-
Notifications
You must be signed in to change notification settings - Fork 8
/
eslint.config.mjs
187 lines (179 loc) · 4.84 KB
/
eslint.config.mjs
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import js from '@eslint/js';
import globals from 'globals';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import reactHooks from 'eslint-plugin-react-hooks';
import reactPlugin from 'eslint-plugin-react';
import importPlugin from 'eslint-plugin-import';
import nextPlugin from '@next/eslint-plugin-next';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import { FlatCompat } from '@eslint/eslintrc';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
// Combine Next.js and Prettier configs
const nextAndPrettierConfig = [...compat.extends('next/core-web-vitals'), ...compat.extends('prettier')];
export default [
// Config for plain JavaScript files
{
files: ['*.js', '*.mjs', '*.cjs'],
...js.configs.recommended,
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
globals: {
...globals.node,
},
},
},
...nextAndPrettierConfig,
{
// TypeScript and React files
files: ['**/*.{ts,tsx,jsx}'],
plugins: {
react: reactPlugin,
'jsx-a11y': jsxA11y,
'react-hooks': reactHooks,
import: importPlugin,
next: nextPlugin,
'@typescript-eslint': tseslint,
},
languageOptions: {
parser: tsParser,
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
},
},
settings: {
react: {
version: 'detect',
},
next: {
rootDir: '.',
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
node: true,
},
},
rules: {
// TypeScript specific rules
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
// React rules
'react/function-component-definition': [
'warn',
{
namedComponents: 'arrow-function',
},
],
'react/jsx-pascal-case': 'warn',
'react/jsx-filename-extension': [
1,
{
extensions: ['.jsx', '.tsx'],
},
],
'react/jsx-key': 'warn',
'react/no-array-index-key': 'warn',
'react/self-closing-comp': 'warn',
'react/jsx-sort-props': [
'error',
{
ignoreCase: true,
},
],
// React Hooks rules
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// Import rules
'import/no-anonymous-default-export': 'warn',
'import/no-extraneous-dependencies': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'import/no-unresolved': 'error',
'import/named': 'error',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'jsx-a11y/accessible-emoji': 'warn',
// General rules
'no-console': [
'warn',
{
allow: ['warn', 'error'],
},
],
'consistent-return': 'error',
// Prettier-compatible rules
'max-len': ['warn', { code: 120, ignoreUrls: true, ignoreStrings: true, ignoreTemplateLiterals: true }],
quotes: ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'jsx-quotes': ['error', 'prefer-single'],
},
},
{
files: ['e2e-tests/**/*', 'allure-report/**/*', 'app/**/*.{js,jsx,ts,tsx}'],
rules: {
'no-console': 'off',
'consistent-return': 'off',
'react/function-component-definition': [
'warn',
{
namedComponents: 'function-declaration',
},
],
},
},
{
ignores: [
'**/node_modules/**',
'.next/**',
'out/**',
'build/**',
'coverage/**',
'allure-report/',
'postcss.config.js',
'tailwind.config.js',
'next.config.js',
'/eslint.config.mjs',
'lib/auth/types.d.ts',
'lib/constants/errors/errors.ts',
'save/**',
'**/.git/**',
'**/dist/**',
'tests-examples/**',
'eslint.config.mjs',
'e2e-tests/**',
],
},
];