-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.mjs
136 lines (120 loc) · 3.38 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
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";
import pluginCypress from "eslint-plugin-cypress";
import pluginJest from "eslint-plugin-jest";
/** @type {import('eslint').Linter.Config[]} */
export default [
// Ignore patterns for build artifacts and dependencies
{
ignores: [
".next/**",
"node_modules/**",
"dist/**",
"build/**",
"out/**",
"coverage/**",
"public/static/**",
],
},
// Jest test files configuration
{
files: ["**/*.{test,spec}.{js,ts,jsx,tsx}", "jest.setup.ts"],
languageOptions: {
globals: {
...globals.jest,
},
},
plugins: {
jest: pluginJest,
},
rules: {
...pluginJest.configs.recommended.rules,
},
},
// Cypress test files configuration
{
files: ["cypress/**/*.{js,ts,jsx,tsx}"],
languageOptions: {
globals: {
...globals.browser,
cy: true,
Cypress: true,
describe: true,
it: true,
expect: true,
beforeEach: true,
afterEach: true,
},
},
plugins: {
cypress: pluginCypress,
},
},
// Base config for all JavaScript/TypeScript files
{
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
// Common Node.js globals
require: true,
module: true,
exports: true,
__dirname: true,
__filename: true,
process: true,
Buffer: true,
// React globals
React: true,
JSX: true,
},
},
},
// Core JavaScript rules
pluginJs.configs.recommended,
// TypeScript rules
...tseslint.configs.recommended,
// React specific configuration
{
...pluginReact.configs.flat.recommended,
settings: {
react: {
version: "detect",
},
},
rules: {
// Warns when let is used where const could be used instead
"prefer-const": "warn",
// Warns when var is used instead of let or const
"no-var": "warn",
// Warn when using == and != instead of === and !==
"no-case-declarations": "warn",
// Warn when React props are missing type definitions
"react/prop-types": "warn",
// These rules are turned off since React 17+ doesn't require importing React
// when using JSX, as the new JSX transform handles this automatically
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
// Warn when empty object types are used (e.g. 'type Foo = {}')
"@typescript-eslint/no-empty-object-type": "warn",
// Warn when the 'any' type is used explicitly
"@typescript-eslint/no-explicit-any": "warn",
// Warn when using require() instead of ES6 imports
"@typescript-eslint/no-require-imports": "warn",
// Warn on unused variables, but allow ones starting with underscore
"@typescript-eslint/no-unused-vars": [
"warn",
{
varsIgnorePattern: "^_", // Ignore variables starting with _
argsIgnorePattern: "^_", // Ignore parameters starting with _
},
],
// Error on references to undefined variables
// typeof check ensures typeof checks don't trigger the error
"no-undef": ["error", { typeof: true }],
},
},
];