-
Notifications
You must be signed in to change notification settings - Fork 2
/
eslint.config.js
84 lines (83 loc) · 2.52 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
import { fixupPluginRules } from '@eslint/compat';
import formatjsPlugin from 'eslint-plugin-formatjs';
import globals from 'globals';
import js from '@eslint/js';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
export default [
js.configs.recommended,
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
...reactPlugin.configs.flat.recommended.languageOptions,
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: { react: { version: 'detect' } },
plugins: {
formatjs: formatjsPlugin,
react: reactPlugin,
// Workaround til react-hooks plugin supports ESLint 9:
// https://github.com/facebook/react/issues/28313
'react-hooks': fixupPluginRules(reactHooksPlugin),
'react-refresh': reactRefreshPlugin,
},
rules: {
...reactHooksPlugin.configs.recommended.rules,
'react/jsx-no-target-blank': 'off',
'formatjs/enforce-default-message': 'error',
'formatjs/enforce-description': 'error',
'formatjs/no-complex-selectors': [
'error',
{
limit: 3,
},
],
'formatjs/no-id': 'error',
'formatjs/no-literal-string-in-jsx': 'warn',
'react-refresh/only-export-components': 'warn',
'no-unused-vars': ['warn', { args: 'none', caughtErrors: 'none' }],
'react/prop-types': 'off',
'react/jsx-key': 'warn',
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-constant-condition': 'warn',
'no-unreachable': 'warn',
'require-await': 'warn',
},
linterOptions: {
reportUnusedDisableDirectives: 'warn',
},
},
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: typescriptParser,
},
plugins: {
typescript: typescriptPlugin,
},
// TODO: extend 'plugin:@typescript-eslint/recommended-type-checked'
// (will add a bunch of errors to fix)
rules: {
'no-undef': 'off', // handled by TypeScript
'no-unused-vars': 'off',
'typescript/no-unused-vars': [
'warn',
{ args: 'none', caughtErrors: 'none' },
],
},
},
];