|
1 | 1 | module.exports = {
|
2 |
| - parser: `@babel/eslint-parser`, |
3 |
| - extends: [ |
4 |
| - `google`, |
5 |
| - `eslint:recommended`, |
6 |
| - `plugin:react/recommended`, |
7 |
| - `prettier`, |
8 |
| - ], |
9 |
| - plugins: [`prettier`, `react`, `filenames`, `@babel`], |
| 2 | + extends: '@netlify/eslint-config-node', |
| 3 | + rules: { |
| 4 | + 'max-depth': 0, |
| 5 | + complexity: 0, |
| 6 | + 'fp/no-let': 0, |
| 7 | + 'fp/no-loops': 0, |
| 8 | + 'fp/no-mutation': 0, |
| 9 | + 'fp/no-mutating-methods': 0, |
| 10 | + 'id-length': 0, |
| 11 | + 'no-magic-numbers': 0, |
| 12 | + 'no-param-reassign': 0, |
| 13 | + 'no-promise-executor-return': 0, |
| 14 | + 'no-prototype-builtins': 0, |
| 15 | + 'no-unused-vars': ['error', { ignoreRestSiblings: true }], |
| 16 | + 'unicorn/filename-case': 0, |
| 17 | + 'unicorn/numeric-separators-style': 0, |
| 18 | + 'unicorn/no-empty-file': 0, |
| 19 | + 'no-plusplus': 0, |
| 20 | + }, |
10 | 21 | parserOptions: {
|
11 |
| - ecmaVersion: 2016, |
12 |
| - sourceType: `module`, |
13 |
| - ecmaFeatures: { |
14 |
| - jsx: true, |
15 |
| - }, |
16 |
| - babelOptions: { |
17 |
| - configFile: `./.babelrc`, |
18 |
| - }, |
| 22 | + sourceType: 'module', |
19 | 23 | },
|
20 | 24 | env: {
|
21 |
| - browser: true, |
22 |
| - es6: true, |
23 |
| - node: true, |
24 | 25 | jest: true,
|
25 | 26 | },
|
26 |
| - globals: { |
27 |
| - before: true, |
28 |
| - after: true, |
29 |
| - spyOn: true, |
30 |
| - // These should be in scope but for some reason eslint can't see them |
31 |
| - NodeJS: true, |
32 |
| - JSX: true, |
33 |
| - NodeRequire: true, |
34 |
| - TimerHandler: true, |
35 |
| - __PATH_PREFIX__: true, |
36 |
| - __BASE_PATH__: true, |
37 |
| - __ASSET_PREFIX__: true, |
38 |
| - _CFLAGS_: true, |
39 |
| - }, |
40 |
| - rules: { |
41 |
| - "@babel/no-unused-expressions": [ |
42 |
| - `error`, |
43 |
| - { |
44 |
| - allowTaggedTemplates: true, |
45 |
| - }, |
46 |
| - ], |
47 |
| - "no-unused-expressions": `off`, |
48 |
| - "@babel/no-invalid-this": `error`, |
49 |
| - "no-invalid-this": `off`, |
50 |
| - "arrow-body-style": [ |
51 |
| - `error`, |
52 |
| - `as-needed`, |
53 |
| - { requireReturnForObjectLiteral: true }, |
54 |
| - ], |
55 |
| - "new-cap": `off`, |
56 |
| - "no-unused-vars": [ |
57 |
| - `warn`, |
58 |
| - { |
59 |
| - varsIgnorePattern: `^_`, |
60 |
| - argsIgnorePattern: `^_`, |
61 |
| - ignoreRestSiblings: true, |
62 |
| - }, |
63 |
| - ], |
64 |
| - "consistent-return": [`error`], |
65 |
| - "filenames/match-regex": [`error`, `^[a-z-\\d\\.]+$`, true], |
66 |
| - "no-console": `off`, |
67 |
| - "no-inner-declarations": `off`, |
68 |
| - "prettier/prettier": `error`, |
69 |
| - quotes: [`error`, `backtick`], |
70 |
| - "react/display-name": `off`, |
71 |
| - "react/jsx-key": `warn`, |
72 |
| - "react/no-unescaped-entities": `off`, |
73 |
| - "react/prop-types": `off`, |
74 |
| - "require-jsdoc": `off`, |
75 |
| - "valid-jsdoc": `off`, |
76 |
| - "prefer-promise-reject-errors": `warn`, |
77 |
| - "no-prototype-builtins": `warn`, |
78 |
| - "guard-for-in": `warn`, |
79 |
| - "spaced-comment": [ |
80 |
| - `error`, |
81 |
| - `always`, |
82 |
| - { markers: [`/`], exceptions: [`*`, `+`] }, |
83 |
| - ], |
84 |
| - camelcase: [ |
85 |
| - `error`, |
86 |
| - { |
87 |
| - properties: `never`, |
88 |
| - ignoreDestructuring: true, |
89 |
| - allow: [`^unstable_`], |
90 |
| - }, |
91 |
| - ], |
92 |
| - }, |
93 |
| - overrides: [ |
94 |
| - { |
95 |
| - files: [ |
96 |
| - `packages/**/gatsby-browser.js`, |
97 |
| - `packages/gatsby/cache-dir/**/*`, |
98 |
| - ], |
99 |
| - env: { |
100 |
| - browser: true, |
101 |
| - }, |
102 |
| - globals: { |
103 |
| - ___loader: false, |
104 |
| - ___emitter: false, |
105 |
| - }, |
106 |
| - }, |
107 |
| - { |
108 |
| - files: [`**/cypress/integration/**/*`, `**/cypress/support/**/*`], |
109 |
| - globals: { |
110 |
| - cy: false, |
111 |
| - Cypress: false, |
112 |
| - }, |
113 |
| - }, |
114 |
| - { |
115 |
| - files: [`*.ts`, `*.tsx`], |
116 |
| - parser: `@typescript-eslint/parser`, |
117 |
| - plugins: [`@typescript-eslint/eslint-plugin`], |
118 |
| - extends: [`plugin:@typescript-eslint/recommended`], |
119 |
| - rules: { |
120 |
| - // We should absolutely avoid using ts-ignore, but it's not always possible. |
121 |
| - // particular when a dependencies types are incorrect. |
122 |
| - "@typescript-eslint/ban-ts-comment": [ |
123 |
| - `warn`, |
124 |
| - { "ts-ignore": `allow-with-description` }, |
125 |
| - ], |
126 |
| - // This rule is great. It helps us not throw on types for areas that are |
127 |
| - // easily inferrable. However we have a desire to have all function inputs |
128 |
| - // and outputs declaratively typed. So this let's us ignore the parameters |
129 |
| - // inferrable lint. |
130 |
| - "@typescript-eslint/no-inferrable-types": [ |
131 |
| - `error`, |
132 |
| - { ignoreParameters: true }, |
133 |
| - ], |
134 |
| - "@typescript-eslint/ban-types": [ |
135 |
| - `error`, |
136 |
| - { |
137 |
| - extendDefaults: true, |
138 |
| - types: { |
139 |
| - "{}": { |
140 |
| - fixWith: `Record<string, unknown>`, |
141 |
| - }, |
142 |
| - object: { |
143 |
| - fixWith: `Record<string, unknown>`, |
144 |
| - }, |
145 |
| - }, |
146 |
| - }, |
147 |
| - ], |
148 |
| - camelcase: `off`, |
149 |
| - // TODO: These rules allow a lot of stuff and don't really enforce. If we want to apply our styleguide, we'd need to fix a lot of stuff |
150 |
| - "@typescript-eslint/naming-convention": [ |
151 |
| - `error`, |
152 |
| - { |
153 |
| - selector: `default`, |
154 |
| - format: [`camelCase`], |
155 |
| - }, |
156 |
| - { |
157 |
| - selector: `variable`, |
158 |
| - format: [`camelCase`, `UPPER_CASE`, `PascalCase`], |
159 |
| - leadingUnderscore: `allowSingleOrDouble`, |
160 |
| - trailingUnderscore: `allowSingleOrDouble`, |
161 |
| - }, |
162 |
| - { |
163 |
| - selector: `function`, |
164 |
| - format: [`camelCase`, `PascalCase`], |
165 |
| - leadingUnderscore: `allow`, |
166 |
| - }, |
167 |
| - { |
168 |
| - selector: `parameter`, |
169 |
| - format: [`camelCase`, `PascalCase`, `snake_case`], |
170 |
| - leadingUnderscore: `allowSingleOrDouble`, |
171 |
| - }, |
172 |
| - { |
173 |
| - selector: `enumMember`, |
174 |
| - format: [`camelCase`, `UPPER_CASE`, `PascalCase`], |
175 |
| - }, |
176 |
| - { |
177 |
| - selector: `typeLike`, |
178 |
| - format: [`PascalCase`], |
179 |
| - }, |
180 |
| - { |
181 |
| - selector: `typeAlias`, |
182 |
| - format: [`camelCase`, `PascalCase`], |
183 |
| - }, |
184 |
| - { |
185 |
| - selector: `property`, |
186 |
| - format: [`PascalCase`, `UPPER_CASE`, `camelCase`, `snake_case`], |
187 |
| - leadingUnderscore: `allowSingleOrDouble`, |
188 |
| - }, |
189 |
| - { |
190 |
| - selector: `objectLiteralProperty`, |
191 |
| - format: [`PascalCase`, `UPPER_CASE`, `camelCase`, `snake_case`], |
192 |
| - leadingUnderscore: `allowSingleOrDouble`, |
193 |
| - trailingUnderscore: `allowSingleOrDouble`, |
194 |
| - }, |
195 |
| - { |
196 |
| - selector: `enum`, |
197 |
| - format: [`PascalCase`, `UPPER_CASE`], |
198 |
| - }, |
199 |
| - { |
200 |
| - selector: `method`, |
201 |
| - format: [`PascalCase`, `camelCase`], |
202 |
| - leadingUnderscore: `allowSingleOrDouble`, |
203 |
| - }, |
204 |
| - { |
205 |
| - selector: `interface`, |
206 |
| - format: [`PascalCase`], |
207 |
| - prefix: [`I`], |
208 |
| - }, |
209 |
| - ], |
210 |
| - // This rule tries to prevent using `require()`. However in node code, |
211 |
| - // there are times where this makes sense. And it specifically is causing |
212 |
| - // problems in our tests where we often want this functionality for module |
213 |
| - // mocking. At this point it's easier to have it off and just encourage |
214 |
| - // using top-level imports via code reviews. |
215 |
| - "@typescript-eslint/no-var-requires": `off`, |
216 |
| - "@typescript-eslint/no-extra-semi": `off`, |
217 |
| - // This rule ensures that typescript types do not have semicolons |
218 |
| - // at the end of their lines, since our prettier setup is to have no semicolons |
219 |
| - // e.g., |
220 |
| - // interface Foo { |
221 |
| - // - baz: string; |
222 |
| - // + baz: string |
223 |
| - // } |
224 |
| - "@typescript-eslint/member-delimiter-style": [ |
225 |
| - `error`, |
226 |
| - { |
227 |
| - multiline: { |
228 |
| - delimiter: `none`, |
229 |
| - }, |
230 |
| - }, |
231 |
| - ], |
232 |
| - "@typescript-eslint/no-empty-function": `off`, |
233 |
| - // This ensures that we always type the return type of functions |
234 |
| - // a high level focus of our TS setup is typing fn inputs and outputs. |
235 |
| - "@typescript-eslint/explicit-function-return-type": `error`, |
236 |
| - // This forces us to use interfaces over types aliases for object definitions. |
237 |
| - // Type is still useful for opaque types |
238 |
| - // e.g., |
239 |
| - // type UUID = string |
240 |
| - "@typescript-eslint/consistent-type-definitions": [ |
241 |
| - `error`, |
242 |
| - `interface`, |
243 |
| - ], |
244 |
| - "@typescript-eslint/no-use-before-define": [ |
245 |
| - `error`, |
246 |
| - { functions: false }, |
247 |
| - ], |
248 |
| - // Allows us to write unions like `type Foo = "baz" | "bar"` |
249 |
| - // otherwise eslint will want to switch the strings to backticks, |
250 |
| - // which then crashes the ts compiler |
251 |
| - quotes: `off`, |
252 |
| - "@typescript-eslint/quotes": [ |
253 |
| - 2, |
254 |
| - `backtick`, |
255 |
| - { |
256 |
| - avoidEscape: true, |
257 |
| - }, |
258 |
| - ], |
259 |
| - |
260 |
| - "@typescript-eslint/array-type": [`error`, { default: `generic` }], |
261 |
| - }, |
262 |
| - }, |
263 |
| - ], |
264 |
| - settings: { |
265 |
| - react: { |
266 |
| - version: `16.9.0`, |
267 |
| - }, |
268 |
| - }, |
269 | 27 | }
|
0 commit comments