-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
139 lines (139 loc) · 4.42 KB
/
.eslintrc.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
module.exports = {
extends: ['airbnb', 'prettier'],
plugins: ['@typescript-eslint', 'react'],
parser: '@babel/eslint-parser', // Use Babel parser for JavaScript files
parserOptions: {
requireConfigFile: false,
},
env: {
browser: true,
node: true,
es6: true,
jest: true,
jquery: true,
},
rules: {
'arrow-body-style': 'off',
'arrow-parens': 'error',
camelcase: 'off',
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'only-multiline',
},
],
'dot-notation': 'off',
'func-names': ['error', 'as-needed'],
'import/extensions': 'off',
'import/no-extraneous-dependencies': [
'error',
{ optionalDependencies: false },
],
'import/prefer-default-export': 'off',
'jsx-quotes': 'warn',
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/label-has-associated-control': [
'error',
{ required: { some: ['nesting', 'id'] } },
],
'jsx-a11y/no-static-element-interactions': 'warn',
'jsx-a11y/tabindex-no-positive': 'warn',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-restricted-syntax': ['off', 'ForOfStatement'],
'no-shadow': 'error',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-underscore-dangle': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-useless-escape': 'error',
'prefer-destructuring': ['error', { object: true, array: false }],
'prefer-template': 'warn',
radix: 'off',
'react/destructuring-assignment': 'off',
'react/function-component-definition': [
'error',
{ namedComponents: 'arrow-function' },
],
'react/jsx-curly-spacing': 'error',
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
'react/jsx-pascal-case': ['error', { allowAllCaps: true }],
'react/jsx-tag-spacing': ['error', { beforeSelfClosing: 'always' }],
'react/forbid-prop-types': 'warn',
'react/jsx-boolean-value': 'off',
'react/jsx-props-no-spreading': 'off',
'react/no-unstable-nested-components': ['warn', { allowAsProps: true }],
'react/self-closing-comp': 'warn',
'react/prop-types': 'off',
},
settings: {
'import/resolver': {
typescript: {}, // Enable ESLint to resolve TypeScript files
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'], // Ensure both JS and TS files are resolved
},
},
},
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json', // Path from your project root
tsconfigRootDir: './', // Points to your project root
},
extends: [
'plugin:@typescript-eslint/recommended',
'prettier', // Prettier config disables conflicting ESLint rules
],
rules: {
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
caughtErrors: 'none',
},
],
'@typescript-eslint/semi': 'off', // we don't use semicolons
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'typeAlias',
format: ['PascalCase'], // Enforce PascalCase for type aliases
trailingUnderscore: 'forbid',
},
{
selector: 'interface',
format: ['PascalCase'], // Enforce PascalCase for interfaces
},
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'], // react components are PascalCase
trailingUnderscore: 'forbid',
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'], // react components are PascalCase
trailingUnderscore: 'forbid',
},
{
selector: 'enum',
format: ['PascalCase'], // Enforce PascalCase for enums
},
{
selector: 'enumMember',
format: ['UPPER_CASE'], // Enforce UPPER_CASE for enum members
},
],
'no-shadow': 'off',
'no-unused-vars': 'off',
'react/require-default-props': 'off', // TypeScript handles this
},
},
],
}