-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eslintrc.cjs
More file actions
128 lines (128 loc) · 4.2 KB
/
Copy path.eslintrc.cjs
File metadata and controls
128 lines (128 loc) · 4.2 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
/** @type {import("eslint").Linter.Config} */
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'eslint:recommended',
'next/core-web-vitals',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
project: './tsconfig.json',
sourceType: 'module',
ecmaVersion: 'latest'
},
ignorePatterns: [
'.eslintrc.cjs',
'tailwind.config.cjs',
'postcss.config.js',
'next.config.mjs',
'/**/*.md',
'/**/*.html'
],
plugins: [
'import',
'react',
'@typescript-eslint',
'eslint-plugin-prefer-arrow',
'jsx-a11y',
'prettier'
],
rules: {
// Turn off prettier related
'indent': 'off',
'quotes': 'off',
'linebreak-style': 'off',
'semi': 'off',
// General
'no-template-curly-in-string': ['error'],
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
'no-var': 'error',
'no-useless-rename': 'error',
'object-shorthand': ['error', 'always'],
'comma-dangle': ['error', 'never'],
'arrow-body-style': ['error', 'as-needed'],
'eqeqeq': ['error', 'always'],
'dot-notation': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-template': 'error',
'prefer-arrow/prefer-arrow-functions': 'error',
// React
'react/function-component-definition': [
'error',
{ namedComponents: 'arrow-function', unnamedComponents: 'arrow-function' }
],
'react/react-in-jsx-scope': 'off',
'react/self-closing-comp': 'error',
'react/jsx-boolean-value': ['error', 'never'],
'react/jsx-curly-brace-presence': ['error', 'never'],
'react/jsx-curly-spacing': ['error', 'never'],
'react/jsx-equals-spacing': ['error', 'never'],
'react/jsx-fragments': ['error', 'syntax'],
'react/jsx-no-useless-fragment': 'error',
'react/display-name': 'off',
// Typescript
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
],
'@typescript-eslint/consistent-type-imports': [
'warn',
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }
],
// Import
'import/order': [
'error',
{
'newlines-between': 'always',
'groups': [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index'
]
}
]
},
settings: {
// Fix react version detection
'react': { version: 'detect' },
// Set src folder path
'import/resolver': {
node: { paths: 'src' },
typescript: {
extensionAlias: {
'.js': ['.ts', '.tsx', '.d.ts', '.js'],
'.jsx': ['.tsx', '.d.ts', '.jsx'],
'.cjs': ['.cts', '.d.cts', '.cjs'],
'.mjs': ['.mts', '.d.mts', '.mjs']
}
}
}
},
overrides: [
// Disable prop-types errors clashing with typescript options
{
files: ['**/*.tsx'],
rules: { 'react/prop-types': 'off' }
}
]
};