-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.cjs
77 lines (71 loc) · 2.05 KB
/
.eslintrc.cjs
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
// Lint the files included in each typescript project with common rules
const projects = ['./../../.tsconfig/tsconfig.cjs.json'];
// Lint the files included in each typescript project with common rules and jest specific rules
const projectsTests = ['./../../.tsconfig/tsconfig.test.json'];
const plugins = ['@typescript-eslint'];
// Lint project using its tsconfig.json.
const lintProjects = () => {
return [
{
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
//'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier'
],
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: projects,
ecmaVersion: 2020,
sourceType: 'module'
},
plugins,
rules: {
...require('./eslint.rules.cjs'),
...require('./typescript-eslint.rules.cjs')
}
}
];
};
// Attention: Declaration order has importance as rules apply in cascade.
const lintProjectsWithoutTests = () => {
return [...lintProjects()];
};
// tests must be included in their tsconfig project.
const lintTests = () => {
return [
{
env: {
'jest/globals': true
},
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: projectsTests,
ecmaVersion: 2020,
sourceType: 'module'
},
files: ['**/*.test.ts', '**/*.spec.ts'],
extends: ['plugin:jest/recommended', 'plugin:jest/style'],
plugins: ['jest', '@typescript-eslint'],
rules: {
...require('./eslint.rules.cjs'),
...require('./eslint-test.rules.cjs'),
...require('./typescript-eslint.rules.cjs'),
...require('./typescript-eslint-test.rules.cjs'),
...require('./jest-eslint.rules.cjs')
}
}
];
};
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true
},
overrides: [...lintProjectsWithoutTests(), ...lintTests()]
};