@favorodera/eslint-config 0.0.4 → 0.0.6

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/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { FlatConfigComposer, renamePluginsInRules } from "eslint-flat-config-utils";
2
2
  import { defu } from "defu";
3
+ import globals from "globals";
3
4
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
4
5
  import vueBlocksProcessor from "eslint-processor-vue-blocks";
5
- import globals from "globals";
6
6
  //#region src/globs.ts
7
7
  /** Glob pattern for matching JavaScript files */
8
8
  const jsGlob = "**/*.{js,cjs,mjs}";
@@ -16,6 +16,8 @@ const mdGlob = "**/*.md";
16
16
  const mdInMdGlob = "**/*.md/*.md";
17
17
  /** Glob pattern for matching code blocks embedded in Markdown files */
18
18
  const codeInMdGlob = "**/*.md/**/*.{js,cjs,mjs,ts,cts,mts,vue}";
19
+ /** Glob pattern for matching test files */
20
+ const testsGlob = ["**/*.{tests,specs,benchmark,bench}.{js,cjs,mjs,ts,cts,mts}", "**/__tests__/**/*.{js,cjs,mjs,ts,cts,mts}"];
19
21
  /** Glob pattern for matching JSON files */
20
22
  const jsonGlob = "**/*.json";
21
23
  /** Glob pattern for matching JSON5 files */
@@ -24,13 +26,15 @@ const json5Glob = "**/*.json5";
24
26
  const jsoncGlob = "**/*.jsonc";
25
27
  /** Glob patterns for matching TypeScript configuration files */
26
28
  const tsConfigGlob = ["**/tsconfig.json", "**/tsconfig.*.json"];
29
+ /** Glob pattern for matching YAML files */
30
+ const yamlGlob = "**/*.{yml,yaml}";
31
+ /** Glob pattern for matching pnpm-workspace.yaml file */
32
+ const pnpmWorkspaceGlob = "pnpm-workspace.yaml";
27
33
  /** Glob pattern for matching package.json files */
28
34
  const packageJsonGlob = "**/package.json";
29
- /**
30
- * Common glob patterns for files and directories that should be ignored by ESLint.
31
- * Includes node_modules, build outputs, lock files, temporary files, and tool-specific caches.
32
- */
33
- const ignoresGlob = [
35
+ //#endregion
36
+ //#region src/configs/ignores.ts
37
+ const defaultPatterns = [
34
38
  "**/node_modules/**",
35
39
  "**/dist/**",
36
40
  "**/package-lock.json",
@@ -67,9 +71,28 @@ const ignoresGlob = [
67
71
  "**/.agents",
68
72
  "**/.*/skills"
69
73
  ];
74
+ /**
75
+ * Globs for ignoring files and directories from ESLint scanning.
76
+ * @param patterns Additional ignore patterns or a function to modify the defaults.
77
+ * @returns An array containing the ignore flat config item.
78
+ */
79
+ function ignores(patterns = []) {
80
+ return [{
81
+ ignores: typeof patterns === "function" ? patterns(defaultPatterns) : [...defaultPatterns, ...patterns],
82
+ name: "favorodera/ignores"
83
+ }];
84
+ }
70
85
  //#endregion
71
86
  //#region src/utils.ts
72
87
  /**
88
+ * Extracts and merges the rules from multiple ESLint configuration arrays.
89
+ * @param configArrays Rest parameter representing multiple arrays of ESLint flat config items.
90
+ * @returns A single object containing all the merged rules from the provided configurations.
91
+ */
92
+ function extractRules(...configArrays) {
93
+ return Object.assign({}, ...configArrays.flat().map((config) => config?.rules || {}));
94
+ }
95
+ /**
73
96
  * Resolves a module (or a promise of one) and returns its default export
74
97
  * if present, otherwise returns the module itself.
75
98
  *
@@ -96,108 +119,6 @@ function resolveOptions(value, defaults) {
96
119
  if (!value) return false;
97
120
  return defu(value === true ? {} : value, defaults);
98
121
  }
99
- /**
100
- * Extracts and merges the rules from multiple ESLint configuration arrays.
101
- * @param configArrays Rest parameter representing multiple arrays of ESLint flat config items.
102
- * @returns A single object containing all the merged rules from the provided configurations.
103
- */
104
- function extractRules(...configArrays) {
105
- return Object.assign({}, ...configArrays.flat().map((config) => config?.rules || {}));
106
- }
107
- //#endregion
108
- //#region src/configs/vue.ts
109
- const sfcBlocksDefaults = { blocks: {
110
- styles: true,
111
- customBlocks: true,
112
- template: false
113
- } };
114
- const vueDefaults = {
115
- files: [vueGlob],
116
- sfcBlocks: sfcBlocksDefaults
117
- };
118
- /**
119
- * Constructs the flat config items for Vue linting, setting up the custom template parser,
120
- * Vue block processors, and rules to enforce recommended component syntax.
121
- * @param options Vue configuration options.
122
- * @returns Promise resolving to Vue ESLint config items.
123
- */
124
- async function vue(options) {
125
- const resolved = defu(options, vueDefaults);
126
- const sfcBlocks = resolveOptions(resolved.sfcBlocks, sfcBlocksDefaults);
127
- const [vuePlugin, vueParser, tsEsLint] = await Promise.all([
128
- importModule(import("eslint-plugin-vue")),
129
- importModule(import("vue-eslint-parser")),
130
- importModule(import("typescript-eslint"))
131
- ]);
132
- const baseRules = extractRules(vuePlugin.configs["flat/essential"], vuePlugin.configs["flat/strongly-recommended"], vuePlugin.configs["flat/recommended"]);
133
- const processor = sfcBlocks === false ? vuePlugin.processors[".vue"] : mergeProcessors([vuePlugin.processors[".vue"], vueBlocksProcessor(sfcBlocks)]);
134
- return [{
135
- name: "favorodera/vue/setup",
136
- plugins: { vue: vuePlugin },
137
- languageOptions: { globals: {
138
- computed: "readonly",
139
- defineEmits: "readonly",
140
- defineExpose: "readonly",
141
- defineProps: "readonly",
142
- onMounted: "readonly",
143
- onUnmounted: "readonly",
144
- reactive: "readonly",
145
- ref: "readonly",
146
- shallowReactive: "readonly",
147
- shallowRef: "readonly",
148
- toRef: "readonly",
149
- toRefs: "readonly",
150
- watch: "readonly",
151
- watchEffect: "readonly"
152
- } }
153
- }, {
154
- name: "favorodera/vue/rules",
155
- files: resolved.files,
156
- languageOptions: {
157
- parser: vueParser,
158
- parserOptions: {
159
- parser: tsEsLint.parser,
160
- extraFileExtensions: [".vue"],
161
- sourceType: "module"
162
- }
163
- },
164
- processor,
165
- rules: {
166
- ...baseRules,
167
- "vue/block-order": ["error", { order: [
168
- "script",
169
- "template",
170
- "style"
171
- ] }],
172
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
173
- "vue/component-options-name-casing": ["error", "PascalCase"],
174
- "vue/multi-word-component-names": "off",
175
- "vue/block-tag-newline": ["error", {
176
- multiline: "ignore",
177
- singleline: "ignore"
178
- }],
179
- "vue/multiline-html-element-content-newline": ["error", {
180
- allowEmptyLines: true,
181
- ignores: ["pre", "textarea"]
182
- }],
183
- ...resolved.overrides
184
- }
185
- }];
186
- }
187
- //#endregion
188
- //#region src/configs/ignores.ts
189
- const defaultPatterns = ignoresGlob;
190
- /**
191
- * Globs for ignoring files and directories from ESLint scanning.
192
- * @param patterns Additional ignore patterns or a function to modify the defaults.
193
- * @returns An array containing the ignore flat config item.
194
- */
195
- function ignores(patterns = []) {
196
- return [{
197
- name: "favorodera/ignores",
198
- ignores: typeof patterns === "function" ? patterns(defaultPatterns) : [...defaultPatterns, ...patterns]
199
- }];
200
- }
201
122
  //#endregion
202
123
  //#region src/configs/imports.ts
203
124
  const importsDefaults = { files: [
@@ -222,16 +143,16 @@ async function imports(options) {
222
143
  "unused-imports": unusedImportsPlugin
223
144
  }
224
145
  }, {
225
- name: "favorodera/imports/rules",
226
146
  files: resolved.files,
147
+ name: "favorodera/imports/rules",
227
148
  rules: {
228
149
  ...renamePluginsInRules(baseRules, { "import-lite": "import" }),
229
- "import/consistent-type-specifier-style": ["error", "top-level"],
150
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
230
151
  "import/first": "error",
152
+ "import/newline-after-import": ["error", { count: 1 }],
231
153
  "import/no-duplicates": "error",
232
154
  "import/no-mutable-exports": "error",
233
155
  "import/no-named-default": "error",
234
- "import/newline-after-import": ["error", { count: 1 }],
235
156
  "unused-imports/no-unused-imports": "error",
236
157
  "unused-imports/no-unused-vars": ["error", {
237
158
  args: "after-used",
@@ -261,10 +182,8 @@ async function javascript(options) {
261
182
  const resolved = defu(options, javascriptDefaults);
262
183
  const baseRules = (await importModule(import("@eslint/js"))).configs.recommended.rules;
263
184
  return [{
264
- name: "favorodera/javascript/setup",
265
185
  languageOptions: {
266
186
  ecmaVersion: "latest",
267
- sourceType: "module",
268
187
  globals: {
269
188
  ...globals.browser,
270
189
  ...globals.es2021,
@@ -272,251 +191,278 @@ async function javascript(options) {
272
191
  document: "readonly",
273
192
  navigator: "readonly",
274
193
  window: "readonly"
275
- }
194
+ },
195
+ sourceType: "module"
276
196
  },
277
- linterOptions: { reportUnusedDisableDirectives: true }
197
+ linterOptions: { reportUnusedDisableDirectives: true },
198
+ name: "favorodera/javascript/setup"
278
199
  }, {
279
- name: "favorodera/javascript/rules",
280
200
  files: resolved.files,
201
+ name: "favorodera/javascript/rules",
281
202
  rules: {
282
203
  ...baseRules,
283
- "accessor-pairs": ["error", {
284
- enforceForClassMembers: true,
285
- setWithoutGet: true
286
- }],
287
204
  "array-callback-return": "error",
288
205
  "block-scoped-var": "error",
206
+ "constructor-super": "error",
207
+ "default-case-last": "error",
208
+ "dot-notation": ["error", { allowKeywords: true }],
209
+ "eqeqeq": ["error", "smart"],
210
+ "new-cap": ["error", {
211
+ capIsNew: false,
212
+ newIsCap: true,
213
+ properties: true
214
+ }],
215
+ "no-alert": "error",
216
+ "no-array-constructor": "error",
217
+ "no-async-promise-executor": "error",
218
+ "no-caller": "error",
219
+ "no-case-declarations": "error",
220
+ "no-class-assign": "error",
221
+ "no-compare-neg-zero": "error",
222
+ "no-cond-assign": ["error", "always"],
223
+ "no-console": ["error", { allow: ["warn", "error"] }],
224
+ "no-const-assign": "error",
225
+ "no-control-regex": "error",
226
+ "no-debugger": "error",
227
+ "no-delete-var": "error",
228
+ "no-dupe-args": "error",
229
+ "no-dupe-class-members": "error",
230
+ "no-dupe-keys": "error",
231
+ "no-duplicate-case": "error",
232
+ "no-empty": ["error", { allowEmptyCatch: true }],
233
+ "no-empty-character-class": "error",
234
+ "no-empty-pattern": "error",
235
+ "no-eval": "error",
236
+ "no-ex-assign": "error",
237
+ "no-extend-native": "error",
238
+ "no-extra-bind": "error",
239
+ "no-extra-boolean-cast": "error",
240
+ "no-fallthrough": "error",
241
+ "no-func-assign": "error",
242
+ "no-global-assign": "error",
243
+ "no-implied-eval": "error",
244
+ "no-import-assign": "error",
245
+ "no-invalid-regexp": "error",
246
+ "no-irregular-whitespace": "error",
247
+ "no-iterator": "error",
248
+ "no-labels": ["error", {
249
+ allowLoop: false,
250
+ allowSwitch: false
251
+ }],
252
+ "no-lone-blocks": "error",
253
+ "no-loss-of-precision": "error",
254
+ "no-misleading-character-class": "error",
255
+ "no-multi-str": "error",
256
+ "no-new": "error",
257
+ "no-new-func": "error",
258
+ "no-new-native-nonconstructor": "error",
259
+ "no-new-wrappers": "error",
260
+ "no-obj-calls": "error",
261
+ "no-octal": "error",
262
+ "no-octal-escape": "error",
263
+ "no-proto": "error",
264
+ "no-prototype-builtins": "error",
265
+ "no-redeclare": ["error", { builtinGlobals: false }],
266
+ "no-regex-spaces": "error",
267
+ "no-restricted-globals": [
268
+ "error",
269
+ {
270
+ message: "Use `globalThis` instead.",
271
+ name: "global"
272
+ },
273
+ {
274
+ message: "Use `globalThis` instead.",
275
+ name: "self"
276
+ }
277
+ ],
278
+ "no-restricted-properties": [
279
+ "error",
280
+ {
281
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
282
+ property: "__proto__"
283
+ },
284
+ {
285
+ message: "Use `Object.defineProperty` instead.",
286
+ property: "__defineGetter__"
287
+ },
288
+ {
289
+ message: "Use `Object.defineProperty` instead.",
290
+ property: "__defineSetter__"
291
+ },
292
+ {
293
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
294
+ property: "__lookupGetter__"
295
+ },
296
+ {
297
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
298
+ property: "__lookupSetter__"
299
+ }
300
+ ],
301
+ "no-restricted-syntax": [
302
+ "error",
303
+ "TSEnumDeclaration[const=true]",
304
+ "TSExportAssignment"
305
+ ],
306
+ "no-self-assign": ["error", { props: true }],
307
+ "no-self-compare": "error",
308
+ "no-sequences": "error",
309
+ "no-shadow-restricted-names": "error",
310
+ "no-sparse-arrays": "error",
311
+ "no-template-curly-in-string": "error",
312
+ "no-this-before-super": "error",
313
+ "no-throw-literal": "error",
314
+ "no-undef": "error",
315
+ "no-undef-init": "error",
316
+ "no-unexpected-multiline": "error",
317
+ "no-unmodified-loop-condition": "error",
318
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
319
+ "no-unreachable": "error",
320
+ "no-unreachable-loop": "error",
321
+ "no-unsafe-finally": "error",
322
+ "no-unsafe-negation": "error",
323
+ "no-unused-expressions": ["error", {
324
+ allowShortCircuit: true,
325
+ allowTaggedTemplates: true,
326
+ allowTernary: true
327
+ }],
328
+ "no-unused-vars": ["error", {
329
+ args: "none",
330
+ caughtErrors: "none",
331
+ ignoreRestSiblings: true,
332
+ vars: "all"
333
+ }],
334
+ "no-use-before-define": ["error", {
335
+ classes: false,
336
+ functions: false,
337
+ variables: true
338
+ }],
339
+ "no-useless-backreference": "error",
340
+ "no-useless-call": "error",
341
+ "no-useless-catch": "error",
342
+ "no-useless-computed-key": "error",
343
+ "no-useless-constructor": "error",
344
+ "no-useless-rename": "error",
345
+ "no-useless-return": "error",
346
+ "no-var": "error",
347
+ "no-with": "error",
348
+ "object-shorthand": [
349
+ "error",
350
+ "always",
351
+ {
352
+ avoidQuotes: true,
353
+ ignoreConstructors: false
354
+ }
355
+ ],
356
+ "one-var": ["error", { initialized: "never" }],
357
+ "prefer-arrow-callback": ["error", {
358
+ allowNamedFunctions: false,
359
+ allowUnboundThis: true
360
+ }],
361
+ "prefer-const": ["error", {
362
+ destructuring: "all",
363
+ ignoreReadBeforeAssign: true
364
+ }],
365
+ "prefer-exponentiation-operator": "error",
366
+ "prefer-promise-reject-errors": "error",
367
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
368
+ "prefer-rest-params": "error",
369
+ "prefer-spread": "error",
370
+ "prefer-template": "error",
371
+ "symbol-description": "error",
372
+ "unicode-bom": ["error", "never"],
373
+ "use-isnan": ["error", {
374
+ enforceForIndexOf: true,
375
+ enforceForSwitchCase: true
376
+ }],
377
+ "valid-typeof": ["error", { requireStringLiterals: true }],
378
+ "vars-on-top": "error",
379
+ "yoda": ["error", "never"],
289
380
  ...resolved.overrides
290
381
  }
291
382
  }];
292
383
  }
293
384
  //#endregion
294
- //#region src/configs/markdown.ts
295
- const markdownDefaults = {
296
- files: [mdGlob],
297
- gfm: true
298
- };
385
+ //#region src/configs/jsdoc.ts
386
+ const jsdocDefaults = { files: [
387
+ jsGlob,
388
+ tsGlob,
389
+ vueGlob
390
+ ] };
299
391
  /**
300
- * Constructs the flat config items for Markdown linting, extracting and linting
301
- * embedded code blocks within the document according to specified rules.
302
- * @param options Markdown configuration options.
303
- * @returns Promise resolving to Markdown ESLint config items.
392
+ * Constructs the flat config items for JSDoc linting, ensuring comments follow
393
+ * proper styling, parameter checks, and types alignment.
394
+ * @param options JSDoc configuration options.
395
+ * @returns Promise resolving to JSDoc ESLint config items.
304
396
  */
305
- async function markdown(options) {
306
- const resolved = defu(options, markdownDefaults);
307
- const markdownPlugin = await importModule(import("@eslint/markdown"));
308
- const baseRules = extractRules(markdownPlugin.configs.recommended);
397
+ async function jsdoc(options) {
398
+ const resolved = defu(options, jsdocDefaults);
399
+ const jsdocPlugin = await importModule(import("eslint-plugin-jsdoc"));
400
+ const baseRules = {
401
+ ...jsdocPlugin.configs["flat/recommended-typescript-error"]?.rules,
402
+ ...jsdocPlugin.configs["flat/stylistic-typescript-error"]?.rules
403
+ };
404
+ return [{
405
+ name: "favorodera/jsdoc/setup",
406
+ plugins: { jsdoc: jsdocPlugin }
407
+ }, {
408
+ files: resolved.files,
409
+ name: "favorodera/jsdoc/rules",
410
+ rules: {
411
+ ...baseRules,
412
+ "jsdoc/check-access": "warn",
413
+ "jsdoc/check-alignment": "warn",
414
+ "jsdoc/check-param-names": "warn",
415
+ "jsdoc/check-property-names": "warn",
416
+ "jsdoc/check-types": "warn",
417
+ "jsdoc/empty-tags": "warn",
418
+ "jsdoc/implements-on-classes": "warn",
419
+ "jsdoc/multiline-blocks": "warn",
420
+ "jsdoc/no-defaults": "warn",
421
+ "jsdoc/no-multi-asterisks": "warn",
422
+ "jsdoc/require-param-name": "warn",
423
+ "jsdoc/require-property": "warn",
424
+ "jsdoc/require-property-description": "warn",
425
+ "jsdoc/require-property-name": "warn",
426
+ "jsdoc/require-returns-check": "warn",
427
+ "jsdoc/require-returns-description": "warn",
428
+ "jsdoc/require-yields-check": "warn",
429
+ ...resolved.overrides
430
+ }
431
+ }];
432
+ }
433
+ //#endregion
434
+ //#region src/configs/jsonc.ts
435
+ const jsoncDefaults = { files: [
436
+ json5Glob,
437
+ jsoncGlob,
438
+ jsonGlob
439
+ ] };
440
+ /**
441
+ * Constructs the flat config items for JSON, JSON5, and JSONC linting, setting up
442
+ * the custom parser, rule validations, and sorting rules for package.json/tsconfig.json.
443
+ * @param options JSONC configuration options.
444
+ * @returns Promise resolving to JSONC ESLint config items.
445
+ */
446
+ async function jsonc(options) {
447
+ const resolved = defu(options, jsoncDefaults);
309
448
  return [
310
449
  {
311
- name: "favorodera/markdown/setup",
312
- plugins: { md: markdownPlugin }
450
+ name: "favorodera/jsonc/setup",
451
+ plugins: { jsonc: await importModule(import("eslint-plugin-jsonc")) }
313
452
  },
314
453
  {
315
- name: "favorodera/markdown/rules",
316
454
  files: resolved.files,
317
- language: resolved.gfm ? "md/gfm" : "md/commonmark",
318
- ignores: [mdInMdGlob],
319
- processor: mergeProcessors([markdownPlugin.processors?.markdown, processorPassThrough]),
320
- rules: {
321
- ...renamePluginsInRules(baseRules, { markdown: "md" }),
322
- "md/fenced-code-language": "off",
323
- "md/no-missing-label-refs": "off",
324
- ...resolved.overrides
325
- }
326
- },
327
- {
328
- name: "favorodera/markdown/disables/code",
329
- files: [codeInMdGlob],
330
- languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
331
- rules: {
332
- "no-alert": "off",
333
- "no-console": "off",
334
- "no-labels": "off",
335
- "no-lone-blocks": "off",
336
- "no-restricted-syntax": "off",
337
- "no-undef": "off",
338
- "no-unused-expressions": "off",
339
- "no-unused-labels": "off",
340
- "no-unused-vars": "off",
341
- "node/prefer-global/process": "off",
342
- "style/comma-dangle": "off",
343
- "style/eol-last": "off",
344
- "style/padding-line-between-statements": "off",
345
- "ts/consistent-type-imports": "off",
346
- "ts/explicit-function-return-type": "off",
347
- "ts/no-namespace": "off",
348
- "ts/no-redeclare": "off",
349
- "ts/no-require-imports": "off",
350
- "ts/no-unused-expressions": "off",
351
- "ts/no-unused-vars": "off",
352
- "ts/no-use-before-define": "off",
353
- "unicode-bom": "off",
354
- "unused-imports/no-unused-imports": "off",
355
- "unused-imports/no-unused-vars": "off"
356
- }
357
- }
358
- ];
359
- }
360
- //#endregion
361
- //#region src/configs/stylistic.ts
362
- const stylisticDefaults = {
363
- settings: {
364
- indent: 2,
365
- experimental: false,
366
- quotes: "single",
367
- semi: false,
368
- jsx: false
369
- },
370
- files: [
371
- jsGlob,
372
- tsGlob,
373
- vueGlob
374
- ]
375
- };
376
- /**
377
- * Constructs the flat config items for Stylistic linting, applying customized
378
- * formatting settings such as quotes, indentation, and spacing.
379
- * @param options Stylistic configuration options.
380
- * @returns Promise resolving to stylistic ESLint config items.
381
- */
382
- async function stylistic(options) {
383
- const resolved = defu(options, stylisticDefaults);
384
- const stylePlugin = await importModule(import("@stylistic/eslint-plugin"));
385
- const baseRules = stylePlugin.configs.customize({
386
- pluginName: "style",
387
- ...resolved.settings
388
- })?.rules || {};
389
- return [{
390
- name: "favorodera/stylistic/setup",
391
- plugins: { style: stylePlugin }
392
- }, {
393
- name: "favorodera/stylistic/rules",
394
- files: resolved.files,
395
- rules: {
396
- ...baseRules,
397
- "style/quotes": [
398
- "error",
399
- "single",
400
- { avoidEscape: true }
401
- ],
402
- "style/no-multiple-empty-lines": ["error", {
403
- max: 2,
404
- maxEOF: 2,
405
- maxBOF: 0
406
- }],
407
- "style/padded-blocks": "off",
408
- "style/no-trailing-spaces": ["error", { skipBlankLines: true }],
409
- "style/brace-style": "off",
410
- "style/generator-star-spacing": ["error", {
411
- after: true,
412
- before: false
413
- }],
414
- "style/yield-star-spacing": ["error", {
415
- after: true,
416
- before: false
417
- }],
418
- ...resolved.overrides
419
- }
420
- }];
421
- }
422
- //#endregion
423
- //#region src/configs/tailwind.ts
424
- const tailwindDefaults = {
425
- files: [
426
- jsGlob,
427
- tsGlob,
428
- vueGlob
429
- ],
430
- settings: { detectComponentClasses: true }
431
- };
432
- /**
433
- * Constructs the flat config items for Tailwind CSS linting, providing custom settings
434
- * to parse and lint utility classes, and enforcing consistent ordering.
435
- * @param options Tailwind configuration options.
436
- * @returns Promise resolving to Tailwind ESLint config items.
437
- */
438
- async function tailwind(options) {
439
- const resolved = defu(options, tailwindDefaults);
440
- const tailwindPlugin = await importModule(import("eslint-plugin-better-tailwindcss"));
441
- const baseRules = {
442
- ...tailwindPlugin.configs["recommended-error"].rules,
443
- ...tailwindPlugin.configs["stylistic-error"].rules
444
- };
445
- return [{
446
- name: "favorodera/tailwind/setup",
447
- plugins: { tailwind: tailwindPlugin },
448
- settings: { tailwindcss: resolved.settings }
449
- }, {
450
- name: "favorodera/tailwind/rules",
451
- files: resolved.files,
452
- rules: {
453
- ...renamePluginsInRules(baseRules, { "better-tailwindcss": "tailwind" }),
454
- "tailwind/no-unregistered-classes": "off",
455
- "tailwind/enforce-consistent-line-wrapping": ["error", { group: "emptyLine" }],
456
- ...resolved.overrides
457
- }
458
- }];
459
- }
460
- //#endregion
461
- //#region src/configs/typescript.ts
462
- const typescriptDefaults = { files: [tsGlob] };
463
- /**
464
- * Constructs the flat config items for TypeScript linting, initializing the parser
465
- * and extending the recommended and strict type-aware rule sets.
466
- * @param options TypeScript configuration options.
467
- * @returns Promise resolving to TypeScript ESLint config items.
468
- */
469
- async function typescript(options) {
470
- const resolved = defu(options, typescriptDefaults);
471
- const tsEsLint = await importModule(import("typescript-eslint"));
472
- const baseRules = extractRules(tsEsLint.configs.recommended, tsEsLint.configs.strict);
473
- return [{
474
- name: "favorodera/typescript/setup",
475
- plugins: { ts: tsEsLint.plugin }
476
- }, {
477
- name: "favorodera/typescript/rules",
478
- files: resolved.files,
479
- languageOptions: {
480
- parser: tsEsLint.parser,
481
- parserOptions: { sourceType: "module" }
482
- },
483
- rules: {
484
- ...renamePluginsInRules(baseRules, { "@typescript-eslint": "ts" }),
485
- "ts/consistent-type-imports": ["error", { prefer: "type-imports" }],
486
- "ts/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }],
487
- "ts/array-type": ["error", {
488
- default: "generic",
489
- readonly: "generic"
490
- }],
491
- ...resolved.overrides
492
- }
493
- }];
494
- }
495
- //#endregion
496
- //#region src/configs/jsonc.ts
497
- const jsoncDefaults = { files: [
498
- json5Glob,
499
- jsoncGlob,
500
- jsonGlob
501
- ] };
502
- /**
503
- * Constructs the flat config items for JSON, JSON5, and JSONC linting, setting up
504
- * the custom parser, rule validations, and sorting rules for package.json/tsconfig.json.
505
- * @param options JSONC configuration options.
506
- * @returns Promise resolving to JSONC ESLint config items.
507
- */
508
- async function jsonc(options) {
509
- const resolved = defu(options, jsoncDefaults);
510
- return [
511
- {
512
- name: "favorodera/jsonc/setup",
513
- plugins: { jsonc: await importModule(import("eslint-plugin-jsonc")) }
514
- },
515
- {
516
- name: "favorodera/jsonc/rules",
517
- files: resolved.files,
518
- language: "jsonc/x",
455
+ language: "jsonc/x",
456
+ name: "favorodera/jsonc/rules",
519
457
  rules: {
458
+ "jsonc/array-bracket-spacing": ["error", "never"],
459
+ "jsonc/comma-dangle": ["error", "never"],
460
+ "jsonc/comma-style": ["error", "last"],
461
+ "jsonc/indent": ["error", 2],
462
+ "jsonc/key-spacing": ["error", {
463
+ afterColon: true,
464
+ beforeColon: false
465
+ }],
520
466
  "jsonc/no-bigint-literals": "error",
521
467
  "jsonc/no-binary-expression": "error",
522
468
  "jsonc/no-binary-numeric-literals": "error",
@@ -540,17 +486,6 @@ async function jsonc(options) {
540
486
  "jsonc/no-undefined-value": "error",
541
487
  "jsonc/no-unicode-codepoint-escapes": "error",
542
488
  "jsonc/no-useless-escape": "error",
543
- "jsonc/space-unary-ops": "error",
544
- "jsonc/valid-json-number": "error",
545
- "jsonc/vue-custom-block/no-parsing-error": "error",
546
- "jsonc/array-bracket-spacing": ["error", "never"],
547
- "jsonc/comma-dangle": ["error", "never"],
548
- "jsonc/comma-style": ["error", "last"],
549
- "jsonc/indent": ["error", 2],
550
- "jsonc/key-spacing": ["error", {
551
- afterColon: true,
552
- beforeColon: false
553
- }],
554
489
  "jsonc/object-curly-newline": ["error", {
555
490
  consistent: true,
556
491
  multiline: true
@@ -559,12 +494,15 @@ async function jsonc(options) {
559
494
  "jsonc/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
560
495
  "jsonc/quote-props": "error",
561
496
  "jsonc/quotes": "error",
497
+ "jsonc/space-unary-ops": "error",
498
+ "jsonc/valid-json-number": "error",
499
+ "jsonc/vue-custom-block/no-parsing-error": "error",
562
500
  ...resolved.overrides
563
501
  }
564
502
  },
565
503
  {
566
- name: "favorodera/jsonc/sort/package-json",
567
504
  files: [packageJsonGlob],
505
+ name: "favorodera/jsonc/sort/package-json",
568
506
  rules: {
569
507
  "jsonc/sort-array-values": ["error", {
570
508
  order: { type: "asc" },
@@ -632,11 +570,11 @@ async function jsonc(options) {
632
570
  },
633
571
  {
634
572
  order: { type: "asc" },
635
- pathPattern: "^workspaces\\.catalog$"
573
+ pathPattern: String.raw`^workspaces\.catalog$`
636
574
  },
637
575
  {
638
576
  order: { type: "asc" },
639
- pathPattern: "^workspaces\\.catalogs\\.[^.]+$"
577
+ pathPattern: String.raw`^workspaces\.catalogs\.[^.]+$`
640
578
  },
641
579
  {
642
580
  order: [
@@ -666,8 +604,8 @@ async function jsonc(options) {
666
604
  }
667
605
  },
668
606
  {
669
- name: "favorodera/jsonc/sort/tsconfig-json",
670
607
  files: tsConfigGlob,
608
+ name: "favorodera/jsonc/sort/tsconfig-json",
671
609
  rules: { "jsonc/sort-keys": [
672
610
  "error",
673
611
  {
@@ -782,55 +720,647 @@ async function jsonc(options) {
782
720
  ];
783
721
  }
784
722
  //#endregion
785
- //#region src/configs/jsdoc.ts
786
- const jsdocDefaults = { files: [
787
- jsGlob,
788
- tsGlob,
789
- vueGlob
790
- ] };
723
+ //#region src/configs/markdown.ts
724
+ const markdownDefaults = {
725
+ files: [mdGlob],
726
+ gfm: true
727
+ };
791
728
  /**
792
- * Constructs the flat config items for JSDoc linting, ensuring comments follow
793
- * proper styling, parameter checks, and types alignment.
794
- * @param options JSDoc configuration options.
795
- * @returns Promise resolving to JSDoc ESLint config items.
729
+ * Constructs the flat config items for Markdown linting, extracting and linting
730
+ * embedded code blocks within the document according to specified rules.
731
+ * @param options Markdown configuration options.
732
+ * @returns Promise resolving to Markdown ESLint config items.
796
733
  */
797
- async function jsdoc(options) {
798
- const resolved = defu(options, jsdocDefaults);
799
- const jsdocPlugin = await importModule(import("eslint-plugin-jsdoc"));
800
- const baseRules = {
801
- ...jsdocPlugin.configs["flat/recommended-typescript-error"]?.rules,
802
- ...jsdocPlugin.configs["flat/stylistic-typescript-error"]?.rules
803
- };
804
- return [{
805
- name: "favorodera/jsdoc/setup",
806
- plugins: { jsdoc: jsdocPlugin }
807
- }, {
808
- name: "favorodera/tailwind/rules",
809
- files: resolved.files,
810
- rules: {
811
- ...baseRules || {},
812
- "jsdoc/check-access": "warn",
813
- "jsdoc/check-param-names": "warn",
814
- "jsdoc/check-property-names": "warn",
815
- "jsdoc/check-types": "warn",
816
- "jsdoc/empty-tags": "warn",
817
- "jsdoc/implements-on-classes": "warn",
818
- "jsdoc/no-defaults": "warn",
819
- "jsdoc/no-multi-asterisks": "warn",
820
- "jsdoc/require-param-name": "warn",
821
- "jsdoc/require-property": "warn",
822
- "jsdoc/require-property-description": "warn",
823
- "jsdoc/require-property-name": "warn",
824
- "jsdoc/require-returns-check": "warn",
825
- "jsdoc/require-returns-description": "warn",
826
- "jsdoc/require-yields-check": "warn",
827
- "jsdoc/check-alignment": "warn",
828
- "jsdoc/multiline-blocks": "warn",
829
- ...resolved.overrides
734
+ async function markdown(options) {
735
+ const resolved = defu(options, markdownDefaults);
736
+ const markdownPlugin = await importModule(import("@eslint/markdown"));
737
+ const baseRules = extractRules(markdownPlugin.configs.recommended);
738
+ return [
739
+ {
740
+ name: "favorodera/markdown/setup",
741
+ plugins: { md: markdownPlugin }
742
+ },
743
+ {
744
+ files: resolved.files,
745
+ ignores: [mdInMdGlob],
746
+ language: resolved.gfm ? "md/gfm" : "md/commonmark",
747
+ name: "favorodera/markdown/rules",
748
+ processor: mergeProcessors([markdownPlugin.processors?.markdown, processorPassThrough]),
749
+ rules: {
750
+ ...renamePluginsInRules(baseRules, { markdown: "md" }),
751
+ "md/fenced-code-language": "off",
752
+ "md/no-missing-label-refs": "off",
753
+ ...resolved.overrides
754
+ }
755
+ },
756
+ {
757
+ files: [codeInMdGlob],
758
+ languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
759
+ name: "favorodera/markdown/code-in-md/disables",
760
+ rules: {
761
+ "no-alert": "off",
762
+ "no-console": "off",
763
+ "no-labels": "off",
764
+ "no-lone-blocks": "off",
765
+ "no-restricted-syntax": "off",
766
+ "no-undef": "off",
767
+ "no-unused-expressions": "off",
768
+ "no-unused-labels": "off",
769
+ "no-unused-vars": "off",
770
+ "node/prefer-global/process": "off",
771
+ "style/comma-dangle": "off",
772
+ "style/eol-last": "off",
773
+ "style/padding-line-between-statements": "off",
774
+ "ts/consistent-type-imports": "off",
775
+ "ts/explicit-function-return-type": "off",
776
+ "ts/no-namespace": "off",
777
+ "ts/no-redeclare": "off",
778
+ "ts/no-require-imports": "off",
779
+ "ts/no-unused-expressions": "off",
780
+ "ts/no-unused-vars": "off",
781
+ "ts/no-use-before-define": "off",
782
+ "unicode-bom": "off",
783
+ "unused-imports/no-unused-imports": "off",
784
+ "unused-imports/no-unused-vars": "off"
785
+ }
786
+ }
787
+ ];
788
+ }
789
+ //#endregion
790
+ //#region src/configs/node.ts
791
+ const nodeDefaults = { files: [
792
+ jsGlob,
793
+ tsGlob,
794
+ vueGlob
795
+ ] };
796
+ /**
797
+ * Constructs the flat config items for Node.js linting, providing rules
798
+ * to enforce best practices for Node.js environments.
799
+ * @param options Node configuration options.
800
+ * @returns Promise resolving to Node ESLint config items.
801
+ */
802
+ async function node(options) {
803
+ const resolved = defu(options, nodeDefaults);
804
+ const nodePlugin = await importModule(import("eslint-plugin-n"));
805
+ const baseRules = nodePlugin.configs?.["flat/recommended"]?.rules || {};
806
+ return [{
807
+ name: "favorodera/node/setup",
808
+ plugins: { node: nodePlugin }
809
+ }, {
810
+ files: resolved.files,
811
+ name: "favorodera/node/rules",
812
+ rules: {
813
+ ...renamePluginsInRules(baseRules, { n: "node" }),
814
+ "node/handle-callback-err": ["error", "^(err|error)$"],
815
+ "node/no-deprecated-api": "error",
816
+ "node/no-exports-assign": "error",
817
+ "node/no-missing-import": "off",
818
+ "node/no-new-require": "error",
819
+ "node/no-path-concat": "error",
820
+ "node/no-unpublished-import": "off",
821
+ "node/prefer-global/buffer": ["error", "never"],
822
+ "node/prefer-global/process": ["error", "never"],
823
+ "node/process-exit-as-throw": "error",
824
+ ...resolved.overrides
825
+ }
826
+ }];
827
+ }
828
+ //#endregion
829
+ //#region src/configs/perfectionist.ts
830
+ const perfectionistDefaults = { files: [
831
+ jsGlob,
832
+ tsGlob,
833
+ vueGlob
834
+ ] };
835
+ /**
836
+ * Constructs the flat config items for Perfectionist linting, providing rules
837
+ * to naturally sort objects, imports, classes, and other elements in your code.
838
+ * @param options Perfectionist configuration options.
839
+ * @returns Promise resolving to Perfectionist ESLint config items.
840
+ */
841
+ async function perfectionist(options) {
842
+ const resolved = defu(options, perfectionistDefaults);
843
+ const perfectionistPlugin = await importModule(import("eslint-plugin-perfectionist"));
844
+ const baseRules = perfectionistPlugin.configs["recommended-natural"]?.rules || {};
845
+ return [{
846
+ name: "favorodera/perfectionist/setup",
847
+ plugins: { perfectionist: perfectionistPlugin }
848
+ }, {
849
+ files: resolved.files,
850
+ name: "favorodera/perfectionist/rules",
851
+ rules: {
852
+ ...baseRules,
853
+ "perfectionist/sort-exports": ["error", {
854
+ order: "asc",
855
+ type: "natural"
856
+ }],
857
+ "perfectionist/sort-imports": ["error", {
858
+ groups: [
859
+ "type-import",
860
+ [
861
+ "type-parent",
862
+ "type-sibling",
863
+ "type-index",
864
+ "type-internal"
865
+ ],
866
+ "value-builtin",
867
+ "value-external",
868
+ "value-internal",
869
+ [
870
+ "value-parent",
871
+ "value-sibling",
872
+ "value-index"
873
+ ],
874
+ "side-effect",
875
+ "ts-equals-import",
876
+ "unknown"
877
+ ],
878
+ newlinesBetween: "ignore",
879
+ newlinesInside: "ignore",
880
+ order: "asc",
881
+ type: "natural"
882
+ }],
883
+ "perfectionist/sort-named-exports": ["error", {
884
+ order: "asc",
885
+ type: "natural"
886
+ }],
887
+ "perfectionist/sort-named-imports": ["error", {
888
+ order: "asc",
889
+ type: "natural"
890
+ }],
891
+ ...resolved.overrides
892
+ }
893
+ }];
894
+ }
895
+ //#endregion
896
+ //#region src/configs/pnpm.ts
897
+ /**
898
+ * Constructs the flat config items for pnpm linting.
899
+ * @returns Promise resolving to pnpm ESLint config items.
900
+ */
901
+ async function pnpm() {
902
+ const [pnpmPlugin, yamlParser] = await Promise.all([importModule(import("eslint-plugin-pnpm")), importModule(import("yaml-eslint-parser"))]);
903
+ return [
904
+ {
905
+ name: "favorodera/pnpm/setup",
906
+ plugins: { pnpm: pnpmPlugin }
907
+ },
908
+ {
909
+ files: [packageJsonGlob],
910
+ language: "jsonc/x",
911
+ name: "favorodera/pnpm/package-json",
912
+ rules: {
913
+ "pnpm/json-enforce-catalog": ["error", {
914
+ autofix: true,
915
+ ignores: ["@types/vscode"]
916
+ }],
917
+ "pnpm/json-prefer-workspace-settings": ["error", { autofix: true }],
918
+ "pnpm/json-valid-catalog": ["error", { autofix: true }]
919
+ }
920
+ },
921
+ {
922
+ files: [pnpmWorkspaceGlob],
923
+ languageOptions: { parser: yamlParser },
924
+ name: "favorodera/pnpm/pnpm-workspace-yaml",
925
+ rules: {
926
+ "pnpm/yaml-enforce-settings": ["error", { settings: {
927
+ shellEmulator: true,
928
+ trustPolicy: "no-downgrade"
929
+ } }],
930
+ "pnpm/yaml-no-duplicate-catalog-item": ["error", { checkDuplicates: "exact-version" }],
931
+ "pnpm/yaml-no-unused-catalog-item": "error"
932
+ }
933
+ }
934
+ ];
935
+ }
936
+ //#endregion
937
+ //#region src/configs/stylistic.ts
938
+ const stylisticDefaults = {
939
+ files: [
940
+ jsGlob,
941
+ tsGlob,
942
+ vueGlob
943
+ ],
944
+ settings: {
945
+ experimental: false,
946
+ indent: 2,
947
+ jsx: false,
948
+ quotes: "single",
949
+ semi: false
950
+ }
951
+ };
952
+ /**
953
+ * Constructs the flat config items for Stylistic linting, applying customized
954
+ * formatting settings such as quotes, indentation, and spacing.
955
+ * @param options Stylistic configuration options.
956
+ * @returns Promise resolving to stylistic ESLint config items.
957
+ */
958
+ async function stylistic(options) {
959
+ const resolved = defu(options, stylisticDefaults);
960
+ const stylePlugin = await importModule(import("@stylistic/eslint-plugin"));
961
+ const baseRules = stylePlugin.configs.customize({
962
+ pluginName: "style",
963
+ ...resolved.settings
964
+ })?.rules || {};
965
+ return [{
966
+ name: "favorodera/stylistic/setup",
967
+ plugins: { style: stylePlugin }
968
+ }, {
969
+ files: resolved.files,
970
+ name: "favorodera/stylistic/rules",
971
+ rules: {
972
+ ...baseRules,
973
+ "style/brace-style": "off",
974
+ "style/generator-star-spacing": ["error", {
975
+ after: true,
976
+ before: false
977
+ }],
978
+ "style/no-multiple-empty-lines": ["error", {
979
+ max: 2,
980
+ maxBOF: 0,
981
+ maxEOF: 2
982
+ }],
983
+ "style/no-trailing-spaces": ["error", { skipBlankLines: true }],
984
+ "style/padded-blocks": "off",
985
+ "style/quotes": [
986
+ "error",
987
+ "single",
988
+ { avoidEscape: true }
989
+ ],
990
+ "style/yield-star-spacing": ["error", {
991
+ after: true,
992
+ before: false
993
+ }],
994
+ ...resolved.overrides
830
995
  }
831
996
  }];
832
997
  }
833
998
  //#endregion
999
+ //#region src/configs/tailwind.ts
1000
+ const tailwindDefaults = {
1001
+ files: [
1002
+ jsGlob,
1003
+ tsGlob,
1004
+ vueGlob
1005
+ ],
1006
+ settings: { detectComponentClasses: true }
1007
+ };
1008
+ /**
1009
+ * Constructs the flat config items for Tailwind CSS linting, providing custom settings
1010
+ * to parse and lint utility classes, and enforcing consistent ordering.
1011
+ * @param options Tailwind configuration options.
1012
+ * @returns Promise resolving to Tailwind ESLint config items.
1013
+ */
1014
+ async function tailwind(options) {
1015
+ const resolved = defu(options, tailwindDefaults);
1016
+ const tailwindPlugin = await importModule(import("eslint-plugin-better-tailwindcss"));
1017
+ const baseRules = {
1018
+ ...tailwindPlugin.configs["recommended-error"].rules,
1019
+ ...tailwindPlugin.configs["stylistic-error"].rules
1020
+ };
1021
+ return [{
1022
+ name: "favorodera/tailwind/setup",
1023
+ plugins: { tailwind: tailwindPlugin },
1024
+ settings: { tailwindcss: resolved.settings }
1025
+ }, {
1026
+ files: resolved.files,
1027
+ name: "favorodera/tailwind/rules",
1028
+ rules: {
1029
+ ...renamePluginsInRules(baseRules, { "better-tailwindcss": "tailwind" }),
1030
+ "tailwind/enforce-consistent-line-wrapping": ["error", { group: "emptyLine" }],
1031
+ ...resolved.overrides
1032
+ }
1033
+ }];
1034
+ }
1035
+ //#endregion
1036
+ //#region src/configs/test.ts
1037
+ const testDefaults = { files: testsGlob };
1038
+ /**
1039
+ * Constructs the flat config items for test linting, extending
1040
+ * the recommended Vitest rule sets.
1041
+ * @param options Test configuration options.
1042
+ * @returns Promise resolving to test ESLint config items.
1043
+ */
1044
+ async function test(options) {
1045
+ const resolved = defu(options, testDefaults);
1046
+ const testPlugin = await importModule(import("@vitest/eslint-plugin"));
1047
+ const baseRules = extractRules(testPlugin.configs.recommended);
1048
+ return [
1049
+ {
1050
+ name: "favorodera/test/setup",
1051
+ plugins: { test: testPlugin }
1052
+ },
1053
+ {
1054
+ files: resolved.files,
1055
+ name: "favorodera/test/rules",
1056
+ rules: {
1057
+ ...renamePluginsInRules(baseRules, { vitest: "test" }),
1058
+ "test/consistent-test-it": ["error", {
1059
+ fn: "it",
1060
+ withinDescribe: "it"
1061
+ }],
1062
+ "test/no-identical-title": "error",
1063
+ "test/no-import-node-test": "error",
1064
+ "test/prefer-hooks-in-order": "error",
1065
+ "test/prefer-lowercase-title": "error",
1066
+ ...resolved.overrides
1067
+ }
1068
+ },
1069
+ {
1070
+ files: resolved.files,
1071
+ name: "favorodera/test/disables",
1072
+ rules: {
1073
+ "no-unused-expressions": "off",
1074
+ "node/prefer-global/process": "off"
1075
+ }
1076
+ }
1077
+ ];
1078
+ }
1079
+ //#endregion
1080
+ //#region src/configs/typescript.ts
1081
+ const typescriptDefaults = { files: [tsGlob] };
1082
+ /**
1083
+ * Constructs the flat config items for TypeScript linting, initializing the parser
1084
+ * and extending the recommended and strict type-aware rule sets.
1085
+ * @param options TypeScript configuration options.
1086
+ * @returns Promise resolving to TypeScript ESLint config items.
1087
+ */
1088
+ async function typescript(options) {
1089
+ const resolved = defu(options, typescriptDefaults);
1090
+ const tsEsLint = await importModule(import("typescript-eslint"));
1091
+ const baseRules = extractRules(tsEsLint.configs.recommended, tsEsLint.configs.strict);
1092
+ return [{
1093
+ name: "favorodera/typescript/setup",
1094
+ plugins: { ts: tsEsLint.plugin }
1095
+ }, {
1096
+ files: resolved.files,
1097
+ languageOptions: {
1098
+ parser: tsEsLint.parser,
1099
+ parserOptions: { sourceType: "module" }
1100
+ },
1101
+ name: "favorodera/typescript/rules",
1102
+ rules: {
1103
+ ...renamePluginsInRules(baseRules, { "@typescript-eslint": "ts" }),
1104
+ "ts/array-type": ["error", {
1105
+ default: "generic",
1106
+ readonly: "generic"
1107
+ }],
1108
+ "ts/consistent-type-imports": ["error", { prefer: "type-imports" }],
1109
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }],
1110
+ ...resolved.overrides
1111
+ }
1112
+ }];
1113
+ }
1114
+ //#endregion
1115
+ //#region src/configs/unicorn.ts
1116
+ const unicornDefaults = { files: [
1117
+ jsGlob,
1118
+ tsGlob,
1119
+ vueGlob
1120
+ ] };
1121
+ /**
1122
+ * Constructs the flat config items for Unicorn linting, providing a collection of
1123
+ * awesome ESLint rules to improve code quality and enforce best practices.
1124
+ * @param options Unicorn configuration options.
1125
+ * @returns Promise resolving to Unicorn ESLint config items.
1126
+ */
1127
+ async function unicorn(options) {
1128
+ const resolved = defu(options, unicornDefaults);
1129
+ const unicornPlugin = await importModule(import("eslint-plugin-unicorn"));
1130
+ const baseRules = unicornPlugin.configs.unopinionated?.rules || {};
1131
+ return [{
1132
+ name: "favorodera/unicorn/setup",
1133
+ plugins: { unicorn: unicornPlugin }
1134
+ }, {
1135
+ files: resolved.files,
1136
+ languageOptions: { globals: globals.builtin },
1137
+ name: "favorodera/unicorn/rules",
1138
+ rules: {
1139
+ ...baseRules,
1140
+ "unicorn/consistent-empty-array-spread": "error",
1141
+ "unicorn/error-message": "error",
1142
+ "unicorn/escape-case": "error",
1143
+ "unicorn/new-for-builtins": "error",
1144
+ "unicorn/no-instanceof-builtins": "error",
1145
+ "unicorn/no-new-array": "error",
1146
+ "unicorn/no-new-buffer": "error",
1147
+ "unicorn/number-literal-case": "error",
1148
+ "unicorn/prefer-dom-node-text-content": "error",
1149
+ "unicorn/prefer-includes": "error",
1150
+ "unicorn/prefer-node-protocol": "error",
1151
+ "unicorn/prefer-number-properties": "error",
1152
+ "unicorn/prefer-string-starts-ends-with": "error",
1153
+ "unicorn/prefer-type-error": "error",
1154
+ "unicorn/throw-new-error": "error",
1155
+ ...resolved.overrides
1156
+ }
1157
+ }];
1158
+ }
1159
+ //#endregion
1160
+ //#region src/configs/vue.ts
1161
+ const sfcBlocksDefaults = { blocks: {
1162
+ customBlocks: true,
1163
+ styles: true,
1164
+ template: false
1165
+ } };
1166
+ const vueDefaults = {
1167
+ files: [vueGlob],
1168
+ sfcBlocks: sfcBlocksDefaults
1169
+ };
1170
+ /**
1171
+ * Constructs the flat config items for Vue linting, setting up the custom template parser,
1172
+ * Vue block processors, and rules to enforce recommended component syntax.
1173
+ * @param options Vue configuration options.
1174
+ * @returns Promise resolving to Vue ESLint config items.
1175
+ */
1176
+ async function vue(options) {
1177
+ const resolved = defu(options, vueDefaults);
1178
+ const sfcBlocks = resolveOptions(resolved.sfcBlocks, sfcBlocksDefaults);
1179
+ const [vuePlugin, vueParser, tsEsLint] = await Promise.all([
1180
+ importModule(import("eslint-plugin-vue")),
1181
+ importModule(import("vue-eslint-parser")),
1182
+ importModule(import("typescript-eslint"))
1183
+ ]);
1184
+ const baseRules = extractRules(vuePlugin.configs["flat/essential"], vuePlugin.configs["flat/strongly-recommended"], vuePlugin.configs["flat/recommended"]);
1185
+ const processor = sfcBlocks === false ? vuePlugin.processors[".vue"] : mergeProcessors([vuePlugin.processors[".vue"], vueBlocksProcessor(sfcBlocks)]);
1186
+ return [{
1187
+ languageOptions: { globals: {
1188
+ computed: "readonly",
1189
+ defineEmits: "readonly",
1190
+ defineExpose: "readonly",
1191
+ defineProps: "readonly",
1192
+ onMounted: "readonly",
1193
+ onUnmounted: "readonly",
1194
+ reactive: "readonly",
1195
+ ref: "readonly",
1196
+ shallowReactive: "readonly",
1197
+ shallowRef: "readonly",
1198
+ toRef: "readonly",
1199
+ toRefs: "readonly",
1200
+ watch: "readonly",
1201
+ watchEffect: "readonly"
1202
+ } },
1203
+ name: "favorodera/vue/setup",
1204
+ plugins: { vue: vuePlugin }
1205
+ }, {
1206
+ files: resolved.files,
1207
+ languageOptions: {
1208
+ parser: vueParser,
1209
+ parserOptions: {
1210
+ extraFileExtensions: [".vue"],
1211
+ parser: tsEsLint.parser,
1212
+ sourceType: "module"
1213
+ }
1214
+ },
1215
+ name: "favorodera/vue/rules",
1216
+ processor,
1217
+ rules: {
1218
+ ...baseRules,
1219
+ "vue/block-order": ["error", { order: [
1220
+ "script",
1221
+ "template",
1222
+ "style"
1223
+ ] }],
1224
+ "vue/block-tag-newline": ["error", {
1225
+ multiline: "ignore",
1226
+ singleline: "ignore"
1227
+ }],
1228
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1229
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1230
+ "vue/multi-word-component-names": "off",
1231
+ "vue/multiline-html-element-content-newline": ["error", {
1232
+ allowEmptyLines: true,
1233
+ ignores: ["pre", "textarea"]
1234
+ }],
1235
+ ...resolved.overrides
1236
+ }
1237
+ }];
1238
+ }
1239
+ //#endregion
1240
+ //#region src/configs/yaml.ts
1241
+ const yamlDefaults = { files: [yamlGlob] };
1242
+ /**
1243
+ * Constructs the flat config items for YAML linting, setting up
1244
+ * the custom parser and rule validations.
1245
+ * @param options YAML configuration options.
1246
+ * @returns Promise resolving to YAML ESLint config items.
1247
+ */
1248
+ async function yaml(options) {
1249
+ const resolved = defu(options, yamlDefaults);
1250
+ const [yamlPlugin, yamlParser] = await Promise.all([importModule(import("eslint-plugin-yml")), importModule(import("yaml-eslint-parser"))]);
1251
+ const baseRules = extractRules(yamlPlugin.configs.recommended);
1252
+ return [
1253
+ {
1254
+ name: "favorodera/yaml/setup",
1255
+ plugins: { yaml: yamlPlugin }
1256
+ },
1257
+ {
1258
+ files: resolved.files,
1259
+ languageOptions: { parser: yamlParser },
1260
+ name: "favorodera/yaml/rules",
1261
+ rules: {
1262
+ ...renamePluginsInRules(baseRules, { yml: "yaml" }),
1263
+ "style/spaced-comment": "off",
1264
+ "yaml/block-mapping": "error",
1265
+ "yaml/block-mapping-question-indicator-newline": "error",
1266
+ "yaml/block-sequence": "error",
1267
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1268
+ "yaml/flow-mapping-curly-newline": "error",
1269
+ "yaml/flow-mapping-curly-spacing": "error",
1270
+ "yaml/flow-sequence-bracket-newline": "error",
1271
+ "yaml/flow-sequence-bracket-spacing": "error",
1272
+ "yaml/indent": ["error", 2],
1273
+ "yaml/key-spacing": "error",
1274
+ "yaml/no-empty-key": "error",
1275
+ "yaml/no-empty-sequence-entry": "error",
1276
+ "yaml/no-irregular-whitespace": "error",
1277
+ "yaml/no-tab-indent": "error",
1278
+ "yaml/plain-scalar": "error",
1279
+ "yaml/quotes": ["error", {
1280
+ avoidEscape: true,
1281
+ prefer: "single"
1282
+ }],
1283
+ "yaml/spaced-comment": "error",
1284
+ "yaml/vue-custom-block/no-parsing-error": "error",
1285
+ ...resolved.overrides
1286
+ }
1287
+ },
1288
+ {
1289
+ files: [pnpmWorkspaceGlob],
1290
+ languageOptions: { parser: yamlParser },
1291
+ name: "favorodera/yaml/sort/pnpm-workspace-yaml",
1292
+ rules: { "yaml/sort-keys": [
1293
+ "error",
1294
+ {
1295
+ order: [
1296
+ "cacheDir",
1297
+ "catalogMode",
1298
+ "cleanupUnusedCatalogs",
1299
+ "dedupeDirectDeps",
1300
+ "deployAllFiles",
1301
+ "enablePrePostScripts",
1302
+ "engineStrict",
1303
+ "extendNodePath",
1304
+ "hoist",
1305
+ "hoistPattern",
1306
+ "hoistWorkspacePackages",
1307
+ "ignoreCompatibilityDb",
1308
+ "ignoreDepScripts",
1309
+ "ignoreScripts",
1310
+ "ignoreWorkspaceRootCheck",
1311
+ "managePackageManagerVersions",
1312
+ "minimumReleaseAge",
1313
+ "minimumReleaseAgeExclude",
1314
+ "modulesDir",
1315
+ "nodeLinker",
1316
+ "nodeVersion",
1317
+ "optimisticRepeatInstall",
1318
+ "packageManagerStrict",
1319
+ "packageManagerStrictVersion",
1320
+ "preferSymlinkedExecutables",
1321
+ "preferWorkspacePackages",
1322
+ "publicHoistPattern",
1323
+ "registrySupportsTimeField",
1324
+ "requiredScripts",
1325
+ "resolutionMode",
1326
+ "savePrefix",
1327
+ "scriptShell",
1328
+ "shamefullyHoist",
1329
+ "shellEmulator",
1330
+ "stateDir",
1331
+ "supportedArchitectures",
1332
+ "symlink",
1333
+ "tag",
1334
+ "trustPolicy",
1335
+ "trustPolicyExclude",
1336
+ "updateNotifier",
1337
+ "packages",
1338
+ "overrides",
1339
+ "patchedDependencies",
1340
+ "catalog",
1341
+ "catalogs",
1342
+ "allowedDeprecatedVersions",
1343
+ "allowNonAppliedPatches",
1344
+ "configDependencies",
1345
+ "ignoredBuiltDependencies",
1346
+ "ignoredOptionalDependencies",
1347
+ "neverBuiltDependencies",
1348
+ "onlyBuiltDependencies",
1349
+ "onlyBuiltDependenciesFile",
1350
+ "packageExtensions",
1351
+ "peerDependencyRules"
1352
+ ],
1353
+ pathPattern: "^$"
1354
+ },
1355
+ {
1356
+ order: { type: "asc" },
1357
+ pathPattern: ".*"
1358
+ }
1359
+ ] }
1360
+ }
1361
+ ];
1362
+ }
1363
+ //#endregion
834
1364
  //#region src/factory.ts
835
1365
  /**
836
1366
  * Factory to create a flat ESLint config.
@@ -839,18 +1369,23 @@ async function jsdoc(options) {
839
1369
  * @returns A flat config composer instance that can be exported directly or further modified.
840
1370
  */
841
1371
  function factory(options = {}) {
842
- const configs = [];
843
- configs.push(ignores(options.ignores));
1372
+ const configs = [ignores(options.ignores)];
844
1373
  const configFunctions = {
845
- vue,
846
- typescript,
847
- stylistic,
848
- tailwind,
849
1374
  imports,
850
- markdown,
851
1375
  javascript,
1376
+ jsdoc,
852
1377
  jsonc,
853
- jsdoc
1378
+ markdown,
1379
+ node,
1380
+ perfectionist,
1381
+ pnpm,
1382
+ stylistic,
1383
+ tailwind,
1384
+ test,
1385
+ typescript,
1386
+ unicorn,
1387
+ vue,
1388
+ yaml
854
1389
  };
855
1390
  for (const [key, configFunction] of Object.entries(configFunctions)) {
856
1391
  const configOption = options[key];
@@ -859,12 +1394,15 @@ function factory(options = {}) {
859
1394
  }
860
1395
  let composer = new FlatConfigComposer();
861
1396
  composer = composer.append(...configs).renamePlugins({
862
- "better-tailwindcss": "tailwind",
863
1397
  "@typescript-eslint": "ts",
1398
+ "better-tailwindcss": "tailwind",
1399
+ "import-lite": "import",
864
1400
  "markdown": "md",
865
- "import-lite": "import"
1401
+ "n": "node",
1402
+ "vitest": "test",
1403
+ "yml": "yaml"
866
1404
  });
867
1405
  return composer;
868
1406
  }
869
1407
  //#endregion
870
- export { factory, importModule };
1408
+ export { extractRules, factory, importModule };