-
Notifications
You must be signed in to change notification settings - Fork 5
/
.eslintrc.js
133 lines (130 loc) · 3.18 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const sharedPlugins = [
'import',
'react',
'react-hooks',
'jest',
'prettier',
'standard',
];
const sharedExtends = [
'standard',
'plugin:react/recommended',
'plugin:jest-playwright/recommended',
'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',
'react/react-in-jsx-scope': 'off',
'react/jsx-curly-brace-presence': [
'warn',
{ props: 'never', children: 'never', propElementValues: 'always' },
],
'react-hooks/rules-of-hooks': 'error',
'sort-imports': [
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
};
module.exports = {
parser: '@babel/eslint-parser',
plugins: sharedPlugins,
env: {
'jest/globals': true,
},
extends: sharedExtends,
rules: sharedRules,
reportUnusedDisableDirectives: true,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-react'],
},
},
settings: {
react: {
version: 'detect',
},
},
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
plugins: [...sharedPlugins, '@typescript-eslint'],
extends: [
...sharedExtends,
'plugin:@typescript-eslint/recommended',
'plugin:jest-playwright/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'] },
],
// This rule does not support FunctionComponent<Props> and so
// makes using (eg) children props more of a pain than it should be
'react/prop-types': 'off',
},
},
// Some directories don't have an absolute import equivalent so ignoring
// import rules for them.
{
files: ['dash/**'],
rules: {
'no-restricted-imports': 'off',
},
},
],
};