Skip to content

Commit 0b8440f

Browse files
ivan-aksamentovGeekOnCoffee
authored andcommitted
fix: ESLint config overrides key should be an array, not object (facebook#7219)
Array format for `overrides` key in eslint config file is now enforced in ESLint v6. Anyone who uses `eslint-config-react-app` and ESLint v6 gets a type mismatch error. This commit fixes the error by converting the object into a one-element array containing this object. Only 2 characters are added: `[` and `]`. The large diff is due to formatting.
1 parent dac2d0e commit 0b8440f

File tree

1 file changed

+50
-48
lines changed
  • packages/eslint-config-react-app

1 file changed

+50
-48
lines changed

packages/eslint-config-react-app/index.js

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -52,57 +52,59 @@ module.exports = {
5252
},
5353
},
5454

55-
overrides: {
56-
files: ['**/*.ts', '**/*.tsx'],
57-
parser: '@typescript-eslint/parser',
58-
parserOptions: {
59-
ecmaVersion: 2018,
60-
sourceType: 'module',
61-
ecmaFeatures: {
62-
jsx: true,
63-
},
55+
overrides: [
56+
{
57+
files: ['**/*.ts', '**/*.tsx'],
58+
parser: '@typescript-eslint/parser',
59+
parserOptions: {
60+
ecmaVersion: 2018,
61+
sourceType: 'module',
62+
ecmaFeatures: {
63+
jsx: true,
64+
},
6465

65-
// typescript-eslint specific options
66-
warnOnUnsupportedTypeScriptVersion: true,
67-
},
68-
plugins: ['@typescript-eslint'],
69-
// If adding a typescript-eslint version of an existing ESLint rule,
70-
// make sure to disable the ESLint rule here.
71-
rules: {
72-
// TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
73-
'default-case': 'off',
74-
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
75-
'no-dupe-class-members': 'off',
76-
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477)
77-
'no-undef': 'off',
66+
// typescript-eslint specific options
67+
warnOnUnsupportedTypeScriptVersion: true,
68+
},
69+
plugins: ['@typescript-eslint'],
70+
// If adding a typescript-eslint version of an existing ESLint rule,
71+
// make sure to disable the ESLint rule here.
72+
rules: {
73+
// TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
74+
'default-case': 'off',
75+
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
76+
'no-dupe-class-members': 'off',
77+
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477)
78+
'no-undef': 'off',
7879

79-
// Add TypeScript specific rules (and turn off ESLint equivalents)
80-
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
81-
'no-array-constructor': 'off',
82-
'@typescript-eslint/no-array-constructor': 'warn',
83-
'@typescript-eslint/no-namespace': 'error',
84-
'no-use-before-define': 'off',
85-
'@typescript-eslint/no-use-before-define': [
86-
'warn',
87-
{
88-
functions: false,
89-
classes: false,
90-
variables: false,
91-
typedefs: false,
92-
},
93-
],
94-
'no-unused-vars': 'off',
95-
'@typescript-eslint/no-unused-vars': [
96-
'warn',
97-
{
98-
args: 'none',
99-
ignoreRestSiblings: true,
100-
},
101-
],
102-
'no-useless-constructor': 'off',
103-
'@typescript-eslint/no-useless-constructor': 'warn',
80+
// Add TypeScript specific rules (and turn off ESLint equivalents)
81+
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
82+
'no-array-constructor': 'off',
83+
'@typescript-eslint/no-array-constructor': 'warn',
84+
'@typescript-eslint/no-namespace': 'error',
85+
'no-use-before-define': 'off',
86+
'@typescript-eslint/no-use-before-define': [
87+
'warn',
88+
{
89+
functions: false,
90+
classes: false,
91+
variables: false,
92+
typedefs: false,
93+
},
94+
],
95+
'no-unused-vars': 'off',
96+
'@typescript-eslint/no-unused-vars': [
97+
'warn',
98+
{
99+
args: 'none',
100+
ignoreRestSiblings: true,
101+
},
102+
],
103+
'no-useless-constructor': 'off',
104+
'@typescript-eslint/no-useless-constructor': 'warn',
105+
},
104106
},
105-
},
107+
],
106108

107109
// NOTE: When adding rules here, you need to make sure they are compatible with
108110
// `typescript-eslint`, as some rules such as `no-array-constructor` aren't compatible.

0 commit comments

Comments
 (0)