-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
156 lines (151 loc) · 4.47 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json'
},
env: {
browser: true,
es6: true,
node: true,
jest: true
},
extends: [
'airbnb',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: ['@typescript-eslint', 'react', 'react-hooks', 'typescript-sort-keys'],
rules: {
// TypeScript Rules
'@typescript-eslint/no-unused-vars': [1, { ignoreRestSiblings: true }],
'@typescript-eslint/member-delimiter-style': [1, {
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": true
},
}],
'@typescript-eslint/no-empty-interface': 0,
// many times, typing will bring duplication
'@typescript-eslint/explicit-function-return-type': 0,
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": true,
"ts-nocheck": true,
"ts-check": true,
"minimumDescriptionLength": 3
}
],
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/interface-name-prefix': 0,
// Import Rules
'import/extensions': [2, 'always', { 'ts': 'never', 'tsx': 'never', 'js': 'never' }],
'import/no-default-export': 2,
'import/prefer-default-export': 0,
// allow to use devDeps in test files.
// See options: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md#options
'import/no-extraneous-dependencies': ["error", {"devDependencies": ["**/*.spec.ts"]}],
// 'sort-imports': 2,
'import/order': [1, {
'groups': ["builtin", "external", "internal", "parent", "sibling", "index"],
'alphabetize': {
order: 'asc'
},
"pathGroups": [
{
"pattern": "src/**",
"group": "parent"
},
]
}],
// Accessibility Rules
// disable anchor-is-valid due to NextJS <a> wrapper
'jsx-a11y/anchor-is-valid': 0,
// React Rules
'react/function-component-definition': [
2,
{ 'namedComponents': 'function-declaration', 'unnamedComponents': 'arrow-function' }
],
'react/jsx-filename-extension': 0,
'react/jsx-boolean-value': [1, 'always'],
'react/jsx-one-expression-per-line': 0,
'react-hooks/rules-of-hooks': 2,
'react-hooks/exhaustive-deps': 2,
// with TypeScript strict mode, no issue
'react/jsx-props-no-spreading': 0,
'react/jsx-sort-props': 1,
// with TypeScript, no default props
'react/require-default-props': 0,
// Plain JavaScript Rules
'arrow-body-style': 0,
'indent': 0, // fix error because it's overidded by @typescript-eslint/indent. Should be removed after ESLint upgrade
'max-len': [1, { code: 120 }],
'no-console': [1, { allow: ['warn', 'error'] }],
'no-multiple-empty-lines': [2, { "max": 1 }], // prettier like
'no-restricted-imports': ['error', {
'patterns': [
'src/*/*',
'!src/adapters/**/*',
'!src/components/*',
'src/components/*/*',
'!src/constants',
'src/constants/*',
'!src/containers/*',
'src/containers/*/*',
'!src/core/*',
'src/core/*/*',
'!src/core/useCases/*',
'src/core/useCases/*/*',
'!src/core/utils/*',
'!src/hooks/*',
'!src/i18n',
'src/i18n/*',
'!src/styles',
'src/styles/*',
'!src/utils/*',
'src/utils/*/*',
]
}],
'semi': [1, 'never'],
// max-len is enought
'object-curly-newline': 0,
// disable due to TypeScript params. More infos here: https://kendaleiv.com/typescript-constructor-assignment-public-and-private-keywords
'no-useless-constructor': 0,
'class-methods-use-this': 0,
'max-classes-per-file': 0,
},
'overrides': [
{
// storybook use both default export and named exports
'files': ['src/**/*.stories.tsx'],
'rules': {
'import/no-default-export': 0,
}
},
{
'files': ['src/pages/**'],
'rules': {
'import/no-default-export': 0,
'import/prefer-default-export': 2,
'no-restricted-exports': 0,
}
},
{
'files': ['src/**/*.reducer.ts'],
'rules': {
'default-param-last': 0,
}
}
],
settings: {
'import/resolver': {
// use <root>/tsconfig.json
typescript: {},
},
},
}