-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
118 lines (114 loc) · 2.82 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const sharedPlugins = ['import', 'jest', 'prettier', 'standard'];
const sharedExtends = [
'standard',
'prettier',
'plugin:prettier/recommended', // Should be the last extension https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
];
const sharedRules = {
'eol-last': 'error',
'import/order': [
'warn',
{
groups: [
['builtin', 'external'],
['internal', 'sibling', 'parent', 'index'],
],
pathGroups: [
{
pattern: '@weco/**',
group: 'external',
position: 'after',
},
],
pathGroupsExcludedImportTypes: ['builtin', 'object'],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
},
],
'no-mixed-operators': 'warn',
'no-multi-spaces': 'warn',
'no-multi-str': 'off',
'no-restricted-imports': [
'error',
{ patterns: ['../*'] }, // Should only import relatively from same directory
],
'no-restricted-syntax': [
'error',
"JSXElement.children > [expression.callee.property.name='stringify']",
],
'no-return-assign': 'off',
'prettier/prettier': 'error',
'sort-imports': [
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
};
const ignorePatterns = [
'/**/node_modules/',
'/**/libs/',
'/**/lib/',
'/**/_next/',
'/**/dist/',
];
module.exports = {
parser: '@babel/eslint-parser',
plugins: sharedPlugins,
env: {
'jest/globals': true,
},
extends: sharedExtends,
ignorePatterns,
rules: sharedRules,
reportUnusedDisableDirectives: true,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
},
overrides: [
{
// we have non-test files in the pipeline/test directory
// this ensures the jest rules only apply to test files
files: ['*test.ts'],
extends: ['plugin:jest/recommended'],
},
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
plugins: [...sharedPlugins, '@typescript-eslint'],
extends: [...sharedExtends, 'plugin:@typescript-eslint/recommended'],
rules: {
...sharedRules,
'no-use-before-define': 'off',
'@typescript-eslint/array-type': ['error'],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false },
],
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true },
],
'jest/no-standalone-expect': [
'error',
{ additionalTestBlockFunctions: ['each.test'] },
],
},
},
// Some directories don't have an absolute import equivalent so ignoring
// import rules for them.
{
files: ['webhook/**'],
rules: {
'no-restricted-imports': 'off',
},
},
],
};