Skip to content

Commit 5943b9c

Browse files
authored
chore: use own eslint rules, not from fb config (#10873)
1 parent 0ef65eb commit 5943b9c

File tree

15 files changed

+229
-318
lines changed

15 files changed

+229
-318
lines changed

.eslintrc.js

+204-30
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@ const internalPackages = getPackages()
1717
.sort();
1818

1919
module.exports = {
20+
env: {
21+
'jest/globals': true,
22+
node: true,
23+
},
2024
extends: [
21-
'fb-strict',
2225
'plugin:import/errors',
23-
'plugin:import/typescript',
2426
'prettier',
25-
'prettier/flowtype',
2627
'plugin:eslint-comments/recommended',
2728
],
2829
overrides: [
2930
{
30-
extends: ['plugin:@typescript-eslint/eslint-recommended'],
31+
extends: [
32+
'plugin:@typescript-eslint/eslint-recommended',
33+
'plugin:import/typescript',
34+
'prettier/@typescript-eslint',
35+
],
3136
files: ['*.ts', '*.tsx'],
3237
plugins: ['@typescript-eslint/eslint-plugin', 'local'],
3338
rules: {
@@ -139,34 +144,22 @@ module.exports = {
139144
rules: {
140145
'arrow-body-style': 'off',
141146
'consistent-return': 'off',
142-
'flowtype/require-valid-file-annotation': 'off',
143147
'import/no-extraneous-dependencies': 'off',
144148
'import/no-unresolved': 'off',
145-
'jest/no-focused-tests': 'off',
146-
'jest/no-identical-title': 'off',
147-
'jest/valid-expect': 'off',
149+
'no-console': 'off',
148150
'no-undef': 'off',
149151
'no-unused-vars': 'off',
150152
'prettier/prettier': 'off',
151-
'react/jsx-no-undef': 'off',
152-
'react/react-in-jsx-scope': 'off',
153153
'sort-keys': 'off',
154154
},
155155
},
156156
{
157157
files: ['examples/**/*'],
158158
rules: {
159-
'babel/func-params-comma-dangle': 'off',
160159
'import/no-unresolved': ['error', {ignore: ['^react-native$']}],
161160
'import/order': 'off',
162161
},
163162
},
164-
{
165-
files: ['scripts/**/*', 'e2e/**/*'],
166-
rules: {
167-
'babel/func-params-comma-dangle': 'off',
168-
},
169-
},
170163
{
171164
files: 'packages/jest-types/**/*',
172165
rules: {
@@ -225,23 +218,68 @@ module.exports = {
225218
},
226219
},
227220
{
228-
files: ['test-types/*.test.ts'],
221+
files: ['test-types/*.test.ts', '*.md'],
229222
rules: {
230223
'jest/no-focused-tests': 'off',
231224
'jest/no-identical-title': 'off',
232225
'jest/valid-expect': 'off',
233226
},
234227
},
228+
{
229+
files: [
230+
'scripts/*',
231+
'packages/jest-cli/src/init/index.ts',
232+
'packages/jest-repl/src/cli/runtime-cli.ts',
233+
],
234+
rules: {
235+
'no-console': 'off',
236+
},
237+
},
238+
{
239+
files: [
240+
'e2e/**',
241+
'examples/**',
242+
'scripts/*',
243+
'website/**',
244+
'**/__mocks__/**',
245+
'**/__tests__/**',
246+
'**/__performance_tests__/**',
247+
'packages/diff-sequences/perf/index.js',
248+
'packages/pretty-format/perf/test.js'
249+
],
250+
rules: {
251+
'import/no-unresolved': 'off',
252+
'no-console': 'off',
253+
'no-unused-vars': 'off',
254+
},
255+
},
235256
],
236257
parser: '@typescript-eslint/parser',
237-
plugins: ['markdown', 'import', 'prettier', 'eslint-comments'],
258+
parserOptions: {
259+
sourceType: 'module',
260+
},
261+
plugins: ['markdown', 'import', 'jest'],
238262
rules: {
239-
'arrow-body-style': 'error',
263+
'accessor-pairs': ['warn', {setWithoutGet: true}],
264+
'block-scoped-var': 'off',
265+
'callback-return': 'off',
266+
camelcase: ['off', {properties: 'always'}],
267+
complexity: 'off',
268+
'consistent-return': 'warn',
269+
'consistent-this': ['off', 'self'],
270+
'constructor-super': 'error',
271+
'default-case': 'off',
272+
'dot-notation': 'off',
273+
eqeqeq: ['off', 'allow-null'],
240274
'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}],
241275
'eslint-comments/no-unused-disable': 'error',
242-
'flowtype/boolean-style': 'error',
243-
'flowtype/no-primitive-constructor-types': 'error',
244-
'flowtype/require-valid-file-annotation': 'error',
276+
'func-names': 'off',
277+
'func-style': ['off', 'declaration'],
278+
'global-require': 'off',
279+
'guard-for-in': 'off',
280+
'handle-callback-err': 'off',
281+
'id-length': 'off',
282+
'id-match': 'off',
245283
'import/no-duplicates': 'error',
246284
'import/no-extraneous-dependencies': [
247285
'error',
@@ -277,17 +315,153 @@ module.exports = {
277315
'newlines-between': 'never',
278316
},
279317
],
280-
'no-console': 'off',
318+
'init-declarations': 'off',
319+
'jest/no-focused-tests': 'error',
320+
'jest/no-identical-title': 'error',
321+
'jest/valid-expect': 'error',
322+
'lines-around-comment': 'off',
323+
'max-depth': 'off',
324+
'max-nested-callbacks': 'off',
325+
'max-params': 'off',
326+
'max-statements': 'off',
327+
'new-cap': 'off',
328+
'new-parens': 'error',
329+
'newline-after-var': 'off',
330+
'no-alert': 'off',
331+
'no-array-constructor': 'error',
332+
'no-bitwise': 'warn',
333+
'no-caller': 'error',
334+
'no-case-declarations': 'off',
335+
'no-catch-shadow': 'error',
336+
'no-class-assign': 'warn',
337+
'no-cond-assign': 'off',
338+
'no-confusing-arrow': 'off',
339+
'no-console': [
340+
'warn',
341+
{allow: ['warn', 'error', 'time', 'timeEnd', 'timeStamp']},
342+
],
343+
'no-const-assign': 'error',
344+
'no-constant-condition': 'off',
345+
'no-continue': 'off',
346+
'no-control-regex': 'off',
347+
'no-debugger': 'error',
348+
'no-delete-var': 'error',
349+
'no-div-regex': 'off',
350+
'no-dupe-args': 'error',
351+
'no-dupe-class-members': 'error',
352+
'no-dupe-keys': 'error',
353+
'no-duplicate-case': 'warn',
354+
'no-else-return': 'off',
355+
'no-empty': 'off',
356+
'no-empty-character-class': 'warn',
357+
'no-empty-pattern': 'warn',
358+
'no-eq-null': 'off',
359+
'no-eval': 'error',
360+
'no-ex-assign': 'warn',
361+
'no-extend-native': 'warn',
362+
'no-extra-bind': 'warn',
363+
'no-extra-boolean-cast': 'warn',
364+
'no-fallthrough': 'warn',
365+
'no-floating-decimal': 'error',
366+
'no-func-assign': 'error',
367+
'no-implicit-coercion': 'off',
368+
'no-implied-eval': 'error',
369+
'no-inline-comments': 'off',
370+
'no-inner-declarations': 'off',
371+
'no-invalid-regexp': 'warn',
372+
'no-invalid-this': 'off',
373+
'no-irregular-whitespace': 'error',
374+
'no-iterator': 'off',
375+
'no-label-var': 'warn',
376+
'no-labels': ['error', {allowLoop: true, allowSwitch: true}],
377+
'no-lonely-if': 'off',
378+
'no-loop-func': 'off',
379+
'no-magic-numbers': 'off',
380+
'no-mixed-requires': 'off',
381+
'no-mixed-spaces-and-tabs': 'error',
382+
'no-multi-str': 'error',
383+
'no-multiple-empty-lines': 'off',
384+
'no-native-reassign': ['error', {exceptions: ['Map', 'Set']}],
385+
'no-negated-condition': 'off',
386+
'no-negated-in-lhs': 'error',
387+
'no-nested-ternary': 'off',
388+
'no-new': 'warn',
389+
'no-new-func': 'error',
390+
'no-new-object': 'warn',
391+
'no-new-require': 'off',
392+
'no-new-wrappers': 'warn',
393+
'no-obj-calls': 'error',
394+
'no-octal': 'warn',
395+
'no-octal-escape': 'warn',
396+
'no-param-reassign': 'off',
397+
'no-path-concat': 'off',
398+
'no-plusplus': 'off',
399+
'no-process-env': 'off',
400+
'no-process-exit': 'off',
401+
'no-proto': 'error',
402+
'no-redeclare': 'warn',
403+
'no-regex-spaces': 'warn',
281404
'no-restricted-imports': [
282405
'error',
283-
{
284-
message: 'Please use graceful-fs instead.',
285-
name: 'fs',
286-
},
406+
{message: 'Please use graceful-fs instead.', name: 'fs'},
407+
],
408+
'no-restricted-modules': 'off',
409+
'no-restricted-syntax': 'off',
410+
'no-return-assign': 'off',
411+
'no-script-url': 'error',
412+
'no-self-compare': 'warn',
413+
'no-sequences': 'warn',
414+
'no-shadow': 'off',
415+
'no-shadow-restricted-names': 'warn',
416+
'no-sparse-arrays': 'error',
417+
'no-sync': 'off',
418+
'no-ternary': 'off',
419+
'no-this-before-super': 'error',
420+
'no-throw-literal': 'error',
421+
'no-undef': 'error',
422+
'no-undef-init': 'off',
423+
'no-undefined': 'off',
424+
'no-underscore-dangle': 'off',
425+
'no-unneeded-ternary': 'warn',
426+
'no-unreachable': 'error',
427+
'no-unused-expressions': 'off',
428+
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
429+
'no-use-before-define': 'off',
430+
'no-useless-call': 'warn',
431+
'no-useless-computed-key': 'error',
432+
'no-useless-concat': 'warn',
433+
'no-var': 'error',
434+
'no-void': 'off',
435+
'no-warn-comments': 'off',
436+
'no-with': 'off',
437+
'object-shorthand': 'error',
438+
'one-var': ['warn', {initialized: 'never'}],
439+
'operator-assignment': ['warn', 'always'],
440+
'operator-linebreak': 'off',
441+
'padded-blocks': 'off',
442+
'prefer-arrow-callback': ['error', {allowNamedFunctions: true}],
443+
'prefer-const': 'error',
444+
'prefer-template': 'off',
445+
quotes: [
446+
'error',
447+
'single',
448+
{allowTemplateLiterals: true, avoidEscape: true},
287449
],
288-
'no-unused-vars': 'error',
289-
'prettier/prettier': 'error',
450+
radix: 'warn',
451+
'require-jsdoc': 'off',
452+
'require-yield': 'off',
290453
'sort-imports': ['error', {ignoreDeclarationSort: true}],
454+
'sort-keys': 'error',
455+
'sort-vars': 'off',
456+
'spaced-comment': ['off', 'always', {exceptions: ['eslint', 'global']}],
457+
strict: 'off',
458+
'use-isnan': 'error',
459+
'valid-jsdoc': 'off',
460+
'valid-typeof': 'error',
461+
'vars-on-top': 'off',
462+
'wrap-iife': 'off',
463+
'wrap-regex': 'off',
464+
yoda: 'off',
291465
},
292466
settings: {
293467
'import/ignore': ['react-native'],

e2e/__tests__/__snapshots__/coverageTransformInstrumented.test.ts.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Object {
2525
"loc": Object {
2626
"end": Object {
2727
"column": 1,
28-
"line": 12,
28+
"line": 11,
2929
},
3030
"start": Object {
3131
"column": 58,
@@ -45,7 +45,7 @@ Object {
4545
"0": Object {
4646
"end": Object {
4747
"column": 2,
48-
"line": 12,
48+
"line": 11,
4949
},
5050
"start": Object {
5151
"column": 0,
@@ -55,21 +55,21 @@ Object {
5555
"1": Object {
5656
"end": Object {
5757
"column": 41,
58-
"line": 10,
58+
"line": 9,
5959
},
6060
"start": Object {
6161
"column": 34,
62-
"line": 10,
62+
"line": 9,
6363
},
6464
},
6565
"2": Object {
6666
"end": Object {
6767
"column": 33,
68-
"line": 11,
68+
"line": 10,
6969
},
7070
"start": Object {
7171
"column": 2,
72-
"line": 11,
72+
"line": 10,
7373
},
7474
},
7575
},

e2e/__tests__/__snapshots__/coverageWithoutTransform.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ exports[`produces code coverage for uncovered files without transformer 1`] = `
55
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
66
---------------------|---------|----------|---------|---------|-------------------
77
All files | 0 | 100 | 0 | 0 |
8-
some-random-file.js | 0 | 100 | 0 | 0 | 8-11
8+
some-random-file.js | 0 | 100 | 0 | 0 | 8-10
99
---------------------|---------|----------|---------|---------|-------------------
1010
`;

e2e/coverage-transform-instrumented/covered.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
module.exports = function doES6Stuff(testObj, multiplier) {
9-
// eslint-disable-next-line no-unused-vars
109
const {someNumber, ...others} = testObj;
1110
return someNumber * multiplier;
1211
};

e2e/coverage-without-transform/some-random-file.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
module.exports = function doES6Stuff(testObj, multiplier) {
9-
// eslint-disable-next-line no-unused-vars
109
const {someNumber, ...others} = testObj;
1110
return someNumber * multiplier;
1211
};

e2e/native-esm/__tests__/native-esm.test.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ import {jest as jestObject} from '@jest/globals';
1515
import staticImportedStatefulFromCjs from '../fromCjs.mjs';
1616
import {double} from '../index';
1717
import defaultFromCjs, {namedFunction} from '../namedExport.cjs';
18+
// eslint-disable-next-line import/named
1819
import {bag} from '../namespaceExport.js';
1920
import staticImportedStateful from '../stateful.mjs';
20-
// https://github.com/benmosher/eslint-plugin-import/issues/1739
21-
/* eslint-disable import/no-unresolved */
2221
import staticImportedStatefulWithQuery from '../stateful.mjs?query=1';
2322
import staticImportedStatefulWithAnotherQuery from '../stateful.mjs?query=2';
24-
/* eslint-enable */
2523

2624
test('should have correct import.meta', () => {
2725
expect(typeof require).toBe('undefined');

e2e/reset-modules/__tests__/resetModules.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
'use strict';
88

9+
// eslint-disable-next-line no-undef
910
global.testObject = new Proxy(
1011
{},
1112
{

e2e/snapshot-serializers/plugins/bar.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*
77
*/
88

9-
// eslint-disable-next-line no-unused-vars
109
const createPlugin = require('../utils').createPlugin;
1110

1211
// We inject the call to "createPlugin('bar') through the transformer"

0 commit comments

Comments
 (0)