-
Notifications
You must be signed in to change notification settings - Fork 290
/
.eslintrc.js
128 lines (128 loc) · 3.45 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
module.exports = {
extends: [
'airbnb',
'prettier',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
plugins: ['prettier', 'react-hooks', '@typescript-eslint'],
root: true,
rules: {
'prettier/prettier': 'error',
'react/jsx-filename-extension': 0,
'react/jsx-one-expression-per-line': 0,
'react/no-unescaped-entities': 0,
'react/prop-types': 0,
'jsx-a11y/anchor-is-valid': 0, // https://github.com/zeit/next.js/issues/5533
// The jsx-wrap-multilines rule conflicts with Prettier.
// https://github.com/prettier/prettier/issues/1009#issuecomment-286993938
'react/jsx-wrap-multilines': [
'error',
{
declaration: false,
assignment: false,
},
],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'react/function-component-definition': [
2,
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code
'no-shadow': 0,
'@typescript-eslint/no-shadow': 'error',
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-defsine.md
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
// Let eslint manage semicolons
'@typescript-eslint/no-extra-semi': 0,
'import/no-unresolved': 'error',
'import/prefer-default-export': 0,
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'react/require-default-props': 'off',
},
overrides: [
// Set Jest rules only for test files.
// https://stackoverflow.com/a/49211283
{
files: [
'**/*.test.ts',
'**/*.test.tsx',
'**/__mocks__/**/*.ts',
'**/__mocks__/**/*.tsx',
'**/*.test.js',
'**/*.test.jsx',
'**/__mocks__/**/*.js',
'**/__mocks__/**/*.jsx',
],
extends: ['plugin:jest/recommended'],
env: {
jest: true,
},
plugins: ['jest'],
rules: {
'global-require': 0,
'react/jsx-props-no-spreading': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-empty-function': 0,
},
},
{
files: ['./codemod/**'],
rules: {
'import/no-extraneous-dependencies': 0,
'@typescript-eslint/no-var-requires': 0,
},
},
{
files: ['./codemod/**/*.fixtures/*'],
rules: {
'@typescript-eslint/no-unused-vars': 0,
},
},
{
files: ['index.tests.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
env: {
es6: true,
},
globals: {
// Polyfilled in Next.js 9.4. Set as a Webpack external.
fetch: 'writable',
},
settings: {
// Handle linting for absolute imports.
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
node: true,
},
},
}