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