/
recommended.js
59 lines (53 loc) · 1.42 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
58
59
/**
* 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',
],
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.plugins = [ '@typescript-eslint' ];
config.overrides = [
{
files: [ '**/*.ts', '**/*.tsx' ],
parser: '@typescript-eslint/parser',
rules: {
'no-duplicate-imports': 'off',
'@typescript-eslint/no-duplicate-imports': 'error',
// 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;