-
Notifications
You must be signed in to change notification settings - Fork 6
/
eslint.config.js
111 lines (106 loc) · 3.95 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
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
const globals = require('globals');
const eslint = require('@eslint/js');
const tsEslint = require('typescript-eslint');
const importPlugin = require('eslint-plugin-import');
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y');
const reactPlugin = require('eslint-plugin-react');
const reactHooksPlugin = require('eslint-plugin-react-hooks');
const storybookPlugin = require('eslint-plugin-storybook');
const tailwindPlugin = require('eslint-plugin-tailwindcss');
const testingLibraryPlugin = require('eslint-plugin-testing-library');
const tsConfig = require('./tsconfig.json');
const config = tsEslint.config(
// Default rules
eslint.configs.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
jsxA11yPlugin.flatConfigs.recommended,
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
...storybookPlugin.configs['flat/recommended'],
...tailwindPlugin.configs['flat/recommended'],
...tsEslint.configs.recommendedTypeChecked,
...tsEslint.configs.strictTypeChecked,
...tsEslint.configs.stylisticTypeChecked,
{
languageOptions: {
globals: {
...globals.node,
},
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: true,
node: true,
},
tailwindcss: {
callees: ['classnames', 'classNames'],
},
},
plugins: {
'react-hooks': reactHooksPlugin,
},
},
{
ignores: tsConfig.exclude,
},
{
rules: {
'no-console': 'warn',
curly: 'warn',
'prefer-template': 'warn',
'no-useless-concat': 'warn',
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'always' }],
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true, caughtErrors: 'none' }],
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/dot-notation': ['error', { allowPrivateClassPropertyAccess: true }],
'@typescript-eslint/consistent-type-imports': ['warn', { fixStyle: 'inline-type-imports' }],
'@typescript-eslint/consistent-type-exports': ['warn', { fixMixedExportsWithInlineTypeSpecifier: true }],
'import/no-cycle': 'warn',
'react/prop-types': 'off',
'react/jsx-boolean-value': ['warn', 'always'],
'react/self-closing-comp': 'warn',
'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }],
...reactHooksPlugin.configs.recommended.rules,
},
},
// Rules for JavaScript files
{
files: ['**/*.js'],
...tsEslint.configs.disableTypeChecked,
rules: {
...tsEslint.configs.disableTypeChecked.rules,
'@typescript-eslint/no-require-imports': 'off',
},
},
// Rules for test files
{
files: ['**/*.test.ts', '**/*.test.tsx'],
...testingLibraryPlugin.configs['flat/react'],
rules: {
...testingLibraryPlugin.configs['flat/react'].rules,
'@typescript-eslint/unbound-method': 'off',
},
},
// Rules for Storybook files
{
files: ['**/*.stories.tsx'],
rules: {
'react-hooks/rules-of-hooks': 'off',
},
},
);
module.exports = config;