-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy patheslint.config.js
86 lines (82 loc) · 2.71 KB
/
eslint.config.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
const { node, browser } = require('globals')
const pluginJs = require('@eslint/js')
const tseslint = require('typescript-eslint')
const pluginReact = require('eslint-plugin-react')
const noBarrelFiles = require('eslint-plugin-no-barrel-files')
const pluginReactHooks = require('eslint-plugin-react-hooks')
module.exports = [
{
ignores: [
'.next',
'**/dist',
'eslint.config.js',
'public',
'vitest.config.mts',
'playwright-report',
'**/.extracted',
'.vercel',
],
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
pluginReactHooks.configs['recommended-latest'],
{
settings: { react: { version: 'detect' } },
},
{
files: ['**/*.{js,ts,jsx,tsx}'],
languageOptions: { globals: { ...node, ...browser } },
plugins: { 'no-barrel-files': noBarrelFiles },
rules: {
// TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
'default-case': 'off',
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
'no-dupe-class-members': 'off',
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477)
'no-undef': 'off',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'warn',
'@typescript-eslint/no-namespace': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'warn',
{
functions: false,
classes: false,
variables: false,
typedefs: false
}
],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'none',
ignoreRestSiblings: true
}
],
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'warn',
// This is really verbose, and requires the author to add a lot of
// types that are already inferred by Typescript (so you'll see them in
// an IDE like VSCode just fine). We may want it eventually, but I
// suspect it will slow people down when doing page conversions. Note
// that `tslint:recommended` turns this kind of checking off.
'@typescript-eslint/explicit-function-return-type': 'off',
// Not necessary in Next.js (https://spectrum.chat/next-js/general/react-must-be-in-scope-when-using-jsx~6193ef62-4d5e-4681-8f51-8c7bf6b9d56d)
'react/react-in-jsx-scope': 'off',
// For instances where we aren't using esmodules or TypeScript and therefore can't use import
'@typescript-eslint/no-require-imports': 'off',
'no-prototype-builtins': 'off',
'react/prop-types': 'off',
},
},
{
files: ['**/*.ts?(x)'],
rules: {
'react/no-array-index-key': 'warn',
'react/no-unknown-property': ['error', { ignore: ['class'] }]
},
},
]