@nelsonlaidev/eslint-config 4.1.0 → 5.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/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import { isPackageExists } from "local-pkg";
2
1
  import commentsPlugin from "@eslint-community/eslint-plugin-eslint-comments";
3
2
  import reactPlugin from "@eslint-react/eslint-plugin";
4
3
  import nelsonlaidevPlugin from "@nelsonlaidev/eslint-plugin";
@@ -26,42 +25,41 @@ import gitignoreConfig from "eslint-config-flat-gitignore";
26
25
  import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
27
26
  import eslint from "@eslint/js";
28
27
  import globals from "globals";
29
- import { rules } from "eslint-config-prettier";
30
- import { getDefaultSelectors } from "eslint-plugin-better-tailwindcss/defaults";
31
- import { MatcherType, SelectorKind } from "eslint-plugin-better-tailwindcss/types";
32
28
  import * as parserBase from "@typescript-eslint/parser";
29
+ import { merge } from "ts-deepmerge";
30
+ import { rules } from "eslint-config-prettier";
33
31
  //#region src/configs/command.ts
34
- const command = () => [{
32
+ const command = () => ({
35
33
  ...commandPlugin(),
36
- name: "nelsonlaidev/command/rules"
37
- }];
34
+ name: "nelsonlaidev/command"
35
+ });
38
36
  //#endregion
39
37
  //#region src/configs/comments.ts
40
- const comments = () => [{
41
- name: "nelsonlaidev/eslint-comments/rules",
38
+ const comments = () => ({
39
+ name: "nelsonlaidev/eslint-comments",
42
40
  plugins: { "@eslint-community/eslint-comments": commentsPlugin },
43
41
  rules: { ...commentsPlugin.configs.recommended.rules }
44
- }];
42
+ });
45
43
  //#endregion
46
44
  //#region src/configs/de-morgan.ts
47
- const deMorgan = () => [{
48
- name: "nelsonlaidev/de-morgan/rules",
45
+ const deMorgan = () => ({
46
+ name: "nelsonlaidev/de-morgan",
49
47
  plugins: { "de-morgan": deMorganPlugin },
50
48
  rules: { ...deMorganPlugin.configs.recommended.rules }
51
- }];
49
+ });
52
50
  //#endregion
53
51
  //#region src/configs/gitignore.ts
54
- const gitignore = () => [gitignoreConfig({ name: "nelsonlaidev/gitignore" })];
52
+ const gitignore = () => gitignoreConfig({ name: "nelsonlaidev/gitignore" });
55
53
  //#endregion
56
54
  //#region src/configs/ignores.ts
57
- const ignores = (userIgnores = []) => [{
55
+ const ignores = (userIgnores = []) => ({
58
56
  name: "nelsonlaidev/ignores",
59
57
  ignores: ["**/routeTree.gen.ts", ...userIgnores]
60
- }];
58
+ });
61
59
  //#endregion
62
60
  //#region src/configs/import-sort.ts
63
- const importSort = () => [{
64
- name: "nelsonlaidev/import-sort/rules",
61
+ const importSort = () => ({
62
+ name: "nelsonlaidev/import-sort",
65
63
  plugins: { "import-sort": importSortPlugin },
66
64
  rules: {
67
65
  "import-sort/imports": ["error", { groups: [
@@ -84,57 +82,57 @@ const importSort = () => [{
84
82
  ] }],
85
83
  "import-sort/exports": "error"
86
84
  }
87
- }];
85
+ });
88
86
  //#endregion
89
87
  //#region src/configs/import-x.ts
90
- const importX = (options = {}) => [{
91
- name: "nelsonlaidev/import-x/setup",
92
- plugins: { "import-x": importXPlugin },
93
- settings: {
94
- ...importXPlugin.configs.typescript.settings,
95
- "import-x/resolver-next": [createTypeScriptImportResolver({
96
- alwaysTryTypes: true,
97
- project: [
98
- "./tsconfig.json",
99
- "apps/**/{ts,js}config.json",
100
- "packages/**/{ts,js}config.json"
101
- ],
102
- noWarnOnMultipleProjects: true,
103
- ...options
104
- })]
105
- }
106
- }, {
107
- name: "nelsonlaidev/import-x/rules",
108
- rules: {
109
- ...importXPlugin.configs.recommended.rules,
110
- ...importXPlugin.configs.typescript.rules,
111
- "import-x/consistent-type-specifier-style": "error",
112
- "import-x/first": "error",
113
- "import-x/newline-after-import": ["error", { count: 1 }],
114
- "import-x/no-amd": "error",
115
- "import-x/no-anonymous-default-export": "error",
116
- "import-x/no-commonjs": "error",
117
- "import-x/no-mutable-exports": "error",
118
- "import-x/no-named-default": "error",
119
- "import-x/no-relative-packages": "error",
120
- "import-x/no-self-import": "error",
121
- "import-x/no-extraneous-dependencies": "error",
122
- "import-x/no-absolute-path": "error",
123
- "import-x/no-webpack-loader-syntax": "error",
124
- "import-x/no-dynamic-require": "error",
125
- "import-x/no-useless-path-segments": "error",
126
- "import-x/no-import-module-exports": "error",
127
- "import-x/no-empty-named-blocks": "error",
128
- "import-x/no-deprecated": "error",
129
- "import-x/no-duplicates": "error",
130
- "import-x/no-named-as-default": "off",
131
- "import-x/no-named-as-default-member": "off"
132
- }
133
- }];
88
+ const importX = (options = {}) => {
89
+ return {
90
+ name: "nelsonlaidev/import-x",
91
+ plugins: { "import-x": importXPlugin },
92
+ settings: {
93
+ ...importXPlugin.configs.typescript.settings,
94
+ "import-x/resolver-next": [createTypeScriptImportResolver({
95
+ alwaysTryTypes: true,
96
+ project: [
97
+ "{ts,js}config.json",
98
+ "apps/**/{ts,js}config.json",
99
+ "packages/**/{ts,js}config.json"
100
+ ],
101
+ noWarnOnMultipleProjects: true,
102
+ ...options
103
+ })]
104
+ },
105
+ rules: {
106
+ ...importXPlugin.configs.recommended.rules,
107
+ ...importXPlugin.configs.typescript.rules,
108
+ "import-x/consistent-type-specifier-style": "error",
109
+ "import-x/first": "error",
110
+ "import-x/newline-after-import": ["error", { count: 1 }],
111
+ "import-x/no-amd": "error",
112
+ "import-x/no-anonymous-default-export": "error",
113
+ "import-x/no-commonjs": "error",
114
+ "import-x/no-mutable-exports": "error",
115
+ "import-x/no-named-default": "error",
116
+ "import-x/no-relative-packages": "error",
117
+ "import-x/no-self-import": "error",
118
+ "import-x/no-extraneous-dependencies": "error",
119
+ "import-x/no-absolute-path": "error",
120
+ "import-x/no-webpack-loader-syntax": "error",
121
+ "import-x/no-dynamic-require": "error",
122
+ "import-x/no-useless-path-segments": "error",
123
+ "import-x/no-import-module-exports": "error",
124
+ "import-x/no-empty-named-blocks": "error",
125
+ "import-x/no-deprecated": "error",
126
+ "import-x/no-duplicates": "error",
127
+ "import-x/no-named-as-default": "off",
128
+ "import-x/no-named-as-default-member": "off"
129
+ }
130
+ };
131
+ };
134
132
  //#endregion
135
133
  //#region src/configs/javascript.ts
136
- const javascript = () => [{
137
- name: "nelsonlaidev/javascript/setup",
134
+ const javascript = () => ({
135
+ name: "nelsonlaidev/javascript",
138
136
  languageOptions: {
139
137
  ecmaVersion: 2022,
140
138
  globals: {
@@ -153,9 +151,7 @@ const javascript = () => [{
153
151
  linterOptions: {
154
152
  reportUnusedDisableDirectives: "error",
155
153
  reportUnusedInlineConfigs: "error"
156
- }
157
- }, {
158
- name: "nelsonlaidev/javascript/rules",
154
+ },
159
155
  rules: {
160
156
  ...eslint.configs.recommended.rules,
161
157
  "array-callback-return": "error",
@@ -191,17 +187,17 @@ const javascript = () => [{
191
187
  "preserve-caught-error": "error",
192
188
  "symbol-description": "error"
193
189
  }
194
- }];
190
+ });
195
191
  //#endregion
196
192
  //#region src/configs/jsdoc.ts
197
- const jsdoc = () => [{
198
- name: "nelsonlaidev/jsdoc/rules",
193
+ const jsdoc = () => ({
194
+ name: "nelsonlaidev/jsdoc",
199
195
  plugins: { jsdoc: jsdocPlugin },
200
196
  rules: {
201
197
  "jsdoc/check-tag-names": "error",
202
198
  "jsdoc/empty-tags": "error"
203
199
  }
204
- }];
200
+ });
205
201
  //#endregion
206
202
  //#region src/globs.ts
207
203
  const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
@@ -212,25 +208,18 @@ const GLOB_TS = "**/*.?([cm])ts";
212
208
  const GLOB_TSX = "**/*.?([cm])tsx";
213
209
  //#endregion
214
210
  //#region src/configs/jsx-a11y.ts
215
- const jsxA11y = (options = {}) => [{
216
- name: "nelsonlaidev/jsx-a11y/setup",
211
+ const jsxA11y = () => ({
212
+ name: "nelsonlaidev/jsx-a11y",
217
213
  files: [GLOB_JSX, GLOB_TSX],
218
214
  plugins: { "jsx-a11y": jsxA11yPlugin },
219
215
  languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
220
- settings: { "jsx-a11y": {
221
- ...options.a11y,
222
- components: {
223
- Button: "button",
224
- Image: "img",
225
- Input: "input",
226
- Textarea: "textarea",
227
- Link: "a",
228
- ...options.a11y?.components
229
- }
230
- } }
231
- }, {
232
- name: "nelsonlaidev/jsx-a11y/rules",
233
- files: [GLOB_JSX, GLOB_TSX],
216
+ settings: { "jsx-a11y": { components: {
217
+ Button: "button",
218
+ Image: "img",
219
+ Input: "input",
220
+ Textarea: "textarea",
221
+ Link: "a"
222
+ } } },
234
223
  rules: {
235
224
  ...jsxA11yPlugin.configs.recommended.rules,
236
225
  "jsx-a11y/lang": "error",
@@ -245,11 +234,11 @@ const jsxA11y = (options = {}) => [{
245
234
  ]
246
235
  }]
247
236
  }
248
- }];
237
+ });
249
238
  //#endregion
250
239
  //#region src/configs/nelsonlaidev.ts
251
- const nelsonlaidev = () => [{
252
- name: "nelsonlaidev/nelsonlaidev/rules",
240
+ const nelsonlaidev = () => ({
241
+ name: "nelsonlaidev/nelsonlaidev",
253
242
  plugins: { "@nelsonlaidev": nelsonlaidevPlugin },
254
243
  rules: {
255
244
  "@nelsonlaidev/lucide-icon-suffix": "error",
@@ -258,18 +247,11 @@ const nelsonlaidev = () => [{
258
247
  "@nelsonlaidev/shadcn-cva-variants-suffix": "error",
259
248
  "@nelsonlaidev/shadcn-prefer-spinner": "error"
260
249
  }
261
- }];
262
- //#endregion
263
- //#region src/configs/nextjs.ts
264
- const nextjs = () => [{
265
- name: "nelsonlaidev/nextjs/rules",
266
- plugins: { "@next/next": nextPlugin },
267
- rules: { ...nextPlugin.configs["core-web-vitals"].rules }
268
- }];
250
+ });
269
251
  //#endregion
270
252
  //#region src/configs/node.ts
271
- const node = () => [{
272
- name: "nelsonlaidev/node/rules",
253
+ const node = () => ({
254
+ name: "nelsonlaidev/node",
273
255
  plugins: { n: nodePlugin },
274
256
  rules: {
275
257
  "n/no-deprecated-api": "error",
@@ -279,35 +261,11 @@ const node = () => [{
279
261
  "n/prefer-promises/fs": "error",
280
262
  "n/prefer-promises/dns": "error"
281
263
  }
282
- }];
283
- //#endregion
284
- //#region src/configs/playwright.ts
285
- const playwright = (options) => [{
286
- name: "nelsonlaidev/playwright/setup",
287
- files: options.files,
288
- plugins: { playwright: playwrightPlugin },
289
- languageOptions: { globals: globals["shared-node-browser"] }
290
- }, {
291
- name: "nelsonlaidev/playwright/rules",
292
- files: options.files,
293
- rules: {
294
- ...playwrightPlugin.configs.recommended.rules,
295
- "playwright/expect-expect": ["error", {
296
- assertFunctionNames: options.assertFunctionNames ?? [],
297
- assertFunctionPatterns: options.assertFunctionPatterns ?? []
298
- }]
299
- }
300
- }];
301
- //#endregion
302
- //#region src/configs/prettier.ts
303
- const prettier = () => [{
304
- name: "nelsonlaidev/prettier/rules",
305
- rules
306
- }];
264
+ });
307
265
  //#endregion
308
266
  //#region src/configs/promise.ts
309
- const promise = () => [{
310
- name: "nelsonlaidev/promise/rules",
267
+ const promise = () => ({
268
+ name: "nelsonlaidev/promise",
311
269
  plugins: { promise: promisePlugin },
312
270
  rules: {
313
271
  ...promisePlugin.configs.recommended.rules,
@@ -317,50 +275,18 @@ const promise = () => [{
317
275
  "promise/prefer-catch": "error",
318
276
  "promise/spec-only": "error"
319
277
  }
320
- }];
321
- //#endregion
322
- //#region src/configs/react.ts
323
- const react = () => [
324
- {
325
- name: "nelsonlaidev/react/setup",
326
- files: [GLOB_SRC],
327
- plugins: {
328
- ...reactPlugin.configs.all.plugins,
329
- "react-hooks": reactHooksPlugin
330
- },
331
- settings: { ...reactPlugin.configs.all.settings }
332
- },
333
- {
334
- name: "nelsonlaidev/react/rules",
335
- files: [GLOB_SRC],
336
- rules: {
337
- ...reactHooksPlugin.configs["recommended-latest"].rules,
338
- ...reactPlugin.configs.all.rules,
339
- ...reactPlugin.configs["disable-conflict-eslint-plugin-react-hooks"].rules,
340
- "@eslint-react/immutability": "error",
341
- "@eslint-react/refs": "error"
342
- }
343
- },
344
- {
345
- name: "nelsonlaidev/react/typescript-rules",
346
- files: [GLOB_TS, GLOB_TSX],
347
- rules: {
348
- "@eslint-react/no-leaked-conditional-rendering": "error",
349
- "@eslint-react/no-unused-props": "error"
350
- }
351
- }
352
- ];
278
+ });
353
279
  //#endregion
354
280
  //#region src/configs/regexp.ts
355
- const regexp = () => [{
356
- name: "nelsonlaidev/regexp/rules",
281
+ const regexp = () => ({
282
+ name: "nelsonlaidev/regexp",
357
283
  plugins: { regexp: regexpPlugin },
358
284
  rules: { ...regexpPlugin.configs.recommended.rules }
359
- }];
285
+ });
360
286
  //#endregion
361
287
  //#region src/configs/sonarjs.ts
362
- const sonarjs = () => [{
363
- name: "nelsonlaidev/sonarjs/rules",
288
+ const sonarjs = () => ({
289
+ name: "nelsonlaidev/sonarjs",
364
290
  plugins: { sonarjs: sonarjsPlugin },
365
291
  rules: {
366
292
  ...sonarjsPlugin.configs.recommended.rules,
@@ -372,141 +298,83 @@ const sonarjs = () => [{
372
298
  "sonarjs/prefer-read-only-props": "off",
373
299
  "sonarjs/argument-type": "off",
374
300
  "sonarjs/cognitive-complexity": "off",
301
+ "sonarjs/assertions-in-tests": "off",
375
302
  "sonarjs/jsx-no-leaked-render": "off"
376
303
  }
377
- }];
304
+ });
378
305
  //#endregion
379
306
  //#region src/configs/stylistic.ts
380
- const stylistic = () => [{
381
- name: "nelsonlaidev/stylistic/rules",
307
+ const stylistic = () => ({
308
+ name: "nelsonlaidev/stylistic",
382
309
  plugins: { "@stylistic": stylisticPlugin },
383
310
  rules: { "@stylistic/multiline-comment-style": ["error", "separate-lines"] }
384
- }];
385
- //#endregion
386
- //#region src/configs/tailwindcss.ts
387
- const createSelectors = (names, kind) => names.map((name) => ({
388
- name,
389
- kind,
390
- match: [{ type: MatcherType.String }, { type: MatcherType.ObjectValue }]
391
- }));
392
- const tailwindcss = (options) => {
393
- const disableShorthand = options.canonical?.logical ?? true;
394
- return [{
395
- name: "nelsonlaidev/tailwindcss/setup",
396
- plugins: { "better-tailwindcss": tailwindcssPlugin },
397
- settings: { "better-tailwindcss": {
398
- entryPoint: options.entryPoint,
399
- tailwindConfig: options.tailwindConfig,
400
- tsconfig: options.tsconfig,
401
- detectComponentClasses: options.detectComponentClasses ?? false,
402
- rootFontSize: options.rootFontSize ?? 16,
403
- messageStyle: options.messageStyle,
404
- selectors: [
405
- ...getDefaultSelectors(),
406
- ...createSelectors(["classNames", ".+ClassNames"], SelectorKind.Attribute),
407
- ...createSelectors([".+ClassName", ".+ClassNames"], SelectorKind.Variable),
408
- ...options.selectors ?? []
409
- ]
410
- } }
411
- }, {
412
- name: "nelsonlaidev/tailwindcss/rules",
413
- files: [GLOB_SRC],
414
- rules: {
415
- "better-tailwindcss/enforce-canonical-classes": ["error", {
416
- collapse: options.canonical?.collapse ?? true,
417
- logical: options.canonical?.logical ?? true
418
- }],
419
- "better-tailwindcss/enforce-consistent-important-position": "off",
420
- "better-tailwindcss/enforce-consistent-variable-syntax": "off",
421
- "better-tailwindcss/enforce-shorthand-classes": disableShorthand ? "off" : "error",
422
- "better-tailwindcss/enforce-consistent-class-order": ["error", {
423
- order: options.classOrder?.order ?? "official",
424
- componentClassOrder: options.classOrder?.componentOrder ?? "preserve",
425
- componentClassPosition: options.classOrder?.componentPosition ?? "start",
426
- unknownClassOrder: options.classOrder?.unknownOrder ?? "preserve",
427
- unknownClassPosition: options.classOrder?.unknownPosition ?? "start"
428
- }],
429
- "better-tailwindcss/no-conflicting-classes": "error",
430
- "better-tailwindcss/no-deprecated-classes": "error",
431
- "better-tailwindcss/no-duplicate-classes": "error",
432
- "better-tailwindcss/no-restricted-classes": ["error", { restrict: options.restrict ?? [] }],
433
- "better-tailwindcss/no-unknown-classes": ["error", { ignore: options.ignore ?? [] }],
434
- "better-tailwindcss/no-unnecessary-whitespace": ["error", { allowMultiline: options.whitespace?.allowMultiline ?? true }]
435
- }
436
- }];
437
- };
311
+ });
438
312
  //#endregion
439
313
  //#region src/configs/typescript.ts
440
- const typescript = () => [
441
- {
442
- name: "nelsonlaidev/typescript/setup",
443
- files: [GLOB_TS, GLOB_TSX],
444
- languageOptions: {
445
- parser: {
446
- meta: parserBase.meta,
447
- parseForESLint: parserBase.parseForESLint
448
- },
449
- parserOptions: {
450
- projectService: true,
451
- tsconfigRootDir: process.cwd()
452
- },
453
- sourceType: "module"
314
+ const typescript = () => ({
315
+ name: "nelsonlaidev/typescript",
316
+ files: [GLOB_TS, GLOB_TSX],
317
+ languageOptions: {
318
+ parser: {
319
+ meta: parserBase.meta,
320
+ parseForESLint: parserBase.parseForESLint
454
321
  },
455
- plugins: { "@typescript-eslint": typescriptPlugin }
456
- },
457
- {
458
- name: "nelsonlaidev/typescript/rules",
459
- files: [GLOB_TS, GLOB_TSX],
460
- rules: {
461
- ...typescriptPlugin.configs["eslint-recommended"].overrides[0].rules,
462
- ...typescriptPlugin.configs["strict-type-checked"].rules,
463
- ...typescriptPlugin.configs["stylistic-type-checked"].rules,
464
- "@typescript-eslint/no-restricted-types": "error",
465
- "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
466
- "@typescript-eslint/no-useless-empty-export": "error",
467
- "@typescript-eslint/prefer-enum-initializers": "error",
468
- "@typescript-eslint/promise-function-async": "error",
469
- "@typescript-eslint/require-array-sort-compare": "error",
470
- "@typescript-eslint/switch-exhaustiveness-check": "error",
471
- "@typescript-eslint/class-methods-use-this": "error",
472
- "@typescript-eslint/default-param-last": "error",
473
- "@typescript-eslint/no-loop-func": "error",
474
- "@typescript-eslint/no-invalid-this": "error",
475
- "@typescript-eslint/no-shadow": "error",
476
- "@typescript-eslint/no-import-type-side-effects": "error",
477
- "@typescript-eslint/array-type": ["error", {
478
- default: "array-simple",
479
- readonly: "array-simple"
480
- }],
481
- "@typescript-eslint/consistent-type-definitions": ["error", "type"],
482
- "@typescript-eslint/consistent-type-imports": ["error", {
483
- prefer: "type-imports",
484
- fixStyle: "separate-type-imports"
485
- }],
486
- "@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: false }],
487
- "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
488
- "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
489
- "@typescript-eslint/only-throw-error": ["error", { allow: [{
490
- from: "package",
491
- package: "@tanstack/router-core",
492
- name: "Redirect"
493
- }] }],
494
- "@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }]
495
- }
322
+ parserOptions: {
323
+ projectService: true,
324
+ tsconfigRootDir: process.cwd()
325
+ },
326
+ sourceType: "module"
496
327
  },
497
- {
498
- name: "nelsonlaidev/typescript/declarations",
499
- files: ["**/*.d.ts"],
500
- rules: {
501
- "@typescript-eslint/consistent-type-definitions": "off",
502
- "@typescript-eslint/consistent-indexed-object-style": "off"
503
- }
328
+ plugins: { "@typescript-eslint": typescriptPlugin },
329
+ rules: {
330
+ ...typescriptPlugin.configs["eslint-recommended"].overrides[0].rules,
331
+ ...typescriptPlugin.configs["strict-type-checked"].rules,
332
+ ...typescriptPlugin.configs["stylistic-type-checked"].rules,
333
+ "@typescript-eslint/no-restricted-types": "error",
334
+ "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
335
+ "@typescript-eslint/no-useless-empty-export": "error",
336
+ "@typescript-eslint/prefer-enum-initializers": "error",
337
+ "@typescript-eslint/promise-function-async": "error",
338
+ "@typescript-eslint/require-array-sort-compare": "error",
339
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
340
+ "@typescript-eslint/class-methods-use-this": "error",
341
+ "@typescript-eslint/default-param-last": "error",
342
+ "@typescript-eslint/no-loop-func": "error",
343
+ "@typescript-eslint/no-invalid-this": "error",
344
+ "@typescript-eslint/no-shadow": "error",
345
+ "@typescript-eslint/no-import-type-side-effects": "error",
346
+ "@typescript-eslint/array-type": ["error", {
347
+ default: "array-simple",
348
+ readonly: "array-simple"
349
+ }],
350
+ "@typescript-eslint/consistent-type-definitions": ["error", "type"],
351
+ "@typescript-eslint/consistent-type-imports": ["error", {
352
+ prefer: "type-imports",
353
+ fixStyle: "separate-type-imports"
354
+ }],
355
+ "@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: false }],
356
+ "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
357
+ "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
358
+ "@typescript-eslint/only-throw-error": ["error", { allow: [{
359
+ from: "package",
360
+ package: "@tanstack/router-core",
361
+ name: "Redirect"
362
+ }] }],
363
+ "@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "with-single-extends" }]
364
+ }
365
+ });
366
+ const typescriptDeclarations = () => ({
367
+ name: "nelsonlaidev/typescript/declarations",
368
+ files: ["**/*.d.ts"],
369
+ rules: {
370
+ "@typescript-eslint/consistent-type-definitions": "off",
371
+ "@typescript-eslint/consistent-indexed-object-style": "off"
504
372
  }
505
- ];
373
+ });
506
374
  //#endregion
507
375
  //#region src/configs/unicorn.ts
508
- const unicorn = () => [{
509
- name: "nelsonlaidev/unicorn/rules",
376
+ const unicorn = () => ({
377
+ name: "nelsonlaidev/unicorn",
510
378
  plugins: { unicorn: unicornPlugin },
511
379
  rules: {
512
380
  ...unicornPlugin.configs.recommended.rules,
@@ -514,13 +382,15 @@ const unicorn = () => [{
514
382
  "unicorn/prevent-abbreviations": "off",
515
383
  "unicorn/no-null": "off",
516
384
  "unicorn/no-document-cookie": "off",
517
- "unicorn/prefer-string-raw": "off"
385
+ "unicorn/prefer-string-raw": "off",
386
+ "unicorn/prefer-number-coercion": "off",
387
+ "unicorn/max-nested-calls": "off"
518
388
  }
519
- }];
389
+ });
520
390
  //#endregion
521
391
  //#region src/configs/unused-imports.ts
522
- const unusedImports = () => [{
523
- name: "nelsonlaidev/unused-imports/rules",
392
+ const unusedImports = () => ({
393
+ name: "nelsonlaidev/unused-imports",
524
394
  plugins: { "unused-imports": unusedImportsPlugin },
525
395
  rules: {
526
396
  "no-unused-vars": "off",
@@ -533,92 +403,145 @@ const unusedImports = () => [{
533
403
  argsIgnorePattern: "^_"
534
404
  }]
535
405
  }
536
- }];
537
- //#endregion
538
- //#region src/configs/vitest.ts
539
- const vitest = (options) => [{
540
- name: "nelsonlaidev/vitest/setup",
541
- files: options.files,
542
- plugins: { vitest: vitestPlugin },
543
- settings: { vitest: { typecheck: true } },
544
- languageOptions: { globals: { ...vitestPlugin.environments.env.globals } }
545
- }, {
546
- name: "nelsonlaidev/vitest/rules",
547
- files: options.files,
548
- rules: {
549
- ...vitestPlugin.configs.recommended.rules,
550
- "vitest/consistent-test-it": ["error", { fn: "test" }],
551
- "vitest/prefer-mock-return-shorthand": "error",
552
- "vitest/warn-todo": "error"
553
- }
554
- }];
406
+ });
555
407
  //#endregion
556
408
  //#region src/configs/zod.ts
557
- const zod = () => [{
558
- name: "nelsonlaidev/zod/rules",
409
+ const zod = () => ({
410
+ name: "nelsonlaidev/zod",
559
411
  plugins: { "import-zod": importZodPlugin },
560
412
  rules: { "import-zod/prefer-zod-namespace": "error" }
561
- }];
413
+ });
414
+ //#endregion
415
+ //#region src/base.ts
416
+ const createConfig = (options, userConfigs) => {
417
+ return [...[
418
+ gitignore(),
419
+ ignores(options.ignores),
420
+ javascript(),
421
+ jsdoc(),
422
+ sonarjs(),
423
+ importSort(),
424
+ deMorgan(),
425
+ comments(),
426
+ node(),
427
+ importX(options.typescriptResolver),
428
+ command(),
429
+ unicorn(),
430
+ jsxA11y(),
431
+ typescript(),
432
+ typescriptDeclarations(),
433
+ unusedImports(),
434
+ regexp(),
435
+ stylistic(),
436
+ zod(),
437
+ promise(),
438
+ nelsonlaidev()
439
+ ], ...userConfigs];
440
+ };
441
+ const withOptions = (options, ...userConfigs) => createConfig(options, userConfigs);
442
+ const defineConfig = Object.assign((...userConfigs) => createConfig({}, userConfigs), { withOptions });
562
443
  //#endregion
563
444
  //#region src/utils.ts
564
- function normalizeRuleValue(value) {
565
- if (Array.isArray(value)) {
566
- const [level, ...rest] = value;
567
- return level === "warn" || level === 1 ? ["error", ...rest] : value;
568
- }
569
- return value === "warn" || value === 1 ? "error" : value;
570
- }
571
- function makeAllErrors(configs) {
572
- return configs.map((config) => {
573
- if (!config.rules) return config;
574
- const rules = Object.fromEntries(Object.entries(config.rules).map(([rule, rawValue]) => [rule, normalizeRuleValue(rawValue)]));
575
- return {
576
- ...config,
577
- rules
578
- };
579
- });
445
+ function mergeConfig(base, override) {
446
+ const { plugins: basePlugins, ...baseConfig } = base;
447
+ const { plugins: overridePlugins, ...overrideConfig } = override;
448
+ return {
449
+ ...merge.withOptions({ mergeArrays: false }, baseConfig, overrideConfig),
450
+ plugins: {
451
+ ...basePlugins,
452
+ ...overridePlugins
453
+ }
454
+ };
580
455
  }
581
456
  //#endregion
582
- //#region src/base.ts
583
- const isReactInstalled = isPackageExists("react");
584
- const isNextjsInstalled = isPackageExists("next");
585
- const isPrettierInstalled = isPackageExists("prettier");
586
- const defineConfig = (options = {}, ...userConfigs) => {
587
- const configs = [
588
- ...gitignore(),
589
- ...ignores(options.ignores),
590
- ...javascript(),
591
- ...jsdoc(),
592
- ...sonarjs(),
593
- ...importSort(),
594
- ...deMorgan(),
595
- ...comments(),
596
- ...node(),
597
- ...importX(options.typescriptResolver),
598
- ...command(),
599
- ...unicorn(),
600
- ...jsxA11y(options.jsxA11y),
601
- ...typescript(),
602
- ...unusedImports(),
603
- ...regexp(),
604
- ...stylistic(),
605
- ...zod(),
606
- ...promise(),
607
- ...nelsonlaidev()
608
- ];
609
- const isNextjsEnabled = options.nextjs ?? isNextjsInstalled;
610
- const isReactEnabled = options.react ?? isReactInstalled;
611
- const isPrettierEnabled = options.prettier ?? isPrettierInstalled;
612
- if (options.vitest) configs.push(...vitest(options.vitest));
613
- if (options.playwright) configs.push(...playwright(options.playwright));
614
- if (isReactEnabled) configs.push(...react());
615
- if (isNextjsEnabled) configs.push(...nextjs());
616
- if (options.tailwindcss) configs.push(...tailwindcss(options.tailwindcss));
617
- configs.push(...userConfigs);
618
- if (isPrettierEnabled) configs.push(...prettier());
619
- return makeAllErrors(configs);
457
+ //#region src/configs/nextjs.ts
458
+ const nextjs = (options = {}) => {
459
+ return mergeConfig({
460
+ name: "nelsonlaidev/nextjs",
461
+ plugins: { "@next/next": nextPlugin },
462
+ rules: { ...nextPlugin.configs["core-web-vitals"].rules }
463
+ }, options);
464
+ };
465
+ //#endregion
466
+ //#region src/configs/playwright.ts
467
+ const playwright = (options = {}) => {
468
+ return mergeConfig({
469
+ name: "nelsonlaidev/playwright",
470
+ plugins: { playwright: playwrightPlugin },
471
+ languageOptions: { globals: globals["shared-node-browser"] },
472
+ rules: { ...playwrightPlugin.configs.recommended.rules }
473
+ }, options);
474
+ };
475
+ //#endregion
476
+ //#region src/configs/prettier.ts
477
+ const prettier = (options = {}) => {
478
+ return mergeConfig({
479
+ name: "nelsonlaidev/prettier",
480
+ rules
481
+ }, options);
482
+ };
483
+ //#endregion
484
+ //#region src/configs/react.ts
485
+ const react = (options = {}) => {
486
+ return mergeConfig({
487
+ name: "nelsonlaidev/react",
488
+ plugins: {
489
+ ...reactPlugin.configs.all.plugins,
490
+ "react-hooks": reactHooksPlugin
491
+ },
492
+ settings: { ...reactPlugin.configs.all.settings },
493
+ rules: {
494
+ ...reactHooksPlugin.configs["recommended-latest"].rules,
495
+ ...reactPlugin.configs.all.rules,
496
+ ...reactPlugin.configs["disable-conflict-eslint-plugin-react-hooks"].rules,
497
+ "@eslint-react/static-components": "off",
498
+ "@eslint-react/immutability": "error",
499
+ "@eslint-react/refs": "error",
500
+ "@eslint-react/no-leaked-conditional-rendering": "error",
501
+ "@eslint-react/no-unused-props": "error"
502
+ }
503
+ }, options);
504
+ };
505
+ //#endregion
506
+ //#region src/configs/tailwindcss.ts
507
+ const tailwindcss = (options = {}) => {
508
+ return mergeConfig({
509
+ name: "nelsonlaidev/tailwindcss",
510
+ plugins: { "better-tailwindcss": tailwindcssPlugin },
511
+ settings: { "better-tailwindcss": {
512
+ detectComponentClasses: false,
513
+ rootFontSize: 16
514
+ } },
515
+ rules: {
516
+ "better-tailwindcss/enforce-canonical-classes": "error",
517
+ "better-tailwindcss/enforce-consistent-variant-order": "error",
518
+ "better-tailwindcss/enforce-consistent-class-order": "error",
519
+ "better-tailwindcss/no-conflicting-classes": "error",
520
+ "better-tailwindcss/no-deprecated-classes": "error",
521
+ "better-tailwindcss/no-duplicate-classes": "error",
522
+ "better-tailwindcss/no-restricted-classes": "error",
523
+ "better-tailwindcss/no-unknown-classes": "error",
524
+ "better-tailwindcss/no-unnecessary-whitespace": "error"
525
+ }
526
+ }, options);
527
+ };
528
+ //#endregion
529
+ //#region src/configs/vitest.ts
530
+ const vitest = (options = {}) => {
531
+ return mergeConfig({
532
+ name: "nelsonlaidev/vitest",
533
+ plugins: { vitest: vitestPlugin },
534
+ settings: { vitest: { typecheck: true } },
535
+ languageOptions: { globals: { ...vitestPlugin.environments.env.globals } },
536
+ rules: {
537
+ ...vitestPlugin.configs.recommended.rules,
538
+ "vitest/consistent-test-it": ["error", { fn: "test" }],
539
+ "vitest/prefer-mock-return-shorthand": "error",
540
+ "vitest/warn-todo": "error"
541
+ }
542
+ }, options);
620
543
  };
621
544
  //#endregion
622
- export { GLOB_JS, GLOB_JSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX, defineConfig };
545
+ export { GLOB_JS, GLOB_JSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX, defineConfig, nextjs, playwright, prettier, react, tailwindcss, vitest };
623
546
 
624
547
  //# sourceMappingURL=index.mjs.map