-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.eslint.config.cjs
More file actions
221 lines (218 loc) · 6.08 KB
/
.eslint.config.cjs
File metadata and controls
221 lines (218 loc) · 6.08 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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/**
* ESLint Flat Configuration (CommonJS format)
*
* Converted from ESM to CommonJS for compatibility.
* Load environment variables from .env file
* Enables configuration customization via environment variables
*/
require("dotenv").config();
const js = require("@eslint/js");
const tsPlugin = require("@typescript-eslint/eslint-plugin");
const tsParser = require("@typescript-eslint/parser");
const prettier = require("eslint-plugin-prettier");
/**
* Generate ignore patterns for ESLint
*
* Supports environment variable override via ESLINT_IGNORE (comma-separated list)
* Default patterns exclude build artifacts, dependencies, and template files
*
* @type {string[]} Array of glob patterns to ignore
*/
const ignoreFolders = process.env.ESLINT_IGNORE
? process.env.ESLINT_IGNORE.split(",")
: [
"node_modules/**", // Third-party dependencies
"build/**", // Build output
"dist/**", // Distribution files
"coverage/**", // Test coverage reports
"test-results/**", // Test artifacts
"vendor/**", // Vendor libraries
".next/**", // Next.js build cache
"logs/**", // Application logs
"tmp/**", // Temporary files
".cache/**", // Cache directories
".husky/**", // Git hooks
".vercel/**", // Vercel deployment
".netlify/**", // Netlify deployment
".storybook/**", // Storybook build
"docs/mustache-repo-templates/**", // Template files
"scripts/utility/__tests__/**", // Test files
"scripts/utility/__fixtures__/**", // Test fixtures
];
/**
* ESLint Flat Configuration
*
* Uses the flat config format (ESLint 8.23+, default in 9.0+) with:
* - JavaScript recommended rules
* - TypeScript recommended rules
* - Prettier integration for code formatting
* - Performance-optimized ignore patterns
*
* @type {import('eslint').Linter.FlatConfig[]}
*/
module.exports = [
// Global ignores apply to all configurations
{
ignores: ignoreFolders,
},
// Base JavaScript recommended rules
js.configs.recommended,
// TypeScript specific configuration
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
globals: {
// Node.js globals
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
clearImmediate: "readonly",
clearInterval: "readonly",
clearTimeout: "readonly",
global: "readonly",
process: "readonly",
setImmediate: "readonly",
setInterval: "readonly",
setTimeout: "readonly",
// Jest test environment globals
describe: "readonly",
it: "readonly",
test: "readonly",
expect: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
jest: "readonly",
TextDecoder: "readonly",
TextEncoder: "readonly",
},
},
plugins: {
"@typescript-eslint": tsPlugin,
prettier,
},
// Merge recommended TypeScript rules
rules: {
...tsPlugin.configs.recommended.rules,
"prettier/prettier": "warn",
},
},
// CommonJS files (.cjs)
{
files: ["**/*.cjs"],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "commonjs",
},
},
plugins: { prettier },
rules: {
"prettier/prettier": "warn",
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
// ES Modules (.mjs and scripts that use import/export)
{
files: [
"**/*.mjs",
"scripts/**/*.js",
".github/agents/**/*.js",
".github/metrics/**/*.js",
".github/scripts/**/*.js",
"docs/ai/**/*.js",
],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
globals: {
// Node.js globals
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
clearImmediate: "readonly",
clearInterval: "readonly",
clearTimeout: "readonly",
global: "readonly",
process: "readonly",
setImmediate: "readonly",
setInterval: "readonly",
setTimeout: "readonly",
console: "readonly",
// Jest test environment globals
describe: "readonly",
it: "readonly",
test: "readonly",
expect: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
jest: "readonly",
TextDecoder: "readonly",
TextEncoder: "readonly",
},
},
plugins: { prettier },
rules: {
"prettier/prettier": "warn",
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
// Standard JavaScript files and test utilities (.js)
{
files: ["**/*.js"],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "commonjs",
},
globals: {
// Node.js globals
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
clearImmediate: "readonly",
clearInterval: "readonly",
clearTimeout: "readonly",
global: "readonly",
process: "readonly",
require: "readonly",
module: "readonly",
exports: "readonly",
setImmediate: "readonly",
setInterval: "readonly",
setTimeout: "readonly",
console: "readonly",
// Jest test environment globals
describe: "readonly",
it: "readonly",
test: "readonly",
expect: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
jest: "readonly",
TextDecoder: "readonly",
TextEncoder: "readonly",
},
},
plugins: { prettier },
rules: {
"prettier/prettier": "warn",
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
];