-
-
Notifications
You must be signed in to change notification settings - Fork 276
Expand file tree
/
Copy patheslint.config.mjs
More file actions
133 lines (130 loc) · 4.13 KB
/
Copy patheslint.config.mjs
File metadata and controls
133 lines (130 loc) · 4.13 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import eslint from '@eslint/js'
import tsParser from '@typescript-eslint/parser'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import eslintPluginReact from 'eslint-plugin-react'
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
import eslintPluginUnusedImports from 'eslint-plugin-unused-imports'
import globals from 'globals'
import typescriptEslint from 'typescript-eslint'
export default typescriptEslint.config(
{ ignores: ['**/*.d.ts', '**/coverage', '**/dist', 'eslint.config.mjs'] },
{
extends: [
eslint.configs.recommended,
...typescriptEslint.configs.recommended,
eslintPluginUnicorn.configs.recommended,
eslintPluginReact.configs.flat.recommended,
eslintPluginReact.configs.flat['jsx-runtime'],
],
plugins: {
'react-hooks': eslintPluginReactHooks,
'unused-imports': eslintPluginUnusedImports,
},
files: ['packages/**/src/**/*.{js,ts,tsx}'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
pragma: 'React',
version: 'detect',
},
},
rules: {
...eslintPluginReactHooks.configs.recommended.rules,
// react-hooks@7 promoted the react-compiler rules into recommended; treat the
// newly-introduced ones as warnings so they don't fail CI on working components
'react-hooks/refs': 'warn',
'react-hooks/set-state-in-effect': 'warn',
'react-hooks/static-components': 'warn',
'@typescript-eslint/no-unused-expressions': [
'error',
{ allowShortCircuit: true, allowTernary: true },
],
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
],
'no-console': 'off',
'no-debugger': 'off',
// the library compiles with the classic JSX transform (tsconfig "jsx": "react"),
// so the React import is required and must count as used
'react/jsx-uses-react': 'error',
'unicorn/filename-case': 'off',
'unicorn/no-array-for-each': 'off',
'unicorn/no-null': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-dom-node-append': 'off',
'unicorn/prefer-export-from': 'off',
'unicorn/prefer-global-this': 'off',
'unicorn/prefer-query-selector': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/prevent-abbreviations': 'off',
'vue/require-default-prop': 'off',
},
},
{
files: ['**/*.mjs'],
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
...globals.node,
},
ecmaVersion: 5,
sourceType: 'module',
},
},
{
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
languageOptions: {
globals: {
...globals.jest,
},
},
},
{
files: ['packages/docs/build/**'],
languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
...globals.node,
},
ecmaVersion: 5,
sourceType: 'commonjs',
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
'no-console': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-top-level-await': 'off',
},
},
{
files: ['packages/docs/**'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
'react/no-unescaped-entities': 'off',
'react-hooks/refs': 'off',
'react-hooks/set-state-in-effect': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/prefer-module': 'off',
},
},
eslintPluginPrettierRecommended
)