-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.eslintrc.js
57 lines (53 loc) · 1.41 KB
/
.eslintrc.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
const defaultConfig = {
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
plugins: [],
parserOptions: {
sourceType: 'module',
},
env: {
es2020: true,
node: true,
},
rules: {
'prettier/prettier': 'error',
'sort-imports': 'error',
},
};
/**
* Add to `extends` of `defaultConfig`.
*
* The Prettier recommended configuration must be the last extension. See
* https://github.com/prettier/eslint-plugin-prettier#recommended-configuration.
*
* @param {...configurations} configurations Configuration(s) to add.
* @return Superset of the `extends` with the given configuration(s) added.
*/
function addToDefaultExtends(...configurations) {
const prettierConfiguration = 'plugin:prettier/recommended';
const extendsSuperset = defaultConfig.extends
.concat(configurations)
.sort((a, b) => {
if (b === prettierConfiguration) {
return -1;
}
if (a === prettierConfiguration) {
return 1;
}
return 0;
});
return extendsSuperset;
}
const config = defaultConfig;
config.overrides = [
{
files: ['**/*.ts', '**/*.tsx'],
extends: addToDefaultExtends('plugin:@typescript-eslint/recommended'),
parser: '@typescript-eslint/parser',
plugins: defaultConfig.plugins.concat(['@typescript-eslint']),
},
{
files: ['**/*.json'],
extends: addToDefaultExtends('plugin:json/recommended'),
},
];
module.exports = config;