@tb-dev/eslint-config 9.1.4 → 10.0.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Andrew Ferreira <andrew.shien2@gmail.com>
3
+ Copyright (c) 2026 Andrew Ferreira <andrew.shien2@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ function isEnabled(config, feature) {
37
37
  switch (feature) {
38
38
  case "perfectionist": return config?.perfectionist ?? true;
39
39
  case "unicorn": return config?.unicorn ?? true;
40
+ case "unocss": return config?.unocss ?? false;
40
41
  case "vue": return config?.vue ?? false;
41
42
  default: return false;
42
43
  }
@@ -44,6 +45,9 @@ function isEnabled(config, feature) {
44
45
  function getIgnores() {
45
46
  return Object.values(GlobIgnore);
46
47
  }
48
+ function mapRules(rules, fn) {
49
+ return Object.fromEntries(Object.entries(rules).map(([rule, value]) => fn(rule, value)));
50
+ }
47
51
  //#endregion
48
52
  //#region src/lib/vue.ts
49
53
  /**
@@ -56,6 +60,10 @@ async function vue(options) {
56
60
  interopDefault(import("vue-eslint-parser")),
57
61
  interopDefault(import("@typescript-eslint/parser"))
58
62
  ]);
63
+ const overrides = mapRules(options.overrides?.vue ?? {}, (rule, value) => {
64
+ if (rule.startsWith("vue/")) return [rule, value];
65
+ else return [`vue/${rule}`, value];
66
+ });
59
67
  const rules = {
60
68
  ...vuePlugin.configs.base.rules,
61
69
  "vue/attribute-hyphenation": ["error", "always"],
@@ -230,7 +238,7 @@ async function vue(options) {
230
238
  "vue/valid-v-show": "error",
231
239
  "vue/valid-v-slot": "error",
232
240
  "vue/valid-v-text": "error",
233
- ...options.overrides?.vue
241
+ ...overrides
234
242
  };
235
243
  return [
236
244
  { plugins: { vue: vuePlugin } },
@@ -255,14 +263,39 @@ async function vue(options) {
255
263
  ];
256
264
  }
257
265
  //#endregion
266
+ //#region src/lib/unocss.ts
267
+ async function unocss(options) {
268
+ if (!isEnabled(options.features, "unocss")) return {};
269
+ const plugin = await interopDefault(import("@unocss/eslint-config"));
270
+ const overrides = mapRules(options.overrides?.unocss ?? {}, (rule, value) => {
271
+ if (rule.startsWith("@unocss/")) return [rule, value];
272
+ else return [`@unocss/${rule}`, value];
273
+ });
274
+ return {
275
+ plugins: { "@unocss": plugin },
276
+ rules: {
277
+ "@unocss/blocklist": "off",
278
+ "@unocss/enforce-class-compile": "off",
279
+ "@unocss/order": "error",
280
+ "@unocss/order-attributify": "off",
281
+ ...overrides
282
+ }
283
+ };
284
+ }
285
+ //#endregion
258
286
  //#region src/lib/unicorn.ts
259
287
  /**
260
288
  * @see https://github.com/sindresorhus/eslint-plugin-unicorn#rules
261
289
  */
262
290
  async function unicorn(options) {
263
291
  if (!isEnabled(options.features, "unicorn")) return {};
292
+ const plugin = await interopDefault(import("eslint-plugin-unicorn"));
293
+ const overrides = mapRules(options.overrides?.unicorn ?? {}, (rule, value) => {
294
+ if (rule.startsWith("unicorn/")) return [rule, value];
295
+ else return [`unicorn/${rule}`, value];
296
+ });
264
297
  return {
265
- plugins: { unicorn: await interopDefault(import("eslint-plugin-unicorn")) },
298
+ plugins: { unicorn: plugin },
266
299
  rules: {
267
300
  "unicorn/catch-error-name": ["error", { name: "err" }],
268
301
  "unicorn/consistent-date-clone": "error",
@@ -317,7 +350,7 @@ async function unicorn(options) {
317
350
  "unicorn/prefer-structured-clone": "error",
318
351
  "unicorn/prefer-type-error": "error",
319
352
  "unicorn/relative-url-style": ["error", "never"],
320
- ...options.overrides?.unicorn
353
+ ...overrides
321
354
  }
322
355
  };
323
356
  }
@@ -503,6 +536,10 @@ async function typescript(options) {
503
536
  if (isEnabled(options.features, "vue")) files.push(Glob.Vue);
504
537
  const extraFileExtensions = [];
505
538
  if (isEnabled(options.features, "vue")) extraFileExtensions.push(".vue");
539
+ const overrides = mapRules(options.overrides?.typescript ?? {}, (rule, value) => {
540
+ if (rule.startsWith("@typescript-eslint/")) return [rule, value];
541
+ else return [`@typescript-eslint/${rule}`, value];
542
+ });
506
543
  const rules = {
507
544
  "@typescript-eslint/adjacent-overload-signatures": "error",
508
545
  "no-array-constructor": "off",
@@ -643,7 +680,7 @@ async function typescript(options) {
643
680
  "@typescript-eslint/no-unnecessary-condition": "error",
644
681
  "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
645
682
  "@typescript-eslint/no-unnecessary-qualifier": "error",
646
- "@typescript-eslint/no-unnecessary-type-arguments": "error",
683
+ "@typescript-eslint/no-unnecessary-type-arguments": "off",
647
684
  "@typescript-eslint/no-unnecessary-type-assertion": "error",
648
685
  "@typescript-eslint/no-unnecessary-type-constraint": "error",
649
686
  "@typescript-eslint/no-unnecessary-type-parameters": "error",
@@ -723,7 +760,7 @@ async function typescript(options) {
723
760
  "@typescript-eslint/unbound-method": "error",
724
761
  "@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
725
762
  "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
726
- ...options.overrides?.typescript
763
+ ...overrides
727
764
  };
728
765
  return [{
729
766
  files,
@@ -751,8 +788,13 @@ async function typescript(options) {
751
788
  */
752
789
  async function perfectionist(options) {
753
790
  if (!isEnabled(options.features, "perfectionist")) return {};
791
+ const plugin = await interopDefault(import("eslint-plugin-perfectionist"));
792
+ const overrides = mapRules(options.overrides?.perfectionist ?? {}, (rule, value) => {
793
+ if (rule.startsWith("perfectionist/")) return [rule, value];
794
+ else return [`perfectionist/${rule}`, value];
795
+ });
754
796
  return {
755
- plugins: { perfectionist: await interopDefault(import("eslint-plugin-perfectionist")) },
797
+ plugins: { perfectionist: plugin },
756
798
  rules: {
757
799
  "perfectionist/sort-array-includes": ["error", {
758
800
  type: "natural",
@@ -805,7 +847,7 @@ async function perfectionist(options) {
805
847
  "perfectionist/sort-object-types": "off",
806
848
  "perfectionist/sort-union-types": "off",
807
849
  "perfectionist/sort-switch-case": "off",
808
- ...options.overrides?.perfectionist
850
+ ...overrides
809
851
  }
810
852
  };
811
853
  }
@@ -819,6 +861,7 @@ async function defineConfig(options) {
819
861
  ...await vue(options),
820
862
  perfectionist(options),
821
863
  unicorn(options),
864
+ unocss(options),
822
865
  ignores
823
866
  ]);
824
867
  }
@@ -1,4 +1,5 @@
1
1
  export * from './vue';
2
+ export * from './unocss';
2
3
  export * from './unicorn';
3
4
  export * from './javascript';
4
5
  export * from './typescript';
@@ -0,0 +1,2 @@
1
+ import { ConfigObject, ConfigOptions } from '../types';
2
+ export declare function unocss(options: ConfigOptions): Promise<Partial<ConfigObject>>;
@@ -4,6 +4,8 @@ export interface FeaturesObject {
4
4
  /** @default true */
5
5
  unicorn?: boolean;
6
6
  /** @default false */
7
+ unocss?: boolean;
8
+ /** @default false */
7
9
  vue?: boolean;
8
10
  }
9
11
  export interface ConfigOptions {
@@ -16,6 +18,7 @@ export interface ConfigOptions {
16
18
  perfectionist?: Rules;
17
19
  typescript?: Rules;
18
20
  unicorn?: Rules;
21
+ unocss?: Rules;
19
22
  vue?: Rules;
20
23
  };
21
24
  /**
@@ -1,6 +1,7 @@
1
- import { ConfigOptions, FeaturesObject } from '../types';
1
+ import { ConfigOptions, FeaturesObject, Rules, Severity } from '../types';
2
2
  export * from './enum';
3
3
  export declare function interopDefault(promise: Promise<any>): Promise<unknown>;
4
4
  export declare function isEnabled(config: ConfigOptions['features'], feature: keyof FeaturesObject): boolean;
5
5
  export declare function json<T>(path: string): Promise<T>;
6
6
  export declare function getIgnores(): string[];
7
+ export declare function mapRules(rules: Rules, fn: (rule: string, value: any[] | Severity) => [string, any[] | Severity]): Rules;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/eslint-config",
3
- "version": "9.1.4",
3
+ "version": "10.0.1",
4
4
  "description": "ESLint config",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,6 +21,7 @@
21
21
  "dependencies": {
22
22
  "@typescript-eslint/eslint-plugin": "^8.58.0",
23
23
  "@typescript-eslint/parser": "^8.58.0",
24
+ "@unocss/eslint-config": "^66.6.7",
24
25
  "eslint-plugin-perfectionist": "^5.8.0",
25
26
  "eslint-plugin-unicorn": "^64.0.0",
26
27
  "eslint-plugin-vue": "^10.8.0",