eslint-plugin-absolute 0.9.0 → 0.10.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.
Files changed (2) hide show
  1. package/dist/index.js +68 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -3681,6 +3681,73 @@ var noRedundantTypeAnnotation = {
3681
3681
  }
3682
3682
  };
3683
3683
 
3684
+ // src/rules/no-trivial-alias.ts
3685
+ var isBareTypeReference = (node) => {
3686
+ if (node.type === "TSTypeReference") {
3687
+ return !node.typeArguments || node.typeArguments.params.length === 0;
3688
+ }
3689
+ switch (node.type) {
3690
+ case "TSStringKeyword":
3691
+ case "TSNumberKeyword":
3692
+ case "TSBooleanKeyword":
3693
+ case "TSNullKeyword":
3694
+ case "TSUndefinedKeyword":
3695
+ case "TSVoidKeyword":
3696
+ case "TSAnyKeyword":
3697
+ case "TSUnknownKeyword":
3698
+ case "TSNeverKeyword":
3699
+ case "TSBigIntKeyword":
3700
+ case "TSSymbolKeyword":
3701
+ case "TSObjectKeyword":
3702
+ return true;
3703
+ default:
3704
+ return false;
3705
+ }
3706
+ };
3707
+ var isBareIdentifierInit = (init) => init.type === "Identifier";
3708
+ var noTrivialAlias = {
3709
+ create(context) {
3710
+ return {
3711
+ TSTypeAliasDeclaration(node) {
3712
+ if (!isBareTypeReference(node.typeAnnotation))
3713
+ return;
3714
+ context.report({
3715
+ data: { name: node.id.name },
3716
+ messageId: "trivialTypeAlias",
3717
+ node
3718
+ });
3719
+ },
3720
+ VariableDeclarator(node) {
3721
+ if (node.id.type !== "Identifier")
3722
+ return;
3723
+ if (node.id.typeAnnotation)
3724
+ return;
3725
+ if (!node.init)
3726
+ return;
3727
+ if (!isBareIdentifierInit(node.init))
3728
+ return;
3729
+ context.report({
3730
+ data: { name: node.id.name },
3731
+ messageId: "trivialConstAlias",
3732
+ node
3733
+ });
3734
+ }
3735
+ };
3736
+ },
3737
+ defaultOptions: [],
3738
+ meta: {
3739
+ docs: {
3740
+ description: "Disallow identity aliases that rename a type or value without transforming it \u2014 `type X = Y` and `const x = y`. Pick one name and use it everywhere."
3741
+ },
3742
+ messages: {
3743
+ trivialConstAlias: "`{{name}}` is a trivial rename of another binding. Use the original at the consumer instead \u2014 duplicate aliases drift when one side is updated and the other isn't.",
3744
+ trivialTypeAlias: "`{{name}}` is a pure rename of another type. Use the original type at the consumer instead \u2014 duplicate aliases drift when one side is updated and the other isn't."
3745
+ },
3746
+ schema: [],
3747
+ type: "suggestion"
3748
+ }
3749
+ };
3750
+
3684
3751
  // src/rules/no-unnecessary-div.ts
3685
3752
  import { AST_NODE_TYPES as AST_NODE_TYPES5 } from "@typescript-eslint/utils";
3686
3753
  var noUnnecessaryDiv = {
@@ -3853,6 +3920,7 @@ var src_default = {
3853
3920
  "no-or-none-component": noOrNoneComponent,
3854
3921
  "no-redundant-type-annotation": noRedundantTypeAnnotation,
3855
3922
  "no-transition-cssproperties": noTransitionCSSProperties,
3923
+ "no-trivial-alias": noTrivialAlias,
3856
3924
  "no-unnecessary-div": noUnnecessaryDiv,
3857
3925
  "no-unnecessary-key": noUnnecessaryKey,
3858
3926
  "no-useless-function": noUselessFunction,
package/package.json CHANGED
@@ -8,8 +8,8 @@
8
8
  "@typescript-eslint/rule-tester": "8.56.0",
9
9
  "@typescript-eslint/utils": "8.56.0",
10
10
  "eslint": "10",
11
+ "knip": "6.11.0",
11
12
  "prettier": "3.8.1",
12
- "ts-prune": "0.10.3",
13
13
  "typescript": "5.9.3",
14
14
  "typescript-eslint": "8.56.0"
15
15
  },
@@ -34,11 +34,11 @@
34
34
  "build": "rm -rf dist && bun build src/index.ts --outdir dist --splitting --target=bun --external eslint --external @typescript-eslint/utils --external typescript",
35
35
  "format": "absolutejs prettier --write",
36
36
  "lint": "bun run build && bun run absolutejs eslint",
37
- "prune": "ts-prune --error",
37
+ "knip": "knip",
38
38
  "release": "bun run format && bun run build && bun publish",
39
39
  "test": "bun test tests/",
40
40
  "typecheck": "bun run tsc --noEmit"
41
41
  },
42
42
  "type": "module",
43
- "version": "0.9.0"
43
+ "version": "0.10.0"
44
44
  }