pasika 0.10.103 → 0.10.104
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 +60 -3
- package/package.json +1 -1
|
@@ -3340,6 +3340,8 @@ var enumPlacementRule = {
|
|
|
3340
3340
|
if (!filename.startsWith(sourceRoot + path25.sep)) return {};
|
|
3341
3341
|
const inConstantsFolder = path25.basename(path25.dirname(filename)) === "constants";
|
|
3342
3342
|
const index = getProjectIndex(sourceRoot);
|
|
3343
|
+
const component = index?.modules.get(filename)?.exports.find((entry) => entry.kind === "component");
|
|
3344
|
+
const componentConsumers = component ? index?.symbolConsumers.get(symbolKey(filename, component.name)) : void 0;
|
|
3343
3345
|
return {
|
|
3344
3346
|
TSEnumDeclaration(node) {
|
|
3345
3347
|
const enumBody = "body" in node ? node.body : void 0;
|
|
@@ -3354,11 +3356,12 @@ var enumPlacementRule = {
|
|
|
3354
3356
|
});
|
|
3355
3357
|
return;
|
|
3356
3358
|
}
|
|
3357
|
-
const
|
|
3358
|
-
if (inConstantsFolder || !
|
|
3359
|
+
const consumers = index?.symbolConsumers.get(symbolKey(filename, enumName));
|
|
3360
|
+
if (inConstantsFolder || !consumers || consumers.size === 0) return;
|
|
3361
|
+
if (component && [...consumers].every((consumer) => componentConsumers?.has(consumer))) return;
|
|
3359
3362
|
context.report({
|
|
3360
3363
|
node,
|
|
3361
|
-
message: "An enum imported
|
|
3364
|
+
message: "An enum imported independently of its component must live in constants/ at its CCF; keep component-owned enums beside their component. See docs/next-codebase-guide/rules/constants-rule.md"
|
|
3362
3365
|
});
|
|
3363
3366
|
}
|
|
3364
3367
|
};
|
|
@@ -5802,6 +5805,31 @@ var noLiteralInlineStyleRule = {
|
|
|
5802
5805
|
// eslint/rules/no-mixed-concerns.ts
|
|
5803
5806
|
import { readFileSync as readFileSync10 } from "fs";
|
|
5804
5807
|
import path42 from "path";
|
|
5808
|
+
function isComponentSupportKind(kind) {
|
|
5809
|
+
return kind === "constant" || kind === "type" || kind === "schema";
|
|
5810
|
+
}
|
|
5811
|
+
function componentSupportExport(file, name, index, visited = /* @__PURE__ */ new Set()) {
|
|
5812
|
+
const key = symbolKey(file, name);
|
|
5813
|
+
if (visited.has(key)) return void 0;
|
|
5814
|
+
visited.add(key);
|
|
5815
|
+
const module = index.modules.get(file);
|
|
5816
|
+
if (!module) return void 0;
|
|
5817
|
+
const supportFolder = path42.basename(path42.dirname(file));
|
|
5818
|
+
if (["constants", "types", "schemas"].includes(supportFolder)) {
|
|
5819
|
+
const exported = module.exports.find((item) => item.name === name && isComponentSupportKind(item.kind));
|
|
5820
|
+
if (exported && isComponentSupportKind(exported.kind)) {
|
|
5821
|
+
return { file, name, kind: exported.kind };
|
|
5822
|
+
}
|
|
5823
|
+
}
|
|
5824
|
+
for (const forwarded of module.reexports) {
|
|
5825
|
+
if (forwarded.names.length > 0 && !forwarded.names.includes(name)) continue;
|
|
5826
|
+
const target = resolveSpecifier(file, forwarded.specifier, index.sourceRoot);
|
|
5827
|
+
if (!target) continue;
|
|
5828
|
+
const exported = componentSupportExport(target, name, index, visited);
|
|
5829
|
+
if (exported) return exported;
|
|
5830
|
+
}
|
|
5831
|
+
return void 0;
|
|
5832
|
+
}
|
|
5805
5833
|
var noMixedConcernsRule = {
|
|
5806
5834
|
meta: {
|
|
5807
5835
|
schema: [],
|
|
@@ -5829,6 +5857,35 @@ var noMixedConcernsRule = {
|
|
|
5829
5857
|
const sourceRoot = sourceRootOf(context);
|
|
5830
5858
|
const index = getProjectIndex(sourceRoot);
|
|
5831
5859
|
const componentConsumers = index?.symbolConsumers.get(symbolKey(file, componentName)) ?? /* @__PURE__ */ new Set();
|
|
5860
|
+
if (index) {
|
|
5861
|
+
const examined = /* @__PURE__ */ new Set();
|
|
5862
|
+
for (const imported of index.modules.get(file)?.imports ?? []) {
|
|
5863
|
+
const importedFile = resolveSpecifier(file, imported.specifier, sourceRoot);
|
|
5864
|
+
if (!importedFile) continue;
|
|
5865
|
+
for (const name of imported.names) {
|
|
5866
|
+
const support = componentSupportExport(importedFile, name, index);
|
|
5867
|
+
if (!support) continue;
|
|
5868
|
+
const key = symbolKey(support.file, support.name);
|
|
5869
|
+
if (examined.has(key)) continue;
|
|
5870
|
+
examined.add(key);
|
|
5871
|
+
const consumers = /* @__PURE__ */ new Set([
|
|
5872
|
+
...index.symbolConsumers.get(key) ?? [],
|
|
5873
|
+
...index.symbolConsumers.get(symbolKey(importedFile, name)) ?? []
|
|
5874
|
+
]);
|
|
5875
|
+
if (!consumers.has(file)) continue;
|
|
5876
|
+
const independentlyUsed = [...consumers].some((consumer) => {
|
|
5877
|
+
if (consumer === file || componentConsumers.has(consumer)) return false;
|
|
5878
|
+
const isForwarder = index.modules.get(consumer)?.reexports.some((forwarded) => forwarded.names.length === 0 || forwarded.names.includes(name));
|
|
5879
|
+
return !isForwarder;
|
|
5880
|
+
});
|
|
5881
|
+
if (independentlyUsed) continue;
|
|
5882
|
+
context.report({
|
|
5883
|
+
loc: { line: imported.line, column: 0 },
|
|
5884
|
+
message: `Supporting ${support.kind} "${support.name}" is consumed only with component "${componentName}". Define it in the component file; extract it into a support folder only when consumed independently. See docs/next-codebase-guide/rules/no-mixed-concerns-rule.md`
|
|
5885
|
+
});
|
|
5886
|
+
}
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5832
5889
|
const isNextPageOrLayout = /(?:^|[/\\])src[/\\]app[/\\](?:[^/\\]+[/\\])*(?:page|layout)\.tsx$/.test(
|
|
5833
5890
|
context.filename
|
|
5834
5891
|
);
|