generated from vidavidorra/repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
83 lines (79 loc) · 1.97 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const defaultConfig = {
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
plugins: [],
parserOptions: {
sourceType: 'module',
},
env: {
es2020: true,
node: true,
},
root: true,
rules: {
'no-restricted-globals': [
'error',
/**
* From Jest global environment.
* https://github.com/facebook/jest/blob/v26.6.3/packages/jest-globals/src/index.ts#L12-L27
*/
'jest',
'expect',
'it',
'test',
'fit',
'xit',
'xtest',
'describe',
'xdescribe',
'fdescribe',
'beforeAll',
'beforeEach',
'afterEach',
'afterAll',
],
'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: ['**/*.json'],
extends: addToDefaultExtends('plugin:json/recommended'),
},
{
files: ['**/*.ts', '**/*.tsx'],
extends: addToDefaultExtends(
'plugin:@typescript-eslint/recommended',
'plugin:jest/style',
),
parser: '@typescript-eslint/parser',
plugins: defaultConfig.plugins.concat(['@typescript-eslint']),
rules: { ...defaultConfig.rules, 'jest/consistent-test-it': 'error' },
},
];
module.exports = config;