-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy patheslint.config.js
More file actions
149 lines (139 loc) · 3.58 KB
/
Copy patheslint.config.js
File metadata and controls
149 lines (139 loc) · 3.58 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import js from '@eslint/js';
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import prettierConfig from 'eslint-config-prettier';
import cypressPlugin from 'eslint-plugin-cypress';
import importPlugin from 'eslint-plugin-import';
import prettierPlugin from 'eslint-plugin-prettier';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import storybookPlugin from 'eslint-plugin-storybook';
import vitestPlugin from 'eslint-plugin-vitest';
import globals from 'globals';
export default [
// Base configuration for all files
{
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
globals: {
// Browser globals
window: 'readonly',
document: 'readonly',
console: 'readonly',
// Node globals
process: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
global: 'readonly',
// Custom globals
Set: 'readonly',
Map: 'readonly',
},
},
settings: {
react: {
version: 'detect',
},
},
},
// ESLint recommended rules
js.configs.recommended,
// Main configuration for source files
{
files: ['**/*.{js,jsx,ts,tsx}'],
ignores: ['node_modules/**', 'dist/**'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
prettier: prettierPlugin,
storybook: storybookPlugin,
import: importPlugin,
'@typescript-eslint': typescriptPlugin,
},
languageOptions: {
globals: globals.browser,
},
rules: {
...typescriptPlugin.configs.recommended.rules,
// ESLint rules
'no-unused-vars': 'warn',
// React rules
'react/prop-types': 'off',
...reactHooksPlugin.configs.recommended.rules,
// Import rules
'import/order': [
'error',
{
groups: ['builtin', 'external', ['parent', 'sibling'], 'index'],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
},
],
// Prettier rules
...prettierConfig.rules,
'prettier/prettier': 'error',
// Storybook rules
...storybookPlugin.configs.recommended.rules,
},
},
// Test files configuration (Vitest)
{
files: [
'**/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
'**/__mocks__/**/*.{js,jsx,ts,tsx}',
'./src/setupTests.ts',
'./src/__tests__/utils.ts',
],
plugins: {
vitest: vitestPlugin,
},
rules: {
...vitestPlugin.configs.recommended.rules,
'vitest/expect-expect': 'off',
},
languageOptions: {
globals: {
globalThis: 'readonly',
describe: 'readonly',
it: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
vi: 'readonly',
},
},
},
// Cypress E2E test files configuration
{
files: ['cypress/e2e/**/*.cy.js'],
plugins: {
cypress: cypressPlugin,
},
rules: {
...cypressPlugin.configs.recommended.rules,
},
languageOptions: {
globals: {
cy: 'readonly',
Cypress: 'readonly',
expect: 'readonly',
assert: 'readonly',
},
},
},
];