-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
recommended.js
57 lines (51 loc) · 1.3 KB
/
recommended.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* External dependencies
*/
const { cosmiconfigSync } = require( 'cosmiconfig' );
/**
* WordPress dependencies
*/
const defaultPrettierConfig = require( '@wordpress/prettier-config' );
/**
* Internal dependencies
*/
const { isPackageInstalled } = require( '../utils' );
const { config: localPrettierConfig } =
cosmiconfigSync( 'prettier' ).search() || {};
const prettierConfig = { ...defaultPrettierConfig, ...localPrettierConfig };
const config = {
extends: [
require.resolve( './recommended-with-formatting.js' ),
'plugin:prettier/recommended',
'prettier/react',
],
rules: {
'prettier/prettier': [ 'error', prettierConfig ],
},
};
if ( isPackageInstalled( 'typescript' ) ) {
config.settings = {
'import/resolver': {
node: {
extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
},
},
'import/core-modules': [ 'react' ],
};
config.extends.push( 'plugin:@typescript-eslint/eslint-recommended' );
config.ignorePatterns = [ '**/*.d.ts' ];
config.overrides = [
{
files: [ '**/*.ts', '**/*.tsx' ],
parser: '@typescript-eslint/parser',
rules: {
// Don't require redundant JSDoc types in TypeScript files.
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-type': 'off',
// handled by TS itself
'no-unused-vars': 'off',
},
},
];
}
module.exports = config;