-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.cjs
159 lines (141 loc) · 4.54 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
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
157
158
159
module.exports = {
extends: [
'airbnb',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
plugins: ['@typescript-eslint'],
rules: {
// === NextJS overriden rules ===
'@next/next/no-img-element': 'off',
// === React rules ===
// Enforce a defaultProps definition for every prop that is not a required prop
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
'react/require-default-props': [
'error',
{ ignoreFunctionalComponents: true },
],
// Enforces where React component static properties should be positioned.
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
'react/static-property-placement': ['error', 'static public field'],
// Disallow JSX props spreading
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
'react/jsx-props-no-spreading': 'warn',
// only .jsx files may have JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
'react/jsx-filename-extension': ['error', { extensions: ['.tsx', '.jsx'] }],
// Disallow JSX no bind
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
'react/jsx-no-bind': 'off',
// === import extension overriden rules ===
'import/extensions': [
'error',
{
ts: 'never',
tsx: 'never',
jsx: 'never',
css: 'always',
json: 'always',
},
],
// sort imports. see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
// TLDR; sorted by : ['react', 'external packages', 'mapado packages', 'internal']
'import/order': [
'error',
{
alphabetize: { order: 'asc' },
pathGroups: [
{
pattern: 'react',
group: 'builtin',
position: 'before',
},
{
pattern: '@mapado/**',
group: 'external',
position: 'after',
},
{
pattern: 'mapado-*',
group: 'external',
position: 'after',
},
],
pathGroupsExcludedImportTypes: ['react'],
},
],
// When there is only a single export from a module, prefer using default export over named export.
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
'import/prefer-default-export': 'off',
'import/no-extraneous-dependencies': 'off',
// === default overriden rules ===
// Require braces in arrow function body
// https://eslint.org/docs/rules/arrow-body-style
'arrow-body-style': 'off',
// disallow the unary operators ++ and --
// https://eslint.org/docs/rules/no-plusplus
'no-plusplus': 'off',
// Disallow Early Use
// https://eslint.org/docs/rules/no-use-before-define
'no-use-before-define': 'off',
// Allow padding line between statements
// https://eslint.org/docs/latest/rules/padding-line-between-statements
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: ['return', 'throw'] },
{
blankLine: 'always',
prev: '*',
next: ['const', 'let', 'var', 'function', 'class', 'block-like'],
},
{
blankLine: 'always',
prev: ['const', 'let', 'var', 'function', 'class', 'block-like'],
next: '*',
},
{
blankLine: 'any',
prev: ['const', 'let', 'var'],
next: ['const', 'let', 'var'],
},
],
'no-console': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.d.ts', '.ts', '.tsx'],
},
},
},
ignorePatterns: ['dist/'],
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
rules: {
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'react/static-property-placement': ['error', 'property assignment'],
},
},
{
files: [
'setup_tests.js',
'*.test.js',
'*.test.ts',
'**/__mocks__/*.js',
'**/__mocks__/*.ts',
],
env: { jest: true },
},
],
};