pasika 0.10.49 → 0.10.50
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/eslint/pasika/index.js +17 -2
- package/package.json +1 -1
|
@@ -4758,6 +4758,15 @@ import path37 from "path";
|
|
|
4758
4758
|
var DOC3 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
|
|
4759
4759
|
var VALUE_SENTINELS = /* @__PURE__ */ new Set(["undefined", "NaN", "Infinity"]);
|
|
4760
4760
|
var HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
4761
|
+
var PRIMITIVE_TYPE_NAMES = {
|
|
4762
|
+
TSBigIntKeyword: "bigint",
|
|
4763
|
+
TSBooleanKeyword: "boolean",
|
|
4764
|
+
TSNullKeyword: "null",
|
|
4765
|
+
TSNumberKeyword: "number",
|
|
4766
|
+
TSStringKeyword: "string",
|
|
4767
|
+
TSSymbolKeyword: "symbol",
|
|
4768
|
+
TSUndefinedKeyword: "undefined"
|
|
4769
|
+
};
|
|
4761
4770
|
function entityNameText(name) {
|
|
4762
4771
|
if (name.type === "Identifier") return name.name;
|
|
4763
4772
|
if (name.type === "TSQualifiedName") {
|
|
@@ -4769,6 +4778,12 @@ function entityNameText(name) {
|
|
|
4769
4778
|
const property = name.property.name;
|
|
4770
4779
|
return object && property ? `${object}.${property}` : void 0;
|
|
4771
4780
|
}
|
|
4781
|
+
function aliasedTypeName(annotation) {
|
|
4782
|
+
const primitiveTypeName = PRIMITIVE_TYPE_NAMES[annotation.type];
|
|
4783
|
+
if (primitiveTypeName) return primitiveTypeName;
|
|
4784
|
+
if (annotation.type !== "TSTypeReference" || annotation.typeArguments || !annotation.typeName) return void 0;
|
|
4785
|
+
return entityNameText(annotation.typeName);
|
|
4786
|
+
}
|
|
4772
4787
|
function aliasMessage(alias, source) {
|
|
4773
4788
|
const aliasName = alias ?? "This declaration";
|
|
4774
4789
|
const sourceName = source ?? "the original symbol";
|
|
@@ -4799,8 +4814,8 @@ var noRedundantAliasRule = {
|
|
|
4799
4814
|
TSTypeAliasDeclaration(node) {
|
|
4800
4815
|
if (node.typeParameters) return;
|
|
4801
4816
|
const annotation = node.typeAnnotation;
|
|
4802
|
-
if (annotation
|
|
4803
|
-
const source =
|
|
4817
|
+
if (!annotation) return;
|
|
4818
|
+
const source = aliasedTypeName(annotation);
|
|
4804
4819
|
if (!source) return;
|
|
4805
4820
|
context.report({
|
|
4806
4821
|
node,
|