@favorodera/eslint-config 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.cjs +689 -0
- package/dist/index.d.cts +8955 -0
- package/dist/index.d.mts +8955 -0
- package/dist/index.mjs +663 -0
- package/package.json +88 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Eslint Config
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
25
|
+
let defu = require("defu");
|
|
26
|
+
let eslint_merge_processors = require("eslint-merge-processors");
|
|
27
|
+
let globals = require("globals");
|
|
28
|
+
globals = __toESM(globals, 1);
|
|
29
|
+
//#region src/utils.ts
|
|
30
|
+
/**
|
|
31
|
+
* Return the default export from a module-like object.
|
|
32
|
+
* If the module has no default export, return the original resolved value.
|
|
33
|
+
*
|
|
34
|
+
* @param module - module or promise resolving to a module
|
|
35
|
+
* @returns resolved module default or original module
|
|
36
|
+
*/
|
|
37
|
+
async function getModuleDefault(module) {
|
|
38
|
+
const resolvedModule = await module;
|
|
39
|
+
return resolvedModule.default || resolvedModule;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Normalize boolean or options value into merged options or null.
|
|
43
|
+
* Returns null when the input is false or undefined.
|
|
44
|
+
*
|
|
45
|
+
* @param value - boolean, options object, or undefined
|
|
46
|
+
* @param defaults - defaults to merge with
|
|
47
|
+
* @returns merged options or false
|
|
48
|
+
*/
|
|
49
|
+
function resolveOptions(value, defaults) {
|
|
50
|
+
if (!value) return false;
|
|
51
|
+
return (0, defu.defu)(value === true ? {} : value, defaults);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Rename rules by replacing configured plugin prefixes.
|
|
55
|
+
*
|
|
56
|
+
* @param rules - rules object to rename
|
|
57
|
+
* @param map - prefix map used for renaming
|
|
58
|
+
* @returns renamed rules object
|
|
59
|
+
*/
|
|
60
|
+
function renameRules(rules, map) {
|
|
61
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
62
|
+
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
63
|
+
return [key, value];
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/globs.ts
|
|
68
|
+
/** Glob pattern for JavaScript linting */
|
|
69
|
+
const jsGlob = "**/*.?([cm])js";
|
|
70
|
+
/** Glob pattern for TypeScript linting */
|
|
71
|
+
const tsGlob = "**/*.?([cm])ts";
|
|
72
|
+
/** Glob pattern for Vue linting */
|
|
73
|
+
const vueGlob = "**/*.vue";
|
|
74
|
+
/** Glob pattern for Markdown linting */
|
|
75
|
+
const mdGlob = "**/*.md";
|
|
76
|
+
/**
|
|
77
|
+
* Default glob patterns for files and directories to ignore
|
|
78
|
+
* Includes common build outputs, dependencies, caches, and temporary files
|
|
79
|
+
*/
|
|
80
|
+
const ignoresGlob = [
|
|
81
|
+
"**/node_modules",
|
|
82
|
+
"**/dist",
|
|
83
|
+
"**/package-lock.json",
|
|
84
|
+
"**/yarn.lock",
|
|
85
|
+
"**/pnpm-lock.yaml",
|
|
86
|
+
"**/bun.lockb",
|
|
87
|
+
"**/output",
|
|
88
|
+
"**/coverage",
|
|
89
|
+
"**/temp",
|
|
90
|
+
"**/.temp",
|
|
91
|
+
"**/tmp",
|
|
92
|
+
"**/.tmp",
|
|
93
|
+
"**/.history",
|
|
94
|
+
"**/.vitepress/cache",
|
|
95
|
+
"**/.nuxt",
|
|
96
|
+
"**/.next",
|
|
97
|
+
"**/.svelte-kit",
|
|
98
|
+
"**/.vercel",
|
|
99
|
+
"**/.changeset",
|
|
100
|
+
"**/.idea",
|
|
101
|
+
"**/.cache",
|
|
102
|
+
"**/.output",
|
|
103
|
+
"**/.vite-inspect",
|
|
104
|
+
"**/.yarn",
|
|
105
|
+
"**/CHANGELOG*.md",
|
|
106
|
+
"**/LICENSE*",
|
|
107
|
+
"**/*.min.*",
|
|
108
|
+
"**/__snapshots__",
|
|
109
|
+
"**/vite.config.*.timestamp-*",
|
|
110
|
+
"**/auto-import?(s).d.ts",
|
|
111
|
+
"**/components.d.ts",
|
|
112
|
+
"**/.context",
|
|
113
|
+
"**/.claude",
|
|
114
|
+
"**/.agents",
|
|
115
|
+
"**/.*/skills"
|
|
116
|
+
];
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/configs/vue.ts
|
|
119
|
+
const sfcBlocksDefaults = { blocks: {
|
|
120
|
+
styles: true,
|
|
121
|
+
customBlocks: true,
|
|
122
|
+
template: false
|
|
123
|
+
} };
|
|
124
|
+
const vueDefaults = {
|
|
125
|
+
files: [vueGlob],
|
|
126
|
+
sfcBlocks: sfcBlocksDefaults
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Vue SFC linting via `vue-eslint-parser`, `eslint-plugin-vue`, `typescript-eslint(parser)`.
|
|
130
|
+
* @param options - Vue configuration options
|
|
131
|
+
* @returns Promise resolving to Vue ESLint config items
|
|
132
|
+
*/
|
|
133
|
+
async function vue(options) {
|
|
134
|
+
const resolved = (0, defu.defu)(options, vueDefaults);
|
|
135
|
+
const sfcBlocks = resolveOptions(resolved.sfcBlocks, sfcBlocksDefaults);
|
|
136
|
+
const [vuePlugin, vueParser, tsEsLint, vueBlocksProcessor] = await Promise.all([
|
|
137
|
+
getModuleDefault(import("eslint-plugin-vue")),
|
|
138
|
+
getModuleDefault(import("vue-eslint-parser")),
|
|
139
|
+
getModuleDefault(import("typescript-eslint")),
|
|
140
|
+
getModuleDefault(import("eslint-processor-vue-blocks"))
|
|
141
|
+
]);
|
|
142
|
+
return [{
|
|
143
|
+
name: "favorodera/vue/rules",
|
|
144
|
+
plugins: { vue: vuePlugin },
|
|
145
|
+
files: resolved.files,
|
|
146
|
+
languageOptions: {
|
|
147
|
+
globals: {
|
|
148
|
+
computed: "readonly",
|
|
149
|
+
defineEmits: "readonly",
|
|
150
|
+
defineExpose: "readonly",
|
|
151
|
+
defineProps: "readonly",
|
|
152
|
+
onMounted: "readonly",
|
|
153
|
+
onUnmounted: "readonly",
|
|
154
|
+
reactive: "readonly",
|
|
155
|
+
ref: "readonly",
|
|
156
|
+
shallowReactive: "readonly",
|
|
157
|
+
shallowRef: "readonly",
|
|
158
|
+
toRef: "readonly",
|
|
159
|
+
toRefs: "readonly",
|
|
160
|
+
watch: "readonly",
|
|
161
|
+
watchEffect: "readonly"
|
|
162
|
+
},
|
|
163
|
+
parser: vueParser,
|
|
164
|
+
parserOptions: {
|
|
165
|
+
parser: tsEsLint.parser,
|
|
166
|
+
extraFileExtensions: [".vue"],
|
|
167
|
+
sourceType: "module"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
processor: sfcBlocks === false ? vuePlugin.processors[".vue"] : (0, eslint_merge_processors.mergeProcessors)([vuePlugin.processors[".vue"], vueBlocksProcessor(sfcBlocks)]),
|
|
171
|
+
rules: {
|
|
172
|
+
...vuePlugin.configs.base.rules,
|
|
173
|
+
...vuePlugin.configs["flat/essential"].map((config) => config.rules).reduce((accumulator, currentConfig) => ({
|
|
174
|
+
...accumulator,
|
|
175
|
+
...currentConfig
|
|
176
|
+
}), {}),
|
|
177
|
+
...vuePlugin.configs["flat/strongly-recommended"].map((config) => config.rules).reduce((accumulator, currentConfig) => ({
|
|
178
|
+
...accumulator,
|
|
179
|
+
...currentConfig
|
|
180
|
+
}), {}),
|
|
181
|
+
...vuePlugin.configs["flat/recommended"].map((config) => config.rules).reduce((accumulator, currentConfig) => ({
|
|
182
|
+
...accumulator,
|
|
183
|
+
...currentConfig
|
|
184
|
+
}), {}),
|
|
185
|
+
"vue/block-order": ["error", { order: [
|
|
186
|
+
"script",
|
|
187
|
+
"template",
|
|
188
|
+
"style"
|
|
189
|
+
] }],
|
|
190
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
191
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
192
|
+
"vue/multi-word-component-names": "off",
|
|
193
|
+
"vue/block-tag-newline": ["error", {
|
|
194
|
+
multiline: "ignore",
|
|
195
|
+
singleline: "ignore"
|
|
196
|
+
}],
|
|
197
|
+
"vue/multiline-html-element-content-newline": ["error", {
|
|
198
|
+
allowEmptyLines: true,
|
|
199
|
+
ignores: ["pre", "textarea"]
|
|
200
|
+
}],
|
|
201
|
+
...resolved.overrides
|
|
202
|
+
}
|
|
203
|
+
}];
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/configs/typescript.ts
|
|
207
|
+
const typescriptDefaults = { files: [tsGlob] };
|
|
208
|
+
/**
|
|
209
|
+
* Extract and merge rules from a compatible config array.
|
|
210
|
+
* @param configs - Array of compatible ESLint configs
|
|
211
|
+
* @returns Merged rules object from all configs
|
|
212
|
+
*/
|
|
213
|
+
function extractRules(configs) {
|
|
214
|
+
return Object.assign({}, ...configs.map((config) => config.rules || {}));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Typescript linting via `typescript-eslint`.
|
|
218
|
+
* @param options - TypeScript configuration options
|
|
219
|
+
* @returns Promise resolving to TypeScript ESLint config items
|
|
220
|
+
*/
|
|
221
|
+
async function typescript(options) {
|
|
222
|
+
const resolved = (0, defu.defu)(options, typescriptDefaults);
|
|
223
|
+
const tsEsLint = await getModuleDefault(import("typescript-eslint"));
|
|
224
|
+
return [{
|
|
225
|
+
name: "favorodera/typescript/rules",
|
|
226
|
+
files: resolved.files,
|
|
227
|
+
plugins: { ts: tsEsLint.plugin },
|
|
228
|
+
languageOptions: {
|
|
229
|
+
parser: tsEsLint.parser,
|
|
230
|
+
parserOptions: { sourceType: "module" }
|
|
231
|
+
},
|
|
232
|
+
rules: {
|
|
233
|
+
...renameRules(extractRules(tsEsLint.configs.strict), { "@typescript-eslint": "ts" }),
|
|
234
|
+
...renameRules(extractRules(tsEsLint.configs.stylistic), { "@typescript-eslint": "ts" }),
|
|
235
|
+
"ts/consistent-type-imports": ["error", { prefer: "type-imports" }],
|
|
236
|
+
"ts/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }],
|
|
237
|
+
"ts/array-type": ["error", { default: "array" }],
|
|
238
|
+
...resolved.overrides
|
|
239
|
+
}
|
|
240
|
+
}];
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/configs/ignores.ts
|
|
244
|
+
const defaultPatterns = ignoresGlob;
|
|
245
|
+
/**
|
|
246
|
+
* Globs for ignoring files and directories from ESLint scanning.
|
|
247
|
+
* @param patterns - Additional ignore patterns or a function to modify the defaults.
|
|
248
|
+
* @returns An array containing the ignore flat config item.
|
|
249
|
+
*/
|
|
250
|
+
function ignores(patterns = []) {
|
|
251
|
+
return [{
|
|
252
|
+
name: "favorodera/ignores",
|
|
253
|
+
ignores: typeof patterns === "function" ? patterns(defaultPatterns) : [...defaultPatterns, ...patterns]
|
|
254
|
+
}];
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/configs/stylistic.ts
|
|
258
|
+
const stylisticDefaults = {
|
|
259
|
+
indent: 2,
|
|
260
|
+
experimental: false,
|
|
261
|
+
quotes: "single",
|
|
262
|
+
semi: false,
|
|
263
|
+
jsx: false
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Code style via `@stylistic/eslint-plugin`.
|
|
267
|
+
* @param options - Stylistic configuration options
|
|
268
|
+
* @returns Promise resolving to stylistic ESLint config items
|
|
269
|
+
*/
|
|
270
|
+
async function stylistic(options) {
|
|
271
|
+
const resolved = (0, defu.defu)(options, stylisticDefaults);
|
|
272
|
+
const stylePlugin = await getModuleDefault(import("@stylistic/eslint-plugin"));
|
|
273
|
+
const customizedStyleConfig = stylePlugin.configs.customize({
|
|
274
|
+
pluginName: "style",
|
|
275
|
+
...resolved
|
|
276
|
+
});
|
|
277
|
+
return [{
|
|
278
|
+
name: "favorodera/stylistic/rules",
|
|
279
|
+
plugins: { style: stylePlugin },
|
|
280
|
+
rules: {
|
|
281
|
+
...customizedStyleConfig.rules,
|
|
282
|
+
"style/quotes": [
|
|
283
|
+
"error",
|
|
284
|
+
"single",
|
|
285
|
+
{ avoidEscape: true }
|
|
286
|
+
],
|
|
287
|
+
"style/no-multiple-empty-lines": ["error", {
|
|
288
|
+
max: 2,
|
|
289
|
+
maxEOF: 2,
|
|
290
|
+
maxBOF: 0
|
|
291
|
+
}],
|
|
292
|
+
"style/padded-blocks": "off",
|
|
293
|
+
"style/no-trailing-spaces": ["error", { skipBlankLines: true }],
|
|
294
|
+
"style/brace-style": "off",
|
|
295
|
+
"style/generator-star-spacing": ["error", {
|
|
296
|
+
after: true,
|
|
297
|
+
before: false
|
|
298
|
+
}],
|
|
299
|
+
"style/yield-star-spacing": ["error", {
|
|
300
|
+
after: true,
|
|
301
|
+
before: false
|
|
302
|
+
}],
|
|
303
|
+
...resolved.overrides
|
|
304
|
+
}
|
|
305
|
+
}];
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/configs/tailwind.ts
|
|
309
|
+
const tailwindDefaults = {
|
|
310
|
+
files: [
|
|
311
|
+
jsGlob,
|
|
312
|
+
tsGlob,
|
|
313
|
+
vueGlob
|
|
314
|
+
],
|
|
315
|
+
settings: { detectComponentClasses: true }
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Tailwind linting via `eslint-plugin-better-tailwindcss`.
|
|
319
|
+
* @param options - Tailwind configuration options
|
|
320
|
+
* @returns Promise resolving to Tailwind ESLint config items
|
|
321
|
+
*/
|
|
322
|
+
async function tailwind(options) {
|
|
323
|
+
const resolved = (0, defu.defu)(options, tailwindDefaults);
|
|
324
|
+
const tailwindPlugin = await getModuleDefault(import("eslint-plugin-better-tailwindcss"));
|
|
325
|
+
return [{
|
|
326
|
+
name: "favorodera/tailwind/rules",
|
|
327
|
+
plugins: { tailwind: tailwindPlugin },
|
|
328
|
+
files: resolved.files,
|
|
329
|
+
settings: { tailwindcss: resolved.settings },
|
|
330
|
+
rules: {
|
|
331
|
+
...renameRules(tailwindPlugin.configs["recommended-error"].rules, { "better-tailwindcss": "tailwind" }),
|
|
332
|
+
...renameRules(tailwindPlugin.configs["stylistic-error"].rules, { "better-tailwindcss": "tailwind" }),
|
|
333
|
+
"tailwind/no-unregistered-classes": "off",
|
|
334
|
+
"tailwind/enforce-consistent-line-wrapping": ["error", { group: "emptyLine" }],
|
|
335
|
+
...resolved.overrides
|
|
336
|
+
}
|
|
337
|
+
}];
|
|
338
|
+
}
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/configs/comments.ts
|
|
341
|
+
const commentsDefaults = { files: [
|
|
342
|
+
jsGlob,
|
|
343
|
+
tsGlob,
|
|
344
|
+
vueGlob
|
|
345
|
+
] };
|
|
346
|
+
/**
|
|
347
|
+
* Comments linting via `@eslint-community/eslint-plugin-eslint-comments`
|
|
348
|
+
* @param options - Comments configuration options
|
|
349
|
+
* @returns Promise resolving to comments ESLint config items
|
|
350
|
+
*/
|
|
351
|
+
async function comments(options) {
|
|
352
|
+
const resolved = (0, defu.defu)(options, commentsDefaults);
|
|
353
|
+
const commentsPlugin = await getModuleDefault(import("@eslint-community/eslint-plugin-eslint-comments"));
|
|
354
|
+
return [{
|
|
355
|
+
name: "favorodera/comments/rules",
|
|
356
|
+
files: resolved.files,
|
|
357
|
+
plugins: { comments: commentsPlugin },
|
|
358
|
+
rules: {
|
|
359
|
+
...renameRules(commentsPlugin.configs.recommended?.rules || {}, { "@eslint-community/eslint-comments": "comments" }),
|
|
360
|
+
"comments/no-aggregating-enable": "error",
|
|
361
|
+
"comments/no-duplicate-disable": "error",
|
|
362
|
+
"comments/no-unlimited-disable": "error",
|
|
363
|
+
"comments/no-unused-enable": "error",
|
|
364
|
+
...resolved.overrides
|
|
365
|
+
}
|
|
366
|
+
}];
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/configs/imports.ts
|
|
370
|
+
const importsDefaults = { files: [
|
|
371
|
+
jsGlob,
|
|
372
|
+
tsGlob,
|
|
373
|
+
vueGlob
|
|
374
|
+
] };
|
|
375
|
+
/**
|
|
376
|
+
* Imports & unused imports linting via `eslint-plugin-import-lite` and `eslint-plugin-unused-imports`.
|
|
377
|
+
* @param options - Imports & unused imports configuration options
|
|
378
|
+
* @returns Promise resolving to imports & unused imports ESLint config items
|
|
379
|
+
*/
|
|
380
|
+
async function imports(options) {
|
|
381
|
+
const resolved = (0, defu.defu)(options, importsDefaults);
|
|
382
|
+
const [importPlugin, unusedImportsPlugin] = await Promise.all([getModuleDefault(import("eslint-plugin-import-lite")), getModuleDefault(import("eslint-plugin-unused-imports"))]);
|
|
383
|
+
return [{
|
|
384
|
+
name: "favorodera/imports/rules",
|
|
385
|
+
files: resolved.files,
|
|
386
|
+
plugins: {
|
|
387
|
+
"import": importPlugin,
|
|
388
|
+
"unused-imports": unusedImportsPlugin
|
|
389
|
+
},
|
|
390
|
+
rules: {
|
|
391
|
+
...renameRules(importPlugin.configs.recommended?.rules || {}, { "import-lite": "import" }),
|
|
392
|
+
"import/consistent-type-specifier-style": ["error", "top-level"],
|
|
393
|
+
"import/first": "error",
|
|
394
|
+
"import/no-duplicates": "error",
|
|
395
|
+
"import/no-mutable-exports": "error",
|
|
396
|
+
"import/no-named-default": "error",
|
|
397
|
+
"import/newline-after-import": ["error", { count: 1 }],
|
|
398
|
+
"unused-imports/no-unused-imports": "error",
|
|
399
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
400
|
+
args: "after-used",
|
|
401
|
+
argsIgnorePattern: "^_",
|
|
402
|
+
ignoreRestSiblings: true,
|
|
403
|
+
vars: "all",
|
|
404
|
+
varsIgnorePattern: "^_"
|
|
405
|
+
}],
|
|
406
|
+
...resolved.overrides
|
|
407
|
+
}
|
|
408
|
+
}];
|
|
409
|
+
}
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/configs/markdown.ts
|
|
412
|
+
const markdownDefaults = {
|
|
413
|
+
files: [mdGlob],
|
|
414
|
+
gfm: true
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* Markdown linting via `@eslint/markdown`.
|
|
418
|
+
* @param options - Markdown configuration options
|
|
419
|
+
* @returns Promise resolving to Markdown ESLint config items
|
|
420
|
+
*/
|
|
421
|
+
async function markdown(options) {
|
|
422
|
+
const resolved = (0, defu.defu)(options, markdownDefaults);
|
|
423
|
+
const markdownPlugin = await getModuleDefault(import("@eslint/markdown"));
|
|
424
|
+
return [{
|
|
425
|
+
name: "favorodera/markdown/rules",
|
|
426
|
+
files: resolved.files,
|
|
427
|
+
plugins: { md: markdownPlugin },
|
|
428
|
+
processor: (0, eslint_merge_processors.mergeProcessors)([markdownPlugin.processors?.markdown, eslint_merge_processors.processorPassThrough]),
|
|
429
|
+
language: resolved.gfm ? "md/gfm" : "md/commonmark",
|
|
430
|
+
rules: {
|
|
431
|
+
...renameRules(markdownPlugin.configs.recommended[0]?.rules || {}, { markdown: "md" }),
|
|
432
|
+
"md/fenced-code-language": "off",
|
|
433
|
+
"md/no-missing-label-refs": "off",
|
|
434
|
+
...resolved.overrides
|
|
435
|
+
}
|
|
436
|
+
}];
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/configs/javascript.ts
|
|
440
|
+
const javascriptDefaults = { files: [
|
|
441
|
+
jsGlob,
|
|
442
|
+
tsGlob,
|
|
443
|
+
vueGlob
|
|
444
|
+
] };
|
|
445
|
+
/**
|
|
446
|
+
* Javascript linting via `eslint`
|
|
447
|
+
* @param options - Javascript configuration options
|
|
448
|
+
* @returns Promise resolving to javascript ESLint config items
|
|
449
|
+
*/
|
|
450
|
+
async function javascript(options) {
|
|
451
|
+
const resolved = (0, defu.defu)(options, javascriptDefaults);
|
|
452
|
+
const jsPlugin = await getModuleDefault(import("@eslint/js"));
|
|
453
|
+
return [{
|
|
454
|
+
name: "favorodera/javascript/rules",
|
|
455
|
+
files: resolved.files,
|
|
456
|
+
languageOptions: {
|
|
457
|
+
ecmaVersion: "latest",
|
|
458
|
+
sourceType: "module",
|
|
459
|
+
globals: {
|
|
460
|
+
...globals.default.browser,
|
|
461
|
+
...globals.default.es2021,
|
|
462
|
+
...globals.default.node,
|
|
463
|
+
document: "readonly",
|
|
464
|
+
navigator: "readonly",
|
|
465
|
+
window: "readonly"
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
linterOptions: { reportUnusedDisableDirectives: true },
|
|
469
|
+
plugins: { js: jsPlugin },
|
|
470
|
+
rules: {
|
|
471
|
+
...jsPlugin.configs.recommended.rules,
|
|
472
|
+
"accessor-pairs": ["error", {
|
|
473
|
+
enforceForClassMembers: true,
|
|
474
|
+
setWithoutGet: true
|
|
475
|
+
}],
|
|
476
|
+
"array-callback-return": "error",
|
|
477
|
+
"block-scoped-var": "error",
|
|
478
|
+
"constructor-super": "error",
|
|
479
|
+
"default-case-last": "error",
|
|
480
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
481
|
+
"eqeqeq": ["error", "smart"],
|
|
482
|
+
"new-cap": ["error", {
|
|
483
|
+
capIsNew: false,
|
|
484
|
+
newIsCap: true,
|
|
485
|
+
properties: true
|
|
486
|
+
}],
|
|
487
|
+
"no-alert": "error",
|
|
488
|
+
"no-array-constructor": "error",
|
|
489
|
+
"no-async-promise-executor": "error",
|
|
490
|
+
"no-caller": "error",
|
|
491
|
+
"no-case-declarations": "error",
|
|
492
|
+
"no-class-assign": "error",
|
|
493
|
+
"no-compare-neg-zero": "error",
|
|
494
|
+
"no-cond-assign": ["error", "always"],
|
|
495
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
496
|
+
"no-const-assign": "error",
|
|
497
|
+
"no-control-regex": "error",
|
|
498
|
+
"no-debugger": "error",
|
|
499
|
+
"no-delete-var": "error",
|
|
500
|
+
"no-dupe-args": "error",
|
|
501
|
+
"no-dupe-class-members": "error",
|
|
502
|
+
"no-dupe-keys": "error",
|
|
503
|
+
"no-duplicate-case": "error",
|
|
504
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
505
|
+
"no-empty-character-class": "error",
|
|
506
|
+
"no-empty-pattern": "error",
|
|
507
|
+
"no-eval": "error",
|
|
508
|
+
"no-ex-assign": "error",
|
|
509
|
+
"no-extend-native": "error",
|
|
510
|
+
"no-extra-bind": "error",
|
|
511
|
+
"no-extra-boolean-cast": "error",
|
|
512
|
+
"no-fallthrough": "error",
|
|
513
|
+
"no-func-assign": "error",
|
|
514
|
+
"no-global-assign": "error",
|
|
515
|
+
"no-implied-eval": "error",
|
|
516
|
+
"no-import-assign": "error",
|
|
517
|
+
"no-invalid-regexp": "error",
|
|
518
|
+
"no-irregular-whitespace": "error",
|
|
519
|
+
"no-iterator": "error",
|
|
520
|
+
"no-labels": ["error", {
|
|
521
|
+
allowLoop: false,
|
|
522
|
+
allowSwitch: false
|
|
523
|
+
}],
|
|
524
|
+
"no-lone-blocks": "error",
|
|
525
|
+
"no-loss-of-precision": "error",
|
|
526
|
+
"no-misleading-character-class": "error",
|
|
527
|
+
"no-multi-str": "error",
|
|
528
|
+
"no-new": "error",
|
|
529
|
+
"no-new-func": "error",
|
|
530
|
+
"no-new-native-nonconstructor": "error",
|
|
531
|
+
"no-new-wrappers": "error",
|
|
532
|
+
"no-obj-calls": "error",
|
|
533
|
+
"no-octal": "error",
|
|
534
|
+
"no-octal-escape": "error",
|
|
535
|
+
"no-proto": "error",
|
|
536
|
+
"no-prototype-builtins": "error",
|
|
537
|
+
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
538
|
+
"no-regex-spaces": "error",
|
|
539
|
+
"no-restricted-globals": [
|
|
540
|
+
"error",
|
|
541
|
+
{
|
|
542
|
+
message: "Use `globalThis` instead.",
|
|
543
|
+
name: "global"
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
message: "Use `globalThis` instead.",
|
|
547
|
+
name: "self"
|
|
548
|
+
}
|
|
549
|
+
],
|
|
550
|
+
"no-restricted-properties": [
|
|
551
|
+
"error",
|
|
552
|
+
{
|
|
553
|
+
message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
|
|
554
|
+
property: "__proto__"
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
message: "Use `Object.defineProperty` instead.",
|
|
558
|
+
property: "__defineGetter__"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
message: "Use `Object.defineProperty` instead.",
|
|
562
|
+
property: "__defineSetter__"
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
566
|
+
property: "__lookupGetter__"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
message: "Use `Object.getOwnPropertyDescriptor` instead.",
|
|
570
|
+
property: "__lookupSetter__"
|
|
571
|
+
}
|
|
572
|
+
],
|
|
573
|
+
"no-restricted-syntax": [
|
|
574
|
+
"error",
|
|
575
|
+
"TSEnumDeclaration[const=true]",
|
|
576
|
+
"TSExportAssignment"
|
|
577
|
+
],
|
|
578
|
+
"no-self-assign": ["error", { props: true }],
|
|
579
|
+
"no-self-compare": "error",
|
|
580
|
+
"no-sequences": "error",
|
|
581
|
+
"no-shadow-restricted-names": "error",
|
|
582
|
+
"no-sparse-arrays": "error",
|
|
583
|
+
"no-template-curly-in-string": "error",
|
|
584
|
+
"no-this-before-super": "error",
|
|
585
|
+
"no-throw-literal": "error",
|
|
586
|
+
"no-undef": "error",
|
|
587
|
+
"no-undef-init": "error",
|
|
588
|
+
"no-unexpected-multiline": "error",
|
|
589
|
+
"no-unmodified-loop-condition": "error",
|
|
590
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
591
|
+
"no-unreachable": "error",
|
|
592
|
+
"no-unreachable-loop": "error",
|
|
593
|
+
"no-unsafe-finally": "error",
|
|
594
|
+
"no-unsafe-negation": "error",
|
|
595
|
+
"no-unused-expressions": ["error", {
|
|
596
|
+
allowShortCircuit: true,
|
|
597
|
+
allowTaggedTemplates: true,
|
|
598
|
+
allowTernary: true
|
|
599
|
+
}],
|
|
600
|
+
"no-unused-vars": ["error", {
|
|
601
|
+
args: "none",
|
|
602
|
+
caughtErrors: "none",
|
|
603
|
+
ignoreRestSiblings: true,
|
|
604
|
+
vars: "all"
|
|
605
|
+
}],
|
|
606
|
+
"no-use-before-define": ["error", {
|
|
607
|
+
classes: false,
|
|
608
|
+
functions: false,
|
|
609
|
+
variables: true
|
|
610
|
+
}],
|
|
611
|
+
"no-useless-backreference": "error",
|
|
612
|
+
"no-useless-call": "error",
|
|
613
|
+
"no-useless-catch": "error",
|
|
614
|
+
"no-useless-computed-key": "error",
|
|
615
|
+
"no-useless-constructor": "error",
|
|
616
|
+
"no-useless-rename": "error",
|
|
617
|
+
"no-useless-return": "error",
|
|
618
|
+
"no-var": "error",
|
|
619
|
+
"no-with": "error",
|
|
620
|
+
"object-shorthand": [
|
|
621
|
+
"error",
|
|
622
|
+
"always",
|
|
623
|
+
{
|
|
624
|
+
avoidQuotes: true,
|
|
625
|
+
ignoreConstructors: false
|
|
626
|
+
}
|
|
627
|
+
],
|
|
628
|
+
"one-var": ["error", { initialized: "never" }],
|
|
629
|
+
"prefer-arrow-callback": ["error", {
|
|
630
|
+
allowNamedFunctions: false,
|
|
631
|
+
allowUnboundThis: true
|
|
632
|
+
}],
|
|
633
|
+
"prefer-const": ["error", {
|
|
634
|
+
destructuring: "all",
|
|
635
|
+
ignoreReadBeforeAssign: true
|
|
636
|
+
}],
|
|
637
|
+
"prefer-exponentiation-operator": "error",
|
|
638
|
+
"prefer-promise-reject-errors": "error",
|
|
639
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
640
|
+
"prefer-rest-params": "error",
|
|
641
|
+
"prefer-spread": "error",
|
|
642
|
+
"prefer-template": "error",
|
|
643
|
+
"symbol-description": "error",
|
|
644
|
+
"unicode-bom": ["error", "never"],
|
|
645
|
+
"use-isnan": ["error", {
|
|
646
|
+
enforceForIndexOf: true,
|
|
647
|
+
enforceForSwitchCase: true
|
|
648
|
+
}],
|
|
649
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
650
|
+
"vars-on-top": "error",
|
|
651
|
+
"yoda": ["error", "never"],
|
|
652
|
+
...resolved.overrides
|
|
653
|
+
}
|
|
654
|
+
}];
|
|
655
|
+
}
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/factory.ts
|
|
658
|
+
/**
|
|
659
|
+
* Factory to create a flat ESLint config
|
|
660
|
+
* @param options - Configuration options for the ESLint config
|
|
661
|
+
* @returns Flat ESLint config composer
|
|
662
|
+
*/
|
|
663
|
+
function factory(options = {}) {
|
|
664
|
+
const configs = [];
|
|
665
|
+
configs.push(ignores(options.ignores));
|
|
666
|
+
const vueOptions = resolveOptions(options.vue, {});
|
|
667
|
+
const typescriptOptions = resolveOptions(options.typescript, {});
|
|
668
|
+
const stylisticOptions = resolveOptions(options.stylistic, {});
|
|
669
|
+
const tailwindOptions = resolveOptions(options.tailwind, {});
|
|
670
|
+
const commentsOptions = resolveOptions(options.comments, {});
|
|
671
|
+
const importsOptions = resolveOptions(options.imports, {});
|
|
672
|
+
const markdownOptions = resolveOptions(options.markdown, {});
|
|
673
|
+
const javascriptOptions = resolveOptions(options.javascript, {});
|
|
674
|
+
if (vueOptions) configs.push(vue(vueOptions));
|
|
675
|
+
if (typescriptOptions) configs.push(typescript(typescriptOptions));
|
|
676
|
+
if (stylisticOptions) configs.push(stylistic(stylisticOptions));
|
|
677
|
+
if (tailwindOptions) configs.push(tailwind(tailwindOptions));
|
|
678
|
+
if (commentsOptions) configs.push(comments(commentsOptions));
|
|
679
|
+
if (importsOptions) configs.push(imports(importsOptions));
|
|
680
|
+
if (markdownOptions) configs.push(markdown(markdownOptions));
|
|
681
|
+
if (javascriptOptions) configs.push(javascript(javascriptOptions));
|
|
682
|
+
let composer = new eslint_flat_config_utils.FlatConfigComposer();
|
|
683
|
+
composer = composer.append(...configs);
|
|
684
|
+
return composer;
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
exports.factory = factory;
|
|
688
|
+
exports.getModuleDefault = getModuleDefault;
|
|
689
|
+
exports.renameRules = renameRules;
|