pasika 0.10.67 → 0.10.69
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 +32 -8
- package/package.json +1 -1
|
@@ -301,6 +301,15 @@ function propertyName(node) {
|
|
|
301
301
|
if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node)) return node.text;
|
|
302
302
|
return void 0;
|
|
303
303
|
}
|
|
304
|
+
function bindingIdentifiers(name) {
|
|
305
|
+
if (ts.isIdentifier(name)) return [name];
|
|
306
|
+
const identifiers = [];
|
|
307
|
+
for (const element of name.elements) {
|
|
308
|
+
if (ts.isOmittedExpression(element)) continue;
|
|
309
|
+
identifiers.push(...bindingIdentifiers(element.name));
|
|
310
|
+
}
|
|
311
|
+
return identifiers;
|
|
312
|
+
}
|
|
304
313
|
function returnsJsx(node) {
|
|
305
314
|
let found = false;
|
|
306
315
|
const visit = (child) => {
|
|
@@ -417,12 +426,21 @@ function parseModule(file) {
|
|
|
417
426
|
}
|
|
418
427
|
if (ts.isVariableStatement(statement)) {
|
|
419
428
|
for (const declaration of statement.declarationList.declarations) {
|
|
420
|
-
if (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
429
|
+
if (ts.isIdentifier(declaration.name)) {
|
|
430
|
+
exports.push({
|
|
431
|
+
name: declaration.name.text,
|
|
432
|
+
kind: classifyValue(declaration.name.text, declaration.initializer, isTsx),
|
|
433
|
+
line: lineOf(sourceFile, declaration)
|
|
434
|
+
});
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
for (const identifier of bindingIdentifiers(declaration.name)) {
|
|
438
|
+
exports.push({
|
|
439
|
+
name: identifier.text,
|
|
440
|
+
kind: classifyValue(identifier.text, void 0, isTsx),
|
|
441
|
+
line: lineOf(sourceFile, identifier)
|
|
442
|
+
});
|
|
443
|
+
}
|
|
426
444
|
}
|
|
427
445
|
continue;
|
|
428
446
|
}
|
|
@@ -7801,7 +7819,7 @@ var typeExtractionRule = {
|
|
|
7801
7819
|
schema: [],
|
|
7802
7820
|
type: "problem",
|
|
7803
7821
|
docs: {
|
|
7804
|
-
description: "Require
|
|
7822
|
+
description: "Require unused type and schema exports to stay local, and independently consumed ones to be extracted."
|
|
7805
7823
|
}
|
|
7806
7824
|
},
|
|
7807
7825
|
create(context) {
|
|
@@ -7819,7 +7837,13 @@ var typeExtractionRule = {
|
|
|
7819
7837
|
for (const exp of module.exports) {
|
|
7820
7838
|
if (exp.kind !== "type" && exp.kind !== "schema") continue;
|
|
7821
7839
|
const consumers = [...index.symbolConsumers.get(symbolKey(file, exp.name)) ?? []];
|
|
7822
|
-
if (consumers.length === 0)
|
|
7840
|
+
if (consumers.length === 0) {
|
|
7841
|
+
findings.push({
|
|
7842
|
+
line: exp.line,
|
|
7843
|
+
message: `${exp.kind} "${exp.name}" has no external consumers; remove its export and keep it local. See docs/next-codebase-guide/rules/types-and-schemas-rule.md`
|
|
7844
|
+
});
|
|
7845
|
+
continue;
|
|
7846
|
+
}
|
|
7823
7847
|
if (componentExport) {
|
|
7824
7848
|
const componentConsumers = index.symbolConsumers.get(symbolKey(file, componentExport.name)) ?? /* @__PURE__ */ new Set();
|
|
7825
7849
|
const independent2 = consumers.filter((consumer) => !componentConsumers.has(consumer));
|