@tb-dev/eslint-config 4.4.0 → 4.4.2

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.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
3
5
  const process = require('node:process');
4
6
  const globals = require('globals');
5
7
 
@@ -144,14 +146,13 @@ const stylisticRules = {
144
146
  "stylistic/yield-star-spacing": ["error", "after"]
145
147
  };
146
148
  async function stylistic(options) {
147
- const { overrides, stylistic: enabled } = options;
148
- if (!enabled) return {};
149
+ if (!options.features?.stylistic) return {};
149
150
  const plugin = await interopDefault(import('@stylistic/eslint-plugin'));
150
151
  const files = [Glob.All];
151
- if (options.vue) files.push(Glob.Vue);
152
+ if (options.features.vue) files.push(Glob.Vue);
152
153
  const rules = {
153
154
  ...stylisticRules,
154
- ...overrides?.stylistic
155
+ ...options.overrides?.stylistic
155
156
  };
156
157
  return {
157
158
  files,
@@ -161,8 +162,7 @@ async function stylistic(options) {
161
162
  }
162
163
 
163
164
  async function vue(options) {
164
- const { overrides, vue: enabled } = options;
165
- if (!enabled) return [];
165
+ if (!options.features?.vue) return [];
166
166
  const [vuePlugin, vueParser, tsParser] = await Promise.all([
167
167
  // @ts-expect-error no types
168
168
  interopDefault(import('eslint-plugin-vue')),
@@ -323,9 +323,9 @@ async function vue(options) {
323
323
  "vue/valid-v-show": "error",
324
324
  "vue/valid-v-slot": "error",
325
325
  "vue/valid-v-text": "error",
326
- ...overrides?.vue
326
+ ...options.overrides?.vue
327
327
  };
328
- if (options.stylistic) {
328
+ if (options.features.stylistic) {
329
329
  Object.assign(rules, {
330
330
  "vue/first-attribute-linebreak": ["error", {
331
331
  singleline: "beside",
@@ -431,8 +431,7 @@ async function vue(options) {
431
431
  }
432
432
 
433
433
  async function jsonc(options) {
434
- const { overrides, jsonc: enabled } = options;
435
- if (!enabled) return [];
434
+ if (!options.features?.jsonc) return [];
436
435
  const [jsoncPlugin, jsoncParser] = await Promise.all([
437
436
  interopDefault(import('eslint-plugin-jsonc')),
438
437
  interopDefault(import('jsonc-eslint-parser'))
@@ -446,9 +445,9 @@ async function jsonc(options) {
446
445
  "jsonc/no-number-props": "error",
447
446
  "jsonc/no-undefined-value": "error",
448
447
  "jsonc/valid-json-number": "error",
449
- ...overrides?.jsonc
448
+ ...options.overrides?.jsonc
450
449
  };
451
- if (options.stylistic) {
450
+ if (options.features.stylistic) {
452
451
  Object.assign(rules, {
453
452
  "jsonc/comma-dangle": ["error", "never"],
454
453
  "jsonc/quotes": ["error", "double", { avoidEscape: false }],
@@ -484,8 +483,7 @@ async function jsonc(options) {
484
483
  }
485
484
 
486
485
  async function vitest(options) {
487
- const { overrides, vitest: enabled } = options;
488
- if (!enabled) return {};
486
+ if (!options.features?.vitest) return {};
489
487
  const plugin = await interopDefault(import('eslint-plugin-vitest'));
490
488
  return {
491
489
  plugins: { vitest: plugin },
@@ -522,13 +520,13 @@ async function vitest(options) {
522
520
  "vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 10 }],
523
521
  "vitest/valid-describe-callback": "error",
524
522
  "vitest/valid-expect": "error",
525
- ...overrides?.vitest
523
+ ...options.overrides?.vitest
526
524
  }
527
525
  };
528
526
  }
529
527
 
530
528
  async function unicorn(options) {
531
- const { overrides, unicorn: enabled = true } = options;
529
+ const { unicorn: enabled = true } = options.features ?? {};
532
530
  if (!enabled) return {};
533
531
  const plugin = await interopDefault(import('eslint-plugin-unicorn'));
534
532
  return {
@@ -573,20 +571,20 @@ async function unicorn(options) {
573
571
  "unicorn/prefer-structured-clone": "error",
574
572
  "unicorn/prefer-type-error": "error",
575
573
  "unicorn/relative-url-style": ["error", "never"],
576
- ...overrides?.unicorn
574
+ ...options.overrides?.unicorn
577
575
  }
578
576
  };
579
577
  }
580
578
 
581
579
  async function tailwind(options) {
582
- const { overrides, tailwind: enabled } = options;
583
- if (!enabled) return {};
580
+ if (!options.features?.tailwind) return {};
584
581
  const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
582
+ const callees = ["classnames", "clsx", "cn", "ctl", "cva", "tv"];
585
583
  const rules = {
586
- "tailwindcss/classnames-order": "error",
587
- "tailwindcss/enforces-shorthand": "error",
588
- "tailwindcss/no-contradicting-classname": "error",
589
- ...overrides?.tailwind
584
+ "tailwindcss/classnames-order": ["error", { callees }],
585
+ "tailwindcss/enforces-shorthand": ["error", { callees }],
586
+ "tailwindcss/no-contradicting-classname": ["error", { callees }],
587
+ ...options.overrides?.tailwind
590
588
  };
591
589
  return {
592
590
  plugins: { tailwindcss: plugin },
@@ -595,9 +593,8 @@ async function tailwind(options) {
595
593
  }
596
594
 
597
595
  function javascript(options) {
598
- const { overrides } = options;
599
596
  const files = [Glob.All];
600
- if (options.vue) files.push(Glob.Vue);
597
+ if (options.features?.vue) files.push(Glob.Vue);
601
598
  return {
602
599
  files,
603
600
  languageOptions: {
@@ -733,19 +730,18 @@ function javascript(options) {
733
730
  "use-isnan": "error",
734
731
  "valid-typeof": "error",
735
732
  yoda: ["error", "never"],
736
- ...overrides?.javascript
733
+ ...options.overrides?.javascript
737
734
  }
738
735
  };
739
736
  }
740
737
 
741
738
  async function typescript(options) {
742
- const { project, overrides } = options;
743
739
  const [tsParser, tsPlugin] = await Promise.all([
744
740
  interopDefault(import('@typescript-eslint/parser')),
745
741
  interopDefault(import('@typescript-eslint/eslint-plugin'))
746
742
  ]);
747
743
  const files = [Glob.Typescript];
748
- if (options.vue) files.push(Glob.Vue);
744
+ if (options.features?.vue) files.push(Glob.Vue);
749
745
  const rules = {
750
746
  "@typescript-eslint/adjacent-overload-signatures": "error",
751
747
  "no-array-constructor": "off",
@@ -946,7 +942,7 @@ async function typescript(options) {
946
942
  "@typescript-eslint/unbound-method": "error",
947
943
  "@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
948
944
  "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
949
- ...overrides?.typescript
945
+ ...options.overrides?.typescript
950
946
  };
951
947
  return {
952
948
  files,
@@ -955,9 +951,9 @@ async function typescript(options) {
955
951
  sourceType: "module",
956
952
  parser: tsParser,
957
953
  parserOptions: {
958
- project,
954
+ project: options.project,
959
955
  tsconfigRootDir: process.cwd(),
960
- extraFileExtensions: options.vue ? [".vue"] : []
956
+ extraFileExtensions: options.features?.vue ? [".vue"] : []
961
957
  }
962
958
  },
963
959
  plugins: { "@typescript-eslint": tsPlugin },
@@ -966,7 +962,7 @@ async function typescript(options) {
966
962
  }
967
963
 
968
964
  async function perfectionist(options) {
969
- const { overrides, perfectionist: enabled = true } = options;
965
+ const { perfectionist: enabled = true } = options.features ?? {};
970
966
  if (!enabled) return {};
971
967
  const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
972
968
  return {
@@ -1027,7 +1023,7 @@ async function perfectionist(options) {
1027
1023
  order: "asc",
1028
1024
  ignoreCase: true
1029
1025
  }],
1030
- ...overrides?.perfectionist
1026
+ ...options.overrides?.perfectionist
1031
1027
  }
1032
1028
  };
1033
1029
  }
@@ -1051,4 +1047,4 @@ async function defineConfig(options) {
1051
1047
  return objects;
1052
1048
  }
1053
1049
 
1054
- module.exports = defineConfig;
1050
+ exports.defineConfig = defineConfig;
package/dist/index.d.ts CHANGED
@@ -15,20 +15,22 @@ declare interface ConfigObject {
15
15
  }
16
16
 
17
17
  declare interface ConfigOptions {
18
- /** @default false */
19
- jsonc?: boolean;
20
- /** @default true */
21
- perfectionist?: boolean;
22
- /** @default false */
23
- stylistic?: boolean;
24
- /** @default false */
25
- tailwind?: boolean;
26
- /** @default true */
27
- unicorn?: boolean;
28
- /** @default false */
29
- vitest?: boolean;
30
- /** @default false */
31
- vue?: boolean;
18
+ features?: {
19
+ /** @default false */
20
+ jsonc?: boolean;
21
+ /** @default true */
22
+ perfectionist?: boolean;
23
+ /** @default false */
24
+ stylistic?: boolean;
25
+ /** @default false */
26
+ tailwind?: boolean;
27
+ /** @default true */
28
+ unicorn?: boolean;
29
+ /** @default false */
30
+ vitest?: boolean;
31
+ /** @default false */
32
+ vue?: boolean;
33
+ };
32
34
  /** `tsconfig.json` files for TypeScript. */
33
35
  project: string[];
34
36
  ignores?: Ignores['ignores'];
@@ -47,8 +49,7 @@ declare interface ConfigOptions {
47
49
  knownSafePromises?: KnownSafePromise[];
48
50
  }
49
51
 
50
- declare function defineConfig(options: ConfigOptions): Promise<Partial<ConfigObject>[]>;
51
- export default defineConfig;
52
+ export declare function defineConfig(options: ConfigOptions): Promise<Partial<ConfigObject>[]>;
52
53
 
53
54
  declare interface Ignores {
54
55
  ignores: string[];
package/dist/index.js CHANGED
@@ -142,14 +142,13 @@ const stylisticRules = {
142
142
  "stylistic/yield-star-spacing": ["error", "after"]
143
143
  };
144
144
  async function stylistic(options) {
145
- const { overrides, stylistic: enabled } = options;
146
- if (!enabled) return {};
145
+ if (!options.features?.stylistic) return {};
147
146
  const plugin = await interopDefault(import('@stylistic/eslint-plugin'));
148
147
  const files = [Glob.All];
149
- if (options.vue) files.push(Glob.Vue);
148
+ if (options.features.vue) files.push(Glob.Vue);
150
149
  const rules = {
151
150
  ...stylisticRules,
152
- ...overrides?.stylistic
151
+ ...options.overrides?.stylistic
153
152
  };
154
153
  return {
155
154
  files,
@@ -159,8 +158,7 @@ async function stylistic(options) {
159
158
  }
160
159
 
161
160
  async function vue(options) {
162
- const { overrides, vue: enabled } = options;
163
- if (!enabled) return [];
161
+ if (!options.features?.vue) return [];
164
162
  const [vuePlugin, vueParser, tsParser] = await Promise.all([
165
163
  // @ts-expect-error no types
166
164
  interopDefault(import('eslint-plugin-vue')),
@@ -321,9 +319,9 @@ async function vue(options) {
321
319
  "vue/valid-v-show": "error",
322
320
  "vue/valid-v-slot": "error",
323
321
  "vue/valid-v-text": "error",
324
- ...overrides?.vue
322
+ ...options.overrides?.vue
325
323
  };
326
- if (options.stylistic) {
324
+ if (options.features.stylistic) {
327
325
  Object.assign(rules, {
328
326
  "vue/first-attribute-linebreak": ["error", {
329
327
  singleline: "beside",
@@ -429,8 +427,7 @@ async function vue(options) {
429
427
  }
430
428
 
431
429
  async function jsonc(options) {
432
- const { overrides, jsonc: enabled } = options;
433
- if (!enabled) return [];
430
+ if (!options.features?.jsonc) return [];
434
431
  const [jsoncPlugin, jsoncParser] = await Promise.all([
435
432
  interopDefault(import('eslint-plugin-jsonc')),
436
433
  interopDefault(import('jsonc-eslint-parser'))
@@ -444,9 +441,9 @@ async function jsonc(options) {
444
441
  "jsonc/no-number-props": "error",
445
442
  "jsonc/no-undefined-value": "error",
446
443
  "jsonc/valid-json-number": "error",
447
- ...overrides?.jsonc
444
+ ...options.overrides?.jsonc
448
445
  };
449
- if (options.stylistic) {
446
+ if (options.features.stylistic) {
450
447
  Object.assign(rules, {
451
448
  "jsonc/comma-dangle": ["error", "never"],
452
449
  "jsonc/quotes": ["error", "double", { avoidEscape: false }],
@@ -482,8 +479,7 @@ async function jsonc(options) {
482
479
  }
483
480
 
484
481
  async function vitest(options) {
485
- const { overrides, vitest: enabled } = options;
486
- if (!enabled) return {};
482
+ if (!options.features?.vitest) return {};
487
483
  const plugin = await interopDefault(import('eslint-plugin-vitest'));
488
484
  return {
489
485
  plugins: { vitest: plugin },
@@ -520,13 +516,13 @@ async function vitest(options) {
520
516
  "vitest/require-top-level-describe": ["error", { maxNumberOfTopLevelDescribes: 10 }],
521
517
  "vitest/valid-describe-callback": "error",
522
518
  "vitest/valid-expect": "error",
523
- ...overrides?.vitest
519
+ ...options.overrides?.vitest
524
520
  }
525
521
  };
526
522
  }
527
523
 
528
524
  async function unicorn(options) {
529
- const { overrides, unicorn: enabled = true } = options;
525
+ const { unicorn: enabled = true } = options.features ?? {};
530
526
  if (!enabled) return {};
531
527
  const plugin = await interopDefault(import('eslint-plugin-unicorn'));
532
528
  return {
@@ -571,20 +567,20 @@ async function unicorn(options) {
571
567
  "unicorn/prefer-structured-clone": "error",
572
568
  "unicorn/prefer-type-error": "error",
573
569
  "unicorn/relative-url-style": ["error", "never"],
574
- ...overrides?.unicorn
570
+ ...options.overrides?.unicorn
575
571
  }
576
572
  };
577
573
  }
578
574
 
579
575
  async function tailwind(options) {
580
- const { overrides, tailwind: enabled } = options;
581
- if (!enabled) return {};
576
+ if (!options.features?.tailwind) return {};
582
577
  const plugin = await interopDefault(import('eslint-plugin-tailwindcss'));
578
+ const callees = ["classnames", "clsx", "cn", "ctl", "cva", "tv"];
583
579
  const rules = {
584
- "tailwindcss/classnames-order": "error",
585
- "tailwindcss/enforces-shorthand": "error",
586
- "tailwindcss/no-contradicting-classname": "error",
587
- ...overrides?.tailwind
580
+ "tailwindcss/classnames-order": ["error", { callees }],
581
+ "tailwindcss/enforces-shorthand": ["error", { callees }],
582
+ "tailwindcss/no-contradicting-classname": ["error", { callees }],
583
+ ...options.overrides?.tailwind
588
584
  };
589
585
  return {
590
586
  plugins: { tailwindcss: plugin },
@@ -593,9 +589,8 @@ async function tailwind(options) {
593
589
  }
594
590
 
595
591
  function javascript(options) {
596
- const { overrides } = options;
597
592
  const files = [Glob.All];
598
- if (options.vue) files.push(Glob.Vue);
593
+ if (options.features?.vue) files.push(Glob.Vue);
599
594
  return {
600
595
  files,
601
596
  languageOptions: {
@@ -731,19 +726,18 @@ function javascript(options) {
731
726
  "use-isnan": "error",
732
727
  "valid-typeof": "error",
733
728
  yoda: ["error", "never"],
734
- ...overrides?.javascript
729
+ ...options.overrides?.javascript
735
730
  }
736
731
  };
737
732
  }
738
733
 
739
734
  async function typescript(options) {
740
- const { project, overrides } = options;
741
735
  const [tsParser, tsPlugin] = await Promise.all([
742
736
  interopDefault(import('@typescript-eslint/parser')),
743
737
  interopDefault(import('@typescript-eslint/eslint-plugin'))
744
738
  ]);
745
739
  const files = [Glob.Typescript];
746
- if (options.vue) files.push(Glob.Vue);
740
+ if (options.features?.vue) files.push(Glob.Vue);
747
741
  const rules = {
748
742
  "@typescript-eslint/adjacent-overload-signatures": "error",
749
743
  "no-array-constructor": "off",
@@ -944,7 +938,7 @@ async function typescript(options) {
944
938
  "@typescript-eslint/unbound-method": "error",
945
939
  "@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
946
940
  "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
947
- ...overrides?.typescript
941
+ ...options.overrides?.typescript
948
942
  };
949
943
  return {
950
944
  files,
@@ -953,9 +947,9 @@ async function typescript(options) {
953
947
  sourceType: "module",
954
948
  parser: tsParser,
955
949
  parserOptions: {
956
- project,
950
+ project: options.project,
957
951
  tsconfigRootDir: process.cwd(),
958
- extraFileExtensions: options.vue ? [".vue"] : []
952
+ extraFileExtensions: options.features?.vue ? [".vue"] : []
959
953
  }
960
954
  },
961
955
  plugins: { "@typescript-eslint": tsPlugin },
@@ -964,7 +958,7 @@ async function typescript(options) {
964
958
  }
965
959
 
966
960
  async function perfectionist(options) {
967
- const { overrides, perfectionist: enabled = true } = options;
961
+ const { perfectionist: enabled = true } = options.features ?? {};
968
962
  if (!enabled) return {};
969
963
  const plugin = await interopDefault(import('eslint-plugin-perfectionist'));
970
964
  return {
@@ -1025,7 +1019,7 @@ async function perfectionist(options) {
1025
1019
  order: "asc",
1026
1020
  ignoreCase: true
1027
1021
  }],
1028
- ...overrides?.perfectionist
1022
+ ...options.overrides?.perfectionist
1029
1023
  }
1030
1024
  };
1031
1025
  }
@@ -1049,4 +1043,4 @@ async function defineConfig(options) {
1049
1043
  return objects;
1050
1044
  }
1051
1045
 
1052
- export { defineConfig as default };
1046
+ export { defineConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/eslint-config",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "description": "ESLint config",
5
5
  "license": "MIT",
6
6
  "type": "module",