pasika 0.10.49 → 0.10.51
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 +30 -7
- 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,
|
|
@@ -6297,7 +6312,7 @@ var supportFolderShapeRule = {
|
|
|
6297
6312
|
schema: [],
|
|
6298
6313
|
type: "problem",
|
|
6299
6314
|
docs: {
|
|
6300
|
-
description: "Require a support folder to either define its exports directly in index.ts or re-export
|
|
6315
|
+
description: "Require a support folder to either define its exports directly in index.ts or re-export its local sibling modules, never proxy an external module from an otherwise empty support folder or mix both."
|
|
6301
6316
|
}
|
|
6302
6317
|
},
|
|
6303
6318
|
create(context) {
|
|
@@ -6314,19 +6329,27 @@ var supportFolderShapeRule = {
|
|
|
6314
6329
|
return {};
|
|
6315
6330
|
}
|
|
6316
6331
|
const siblingModules = entries.filter((entry) => entry !== baseName && /\.(?:[cm]?tsx?|jsx?)$/.test(entry));
|
|
6317
|
-
if (siblingModules.length === 0) return {};
|
|
6318
6332
|
return {
|
|
6319
6333
|
Program(node) {
|
|
6320
6334
|
const source = context.sourceCode.text;
|
|
6321
6335
|
const hasDirectExport = /export\s+(?:const|let|var|function|class|type|interface|enum)\b/.test(source);
|
|
6322
6336
|
const exportedFiles = /* @__PURE__ */ new Set();
|
|
6323
|
-
|
|
6337
|
+
let hasAnyReExport = false;
|
|
6338
|
+
const exportPattern = /export\s+(?:type\s+)?(?:\{[^}]*\}|\*)\s+from\s+["'](?<specifier>[^"']+)["']/g;
|
|
6324
6339
|
for (const match of source.matchAll(exportPattern)) {
|
|
6340
|
+
hasAnyReExport = true;
|
|
6325
6341
|
const specifier = match.groups?.specifier;
|
|
6326
|
-
if (specifier) exportedFiles.add(path49.basename(specifier));
|
|
6342
|
+
if (specifier?.startsWith(".")) exportedFiles.add(path49.basename(specifier));
|
|
6327
6343
|
}
|
|
6328
|
-
const hasAnyReExport = exportedFiles.size > 0;
|
|
6329
6344
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
6345
|
+
if (siblingModules.length === 0) {
|
|
6346
|
+
if (hasDirectExport || !hasAnyReExport) return;
|
|
6347
|
+
context.report({
|
|
6348
|
+
node,
|
|
6349
|
+
message: `${folder}/index.ts re-exports from an external module without local support files; define the exports directly in index.ts. See ${guide}`
|
|
6350
|
+
});
|
|
6351
|
+
return;
|
|
6352
|
+
}
|
|
6330
6353
|
if (hasDirectExport && hasAnyReExport) {
|
|
6331
6354
|
context.report({
|
|
6332
6355
|
node,
|