@r_masseater/vite-plus-adopt 0.11.1 → 0.12.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.
- package/README.md +5 -20
- package/THIRD-PARTY-NOTICES +0 -251
- package/dist/attw.mjs +4 -5
- package/dist/attw.mjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +61 -2
- package/dist/index.mjs +1 -1
- package/dist/{vpa-MRYbih3E.mjs → vpa-CvCOW4oL.mjs} +7 -30
- package/dist/vpa-CvCOW4oL.mjs.map +1 -0
- package/package.json +15 -47
- package/skills/configure-checks/SKILL.md +5 -13
- package/dist/fsd.d.mts +0 -10
- package/dist/fsd.mjs +0 -1336
- package/dist/fsd.mjs.map +0 -1
- package/dist/index-DyvYt7R0.d.mts +0 -173
- package/dist/parsers/tree-sitter-astro.wasm +0 -0
- package/dist/parsers/tree-sitter-svelte.wasm +0 -0
- package/dist/parsers/tree-sitter-tsx.wasm +0 -0
- package/dist/parsers/tree-sitter-vue.wasm +0 -0
- package/dist/steiger-CbusAzht.mjs +0 -5944
- package/dist/steiger-CbusAzht.mjs.map +0 -1
- package/dist/vpa-MRYbih3E.mjs.map +0 -1
package/dist/fsd.mjs
DELETED
|
@@ -1,1336 +0,0 @@
|
|
|
1
|
-
import { n as toJson } from "./json-QtVKpodH.mjs";
|
|
2
|
-
import { Option, String, pipe } from "effect";
|
|
3
|
-
import { isBuiltin } from "module";
|
|
4
|
-
import { basename, dirname, extname, join, relative, resolve, sep } from "path";
|
|
5
|
-
import { basename as basename$1, join as join$1, parse, sep as sep$1 } from "node:path";
|
|
6
|
-
import { serverFS } from "typescript/fs";
|
|
7
|
-
import { rootedDirectoryPathFromPath, rootedPathFromNormalized, toRootedDirectoryPath, toRootedFilePath } from "typescript/path";
|
|
8
|
-
import { API } from "typescript/sync";
|
|
9
|
-
import * as fs from "fs";
|
|
10
|
-
import { existsSync, readFileSync, statSync } from "fs";
|
|
11
|
-
import { parse as parse$1 } from "tsconfck";
|
|
12
|
-
import { Language, Parser, Query } from "web-tree-sitter";
|
|
13
|
-
import pluralize from "pluralize";
|
|
14
|
-
import { distance } from "fastest-levenshtein";
|
|
15
|
-
// src/app/fsd-typescript.ts
|
|
16
|
-
const WORKING_DIRECTORY = String.replaceAll("\\", "/")(process.cwd());
|
|
17
|
-
const CWD = rootedDirectoryPathFromPath(rootedPathFromNormalized(WORKING_DIRECTORY));
|
|
18
|
-
const PREFIX = `${CWD}/`;
|
|
19
|
-
const current = {
|
|
20
|
-
host: Option.none(),
|
|
21
|
-
relative: false
|
|
22
|
-
};
|
|
23
|
-
const toCaller = (fileName) => Option.liftPredicate(fileName, (name) => current.relative && String.startsWith(PREFIX)(name)).pipe(Option.match({
|
|
24
|
-
onSome: (name) => String.slice(PREFIX.length)(name),
|
|
25
|
-
onNone: () => fileName
|
|
26
|
-
}));
|
|
27
|
-
const directoryExistsOf = (host, directoryName) => Option.fromNullishOr(host.directoryExists).pipe(Option.match({
|
|
28
|
-
onSome: (directoryExists) => directoryExists(toCaller(directoryName)),
|
|
29
|
-
onNone: () => true
|
|
30
|
-
}));
|
|
31
|
-
const callerFileSystem = {
|
|
32
|
-
fileExists: (fileName) => current.host.pipe(Option.match({
|
|
33
|
-
onSome: (host) => host.fileExists(toCaller(fileName)),
|
|
34
|
-
onNone: () => serverFS.useOS
|
|
35
|
-
})),
|
|
36
|
-
directoryExists: (directoryName) => current.host.pipe(Option.match({
|
|
37
|
-
onSome: (host) => directoryExistsOf(host, directoryName),
|
|
38
|
-
onNone: () => serverFS.useOS
|
|
39
|
-
})),
|
|
40
|
-
getAccessibleEntries: serverFS.useOS,
|
|
41
|
-
readFile: serverFS.useOS,
|
|
42
|
-
realpath: serverFS.useOS,
|
|
43
|
-
stat: serverFS.useOS,
|
|
44
|
-
writeFile: serverFS.useOS,
|
|
45
|
-
removeFile: serverFS.useOS
|
|
46
|
-
};
|
|
47
|
-
const createResolverCache = () => {
|
|
48
|
-
const api = new API({
|
|
49
|
-
cwd: CWD,
|
|
50
|
-
fs: callerFileSystem
|
|
51
|
-
});
|
|
52
|
-
const byOptions = /* @__PURE__ */ new Map();
|
|
53
|
-
return (compilerOptions) => {
|
|
54
|
-
const key = toJson(compilerOptions);
|
|
55
|
-
return byOptions.getOrInsertComputed(key, () => {
|
|
56
|
-
const { options } = api.parseJsonConfigFileContent({ compilerOptions }, { configDirectory: CWD });
|
|
57
|
-
return api.createModuleResolver(options);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
const resolverCache = { value: Option.none() };
|
|
62
|
-
const resolverFor = (compilerOptions) => resolverCache.value.pipe(Option.getOrElse(() => {
|
|
63
|
-
const created = createResolverCache();
|
|
64
|
-
resolverCache.value = Option.some(created);
|
|
65
|
-
return created;
|
|
66
|
-
}))(compilerOptions);
|
|
67
|
-
const resolveModuleName = (...[moduleName, containingFile, compilerOptions, host]) => {
|
|
68
|
-
const containingPath = toRootedFilePath(containingFile, CWD);
|
|
69
|
-
current.host = Option.some(host);
|
|
70
|
-
current.relative = containingPath !== containingFile;
|
|
71
|
-
const { resolvedModule } = resolverFor(compilerOptions).resolveModuleName(moduleName, toRootedDirectoryPath("..", rootedDirectoryPathFromPath(containingPath)));
|
|
72
|
-
return { resolvedModule: pipe(Option.fromNullishOr(resolvedModule), Option.map(({ resolvedFileName }) => ({ resolvedFileName: toCaller(resolvedFileName) })), Option.getOrUndefined) };
|
|
73
|
-
};
|
|
74
|
-
const ts = {
|
|
75
|
-
resolveModuleName,
|
|
76
|
-
sys: {},
|
|
77
|
-
ModuleKind: {},
|
|
78
|
-
ModuleResolutionKind: {},
|
|
79
|
-
ModuleDetectionKind: {},
|
|
80
|
-
NewLineKind: {},
|
|
81
|
-
ScriptTarget: {}
|
|
82
|
-
};
|
|
83
|
-
// ../../node_modules/.pnpm/@feature-sliced+filesystem@3.1.1/node_modules/@feature-sliced/filesystem/dist/index.js
|
|
84
|
-
var layerSequence = [
|
|
85
|
-
"shared",
|
|
86
|
-
"entities",
|
|
87
|
-
"features",
|
|
88
|
-
"widgets",
|
|
89
|
-
"pages",
|
|
90
|
-
"app"
|
|
91
|
-
];
|
|
92
|
-
var unslicedLayers = ["shared", "app"];
|
|
93
|
-
var conventionalSegmentNames = [
|
|
94
|
-
"ui",
|
|
95
|
-
"api",
|
|
96
|
-
"lib",
|
|
97
|
-
"model",
|
|
98
|
-
"config"
|
|
99
|
-
];
|
|
100
|
-
function hasPrefix(path) {
|
|
101
|
-
return /^([0-9]_|_)/.test(path);
|
|
102
|
-
}
|
|
103
|
-
function removePrefix(path) {
|
|
104
|
-
return path.replace(/^([0-9]_|_)/, "");
|
|
105
|
-
}
|
|
106
|
-
function getLayers(fsdRoot) {
|
|
107
|
-
return Object.fromEntries(fsdRoot.children.reduce((acc, child) => {
|
|
108
|
-
if (child.type !== "folder") return acc;
|
|
109
|
-
const name = basename$1(child.path);
|
|
110
|
-
const layer = layerSequence[layerSequence.indexOf(removePrefix(name))];
|
|
111
|
-
if (layer) {
|
|
112
|
-
const existingLayer = acc.find((el) => el[0] === layer);
|
|
113
|
-
if (!existingLayer) acc.push([layer, child]);
|
|
114
|
-
else if (hasPrefix(name) && !hasPrefix(basename$1(existingLayer[1].path))) acc.splice(acc.indexOf(existingLayer), 1, [layer, child]);
|
|
115
|
-
}
|
|
116
|
-
return acc;
|
|
117
|
-
}, []));
|
|
118
|
-
}
|
|
119
|
-
function getSlices(slicedLayer, additionalSegmentNames = []) {
|
|
120
|
-
const slices = {};
|
|
121
|
-
function traverse(folder, pathPrefix = "") {
|
|
122
|
-
if (isSlice(folder, additionalSegmentNames)) slices[join$1(pathPrefix, basename$1(folder.path))] = folder;
|
|
123
|
-
else folder.children.forEach((child) => {
|
|
124
|
-
if (child.type === "folder") traverse(child, join$1(pathPrefix, basename$1(folder.path)));
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
for (const child of slicedLayer.children) if (child.type === "folder") traverse(child);
|
|
128
|
-
return slices;
|
|
129
|
-
}
|
|
130
|
-
function getSegments(sliceOrUnslicedLayer) {
|
|
131
|
-
return Object.fromEntries(sliceOrUnslicedLayer.children.filter((child) => !isIndex(child)).map((child) => [parse(child.path).name, child]));
|
|
132
|
-
}
|
|
133
|
-
function getAllSlices(fsdRoot, additionalSegmentNames = []) {
|
|
134
|
-
return Object.entries(getLayers(fsdRoot)).filter(([, layer]) => isSliced(layer)).reduce((slices, [layerName, layer]) => {
|
|
135
|
-
return {
|
|
136
|
-
...slices,
|
|
137
|
-
...Object.fromEntries(Object.entries(getSlices(layer, additionalSegmentNames)).map(([name, slice]) => [name, {
|
|
138
|
-
...slice,
|
|
139
|
-
layerName
|
|
140
|
-
}]))
|
|
141
|
-
};
|
|
142
|
-
}, {});
|
|
143
|
-
}
|
|
144
|
-
function getAllSegments(fsdRoot) {
|
|
145
|
-
return Object.entries(getLayers(fsdRoot)).flatMap(([layerName, layer]) => {
|
|
146
|
-
if (isSliced(layer)) return Object.entries(getSlices(layer)).flatMap(([sliceName, slice]) => Object.entries(getSegments(slice)).map(([segmentName, segment]) => ({
|
|
147
|
-
segment,
|
|
148
|
-
segmentName,
|
|
149
|
-
sliceName,
|
|
150
|
-
layerName
|
|
151
|
-
})));
|
|
152
|
-
else return Object.entries(getSegments(layer)).map(([segmentName, segment]) => ({
|
|
153
|
-
segment,
|
|
154
|
-
segmentName,
|
|
155
|
-
sliceName: null,
|
|
156
|
-
layerName
|
|
157
|
-
}));
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function isSliced(layerOrName) {
|
|
161
|
-
const name = typeof layerOrName === "string" ? layerOrName : layerOrName.path;
|
|
162
|
-
return !unslicedLayers.includes(removePrefix(basename$1(name)));
|
|
163
|
-
}
|
|
164
|
-
function getIndexes(fileOrFolder) {
|
|
165
|
-
if (fileOrFolder.type === "file") return [fileOrFolder];
|
|
166
|
-
return fileOrFolder.children.filter(isIndex);
|
|
167
|
-
}
|
|
168
|
-
function isIndex(fileOrFolder) {
|
|
169
|
-
if (fileOrFolder.type === "file") return parse(fileOrFolder.path).name.split(".").at(0) === "index";
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
function isCrossImportPublicApi(file, { inSlice, forSlice, layerPath }) {
|
|
173
|
-
const { dir, name } = parse(file.path);
|
|
174
|
-
if (isIndex(file)) return dir === join$1(layerPath, inSlice, "@x", forSlice);
|
|
175
|
-
return name === forSlice && dir === join$1(layerPath, inSlice, "@x");
|
|
176
|
-
}
|
|
177
|
-
function isSlice(folder, additionalSegmentNames = []) {
|
|
178
|
-
return folder.children.some((child) => conventionalSegmentNames.concat(additionalSegmentNames).includes(parse(child.path).name));
|
|
179
|
-
}
|
|
180
|
-
function resolveImport(importedPath, importerPath, tsCompilerOptions, fileExists, directoryExists) {
|
|
181
|
-
return ts.resolveModuleName(importedPath, importerPath, normalizeCompilerOptions(tsCompilerOptions), {
|
|
182
|
-
...ts.sys,
|
|
183
|
-
fileExists,
|
|
184
|
-
directoryExists
|
|
185
|
-
}).resolvedModule?.resolvedFileName?.replaceAll("/", sep$1) ?? null;
|
|
186
|
-
}
|
|
187
|
-
var imperfectKeys = {
|
|
188
|
-
module: ts.ModuleKind,
|
|
189
|
-
moduleResolution: {
|
|
190
|
-
...ts.ModuleResolutionKind,
|
|
191
|
-
node: ts.ModuleResolutionKind.Node10
|
|
192
|
-
},
|
|
193
|
-
moduleDetection: ts.ModuleDetectionKind,
|
|
194
|
-
newLine: ts.NewLineKind,
|
|
195
|
-
target: ts.ScriptTarget
|
|
196
|
-
};
|
|
197
|
-
function normalizeCompilerOptions(compilerOptions) {
|
|
198
|
-
return Object.fromEntries(Object.entries(compilerOptions).map(([key, value]) => {
|
|
199
|
-
if (Object.keys(imperfectKeys).includes(key) && typeof value === "string") {
|
|
200
|
-
for (const [enumKey, enumValue] of Object.entries(imperfectKeys[key])) if (enumKey.toLowerCase() === value.toLowerCase()) return [key, enumValue];
|
|
201
|
-
}
|
|
202
|
-
return [key, value];
|
|
203
|
-
}));
|
|
204
|
-
}
|
|
205
|
-
// ../../node_modules/.pnpm/@feature-sliced+steiger-plugin@0.8.2_typescript@7.1.0-beta/node_modules/@feature-sliced/steiger-plugin/dist/index.js
|
|
206
|
-
function findAllRecursively(folder, predicate) {
|
|
207
|
-
const result = [];
|
|
208
|
-
function walk(entry) {
|
|
209
|
-
if (predicate(entry)) result.push(entry);
|
|
210
|
-
if (entry.type === "folder") for (const child of entry.children) walk(child);
|
|
211
|
-
}
|
|
212
|
-
walk(folder);
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
|
-
function enableSpecificRules(plugin2, rulesToEnable, options) {
|
|
216
|
-
const namesOfRulesToEnable = rulesToEnable.map((ruleToEnable) => ruleToEnable.name);
|
|
217
|
-
return [plugin2, { rules: Object.fromEntries(plugin2.ruleDefinitions.filter((rule) => namesOfRulesToEnable.includes(rule.name)).map((rule) => [rule.name, "error"])) }];
|
|
218
|
-
}
|
|
219
|
-
function createConfigs(configs2) {
|
|
220
|
-
return configs2;
|
|
221
|
-
}
|
|
222
|
-
function createPlugin(plugin2) {
|
|
223
|
-
return plugin2;
|
|
224
|
-
}
|
|
225
|
-
var NAMESPACE = "fsd";
|
|
226
|
-
var ambiguous_slice_names_default = {
|
|
227
|
-
name: `${NAMESPACE}/ambiguous-slice-names`,
|
|
228
|
-
check(root) {
|
|
229
|
-
const diagnostics = [];
|
|
230
|
-
const layers = getLayers(root);
|
|
231
|
-
const sharedLayer = layers.shared;
|
|
232
|
-
if (sharedLayer === void 0) return { diagnostics };
|
|
233
|
-
const segmentNamesInShared = Object.keys(getSegments(sharedLayer));
|
|
234
|
-
for (const [sliceName, slice] of Object.entries(getAllSlices(root))) {
|
|
235
|
-
const pathSegments = sliceName.split(sep);
|
|
236
|
-
const matchingSegment = segmentNamesInShared.find((segmentName) => pathSegments.includes(segmentName));
|
|
237
|
-
if (matchingSegment === void 0) continue;
|
|
238
|
-
if (matchingSegment === sliceName) {
|
|
239
|
-
diagnostics.push({
|
|
240
|
-
message: `Slice "${sliceName}" could be confused with a segment from Shared with the same name`,
|
|
241
|
-
location: { path: slice.path }
|
|
242
|
-
});
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
const segmentIndex = pathSegments.indexOf(matchingSegment);
|
|
246
|
-
if (!(segmentIndex < pathSegments.length - 1)) diagnostics.push({
|
|
247
|
-
message: `Slice "${sliceName}" could be confused with a segment "${matchingSegment}" from Shared`,
|
|
248
|
-
location: { path: slice.path }
|
|
249
|
-
});
|
|
250
|
-
else {
|
|
251
|
-
const layer = layers[slice.layerName];
|
|
252
|
-
if (layer === void 0) continue;
|
|
253
|
-
const pathSegmentsToGroup = pathSegments.slice(0, segmentIndex + 1);
|
|
254
|
-
const group = pathSegmentsToGroup.reduce((folder, segmentName) => folder?.children.find((child) => child.type === "folder" && basename(child.path) === segmentName), layer);
|
|
255
|
-
if (group !== void 0) diagnostics.push({
|
|
256
|
-
message: `Slice group "${pathSegmentsToGroup.join(sep)}" could be confused with a segment "${matchingSegment}" from Shared`,
|
|
257
|
-
location: { path: group.path }
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return { diagnostics };
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
function groupSlices(sliceNames) {
|
|
265
|
-
const groups = {};
|
|
266
|
-
for (const sliceName of sliceNames) {
|
|
267
|
-
const segments = sliceName.split(sep);
|
|
268
|
-
const name = segments.pop();
|
|
269
|
-
const group = segments.join(sep);
|
|
270
|
-
if (name !== void 0) {
|
|
271
|
-
groups[group] ??= [];
|
|
272
|
-
groups[group].push(name);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return groups;
|
|
276
|
-
}
|
|
277
|
-
var THRESHOLDS = {
|
|
278
|
-
entities: 20,
|
|
279
|
-
features: 20,
|
|
280
|
-
widgets: 20,
|
|
281
|
-
pages: 20
|
|
282
|
-
};
|
|
283
|
-
var excessive_slicing_default = {
|
|
284
|
-
name: `${NAMESPACE}/excessive-slicing`,
|
|
285
|
-
check(root) {
|
|
286
|
-
const diagnostics = [];
|
|
287
|
-
for (const [layerName, layer] of Object.entries(getLayers(root))) {
|
|
288
|
-
if (!isSliced(layer) || !(layerName in THRESHOLDS)) continue;
|
|
289
|
-
const sliceGroups = groupSlices(Object.keys(getSlices(layer)));
|
|
290
|
-
const threshold = THRESHOLDS[layerName];
|
|
291
|
-
for (const [group, slices] of Object.entries(sliceGroups)) {
|
|
292
|
-
if (slices.length <= threshold) continue;
|
|
293
|
-
if (group === "") diagnostics.push({
|
|
294
|
-
message: `Layer "${layerName}" has ${slices.length} ungrouped slices, which is above the recommended threshold of ${threshold}. Consider grouping them or moving the code inside to the layer where it's used.`,
|
|
295
|
-
location: { path: layer.path }
|
|
296
|
-
});
|
|
297
|
-
else diagnostics.push({
|
|
298
|
-
message: `Slice group "${group}" has ${slices.length} slices, which is above the recommended threshold of ${threshold}. Consider grouping them or moving the code inside to the layer where it's used.`,
|
|
299
|
-
location: { path: join(layer.path, group) }
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return { diagnostics };
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
function indexSourceFiles(root) {
|
|
307
|
-
const index = {};
|
|
308
|
-
function walk(node, metadata) {
|
|
309
|
-
if (node.type === "file") index[node.path] = {
|
|
310
|
-
...metadata,
|
|
311
|
-
file: node
|
|
312
|
-
};
|
|
313
|
-
else for (const child of node.children) walk(child, metadata);
|
|
314
|
-
}
|
|
315
|
-
for (const [layerName, layer] of Object.entries(getLayers(root))) {
|
|
316
|
-
layer.children.filter((child) => child.type === "file").forEach((file) => walk(file, {
|
|
317
|
-
layerName,
|
|
318
|
-
layerPath: layer.path,
|
|
319
|
-
sliceName: null,
|
|
320
|
-
segmentName: null
|
|
321
|
-
}));
|
|
322
|
-
if (!isSliced(layer)) for (const [segmentName, segment] of Object.entries(getSegments(layer))) walk(segment, {
|
|
323
|
-
layerName,
|
|
324
|
-
layerPath: layer.path,
|
|
325
|
-
sliceName: null,
|
|
326
|
-
segmentName
|
|
327
|
-
});
|
|
328
|
-
else for (const [sliceName, slice] of Object.entries(getSlices(layer))) {
|
|
329
|
-
for (const [segmentName, segment] of Object.entries(getSegments(slice))) walk(segment, {
|
|
330
|
-
layerName,
|
|
331
|
-
layerPath: layer.path,
|
|
332
|
-
sliceName,
|
|
333
|
-
segmentName
|
|
334
|
-
});
|
|
335
|
-
const indexes = getIndexes(slice);
|
|
336
|
-
for (const index2 of indexes) walk(index2, {
|
|
337
|
-
layerName,
|
|
338
|
-
layerPath: layer.path,
|
|
339
|
-
sliceName,
|
|
340
|
-
segmentName: null
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return index;
|
|
345
|
-
}
|
|
346
|
-
function collectRelatedTsConfigs(payload) {
|
|
347
|
-
const configs2 = [];
|
|
348
|
-
const setTsConfigs = ({ tsconfig, tsconfigFile, referenced, extended }) => {
|
|
349
|
-
configs2.push(resolveRelativePathsInMergedConfig({
|
|
350
|
-
tsconfig,
|
|
351
|
-
tsconfigFile,
|
|
352
|
-
extended
|
|
353
|
-
}));
|
|
354
|
-
referenced?.forEach(setTsConfigs);
|
|
355
|
-
};
|
|
356
|
-
setTsConfigs(payload);
|
|
357
|
-
return configs2;
|
|
358
|
-
}
|
|
359
|
-
function resolveRelativePathsInMergedConfig(configParseResult) {
|
|
360
|
-
const { tsconfig: mergedConfig, extended } = configParseResult;
|
|
361
|
-
if (!mergedConfig || !mergedConfig.compilerOptions || !mergedConfig.compilerOptions.paths) return mergedConfig;
|
|
362
|
-
const absolutePaths = makeRelativePathAliasesAbsolute(configParseResult, findFirstConfigWithPaths(extended || []) || configParseResult);
|
|
363
|
-
return {
|
|
364
|
-
...mergedConfig,
|
|
365
|
-
compilerOptions: {
|
|
366
|
-
...mergedConfig.compilerOptions,
|
|
367
|
-
paths: absolutePaths
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function findFirstConfigWithPaths(extended) {
|
|
372
|
-
for (const parseResult of extended) {
|
|
373
|
-
const { tsconfig } = parseResult;
|
|
374
|
-
if (tsconfig.compilerOptions?.paths) return parseResult;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
function makeRelativePathAliasesAbsolute(finalConfig, firstConfigWithPaths) {
|
|
378
|
-
const { tsconfig: mergedConfig } = finalConfig;
|
|
379
|
-
const { compilerOptions: { paths, baseUrl } } = mergedConfig;
|
|
380
|
-
const absolutePaths = {};
|
|
381
|
-
if (!firstConfigWithPaths.tsconfigFile) return mergedConfig.compilerOptions.paths;
|
|
382
|
-
for (const entries of Object.entries(paths)) {
|
|
383
|
-
const [key, paths2] = entries;
|
|
384
|
-
absolutePaths[key] = paths2.map((relativePath) => baseUrl ? resolve(dirname(firstConfigWithPaths.tsconfigFile), baseUrl, relativePath) : resolve(dirname(firstConfigWithPaths.tsconfigFile), relativePath));
|
|
385
|
-
}
|
|
386
|
-
return absolutePaths;
|
|
387
|
-
}
|
|
388
|
-
function createFSCache() {
|
|
389
|
-
const cache = /* @__PURE__ */ new Map();
|
|
390
|
-
function has(key, mtimeSourcePath = key) {
|
|
391
|
-
const data = cache.get(key);
|
|
392
|
-
if (data === void 0) return false;
|
|
393
|
-
return data.mtime === statSync(mtimeSourcePath, { throwIfNoEntry: false })?.mtimeMs;
|
|
394
|
-
}
|
|
395
|
-
function get(key, mtimeSourcePath = key) {
|
|
396
|
-
if (!has(key, mtimeSourcePath)) return void 0;
|
|
397
|
-
return cache.get(key).value;
|
|
398
|
-
}
|
|
399
|
-
function set(key, value, mtimeSourcePath = key) {
|
|
400
|
-
const mtime = statSync(mtimeSourcePath, { throwIfNoEntry: false })?.mtimeMs;
|
|
401
|
-
if (mtime === void 0) return;
|
|
402
|
-
cache.set(key, {
|
|
403
|
-
mtime,
|
|
404
|
-
value
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
return {
|
|
408
|
-
has,
|
|
409
|
-
get,
|
|
410
|
-
set
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
var resolutionCache = createFSCache();
|
|
414
|
-
function resolveDependency(importedPath, importerPath, tsConfigs, fileExists = existsSync, directoryExists = existsSync) {
|
|
415
|
-
const useCache = fileExists === existsSync;
|
|
416
|
-
if (useCache) {
|
|
417
|
-
const cached = resolutionCache.get(`${importerPath}\0${importedPath}`, importerPath);
|
|
418
|
-
if (cached !== void 0) return cached;
|
|
419
|
-
}
|
|
420
|
-
let resolvedDependency = null;
|
|
421
|
-
for (const config of tsConfigs) {
|
|
422
|
-
resolvedDependency = resolveImport(importedPath, importerPath, config?.compilerOptions ?? {}, fileExists, directoryExists);
|
|
423
|
-
if (resolvedDependency !== null) break;
|
|
424
|
-
}
|
|
425
|
-
if (useCache) resolutionCache.set(`${importerPath}\0${importedPath}`, resolvedDependency, importerPath);
|
|
426
|
-
return resolvedDependency;
|
|
427
|
-
}
|
|
428
|
-
var parserDirectory = import.meta.dirname;
|
|
429
|
-
await Parser.init();
|
|
430
|
-
var parserPaths = [
|
|
431
|
-
join(parserDirectory, "parsers", "tree-sitter-tsx.wasm"),
|
|
432
|
-
join(parserDirectory, "parsers", "tree-sitter-svelte.wasm"),
|
|
433
|
-
join(parserDirectory, "parsers", "tree-sitter-astro.wasm"),
|
|
434
|
-
join(parserDirectory, "parsers", "tree-sitter-vue.wasm")
|
|
435
|
-
];
|
|
436
|
-
var tsx;
|
|
437
|
-
var svelte;
|
|
438
|
-
var astro;
|
|
439
|
-
var vue;
|
|
440
|
-
try {
|
|
441
|
-
[tsx, svelte, astro, vue] = await Promise.all(parserPaths.map((path) => Language.load(path)));
|
|
442
|
-
} catch (parallelError) {
|
|
443
|
-
console.error("@feature-sliced/steiger-plugin: recovered from a known Node.js 20 bug while loading tree-sitter parsers in parallel. Loading them sequentially instead. Set DEBUG=1 for the full error.");
|
|
444
|
-
if (process.env.DEBUG) console.error(parallelError);
|
|
445
|
-
tsx = await Language.load(parserPaths[0]);
|
|
446
|
-
svelte = await Language.load(parserPaths[1]);
|
|
447
|
-
astro = await Language.load(parserPaths[2]);
|
|
448
|
-
vue = await Language.load(parserPaths[3]);
|
|
449
|
-
}
|
|
450
|
-
var extractors = [
|
|
451
|
-
{
|
|
452
|
-
type: "tsx",
|
|
453
|
-
extensions: [
|
|
454
|
-
".tsx",
|
|
455
|
-
".jsx",
|
|
456
|
-
".ts",
|
|
457
|
-
".js",
|
|
458
|
-
".cjs",
|
|
459
|
-
".mjs"
|
|
460
|
-
],
|
|
461
|
-
language: tsx,
|
|
462
|
-
queries: [
|
|
463
|
-
{
|
|
464
|
-
query: new Query(tsx, "(import_statement source: (string (string_fragment) @source)) @statement"),
|
|
465
|
-
type: "static"
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
query: new Query(tsx, `(program
|
|
469
|
-
(lexical_declaration
|
|
470
|
-
(variable_declarator
|
|
471
|
-
value: (call_expression
|
|
472
|
-
function: (identifier) @function.name (#eq? @function.name "require")
|
|
473
|
-
arguments: (arguments (string (string_fragment) @source)))) @statement))`),
|
|
474
|
-
type: "static"
|
|
475
|
-
},
|
|
476
|
-
{
|
|
477
|
-
query: new Query(tsx, `(call_expression
|
|
478
|
-
function: (import)
|
|
479
|
-
arguments: (arguments (string (string_fragment) @source))) @statement`),
|
|
480
|
-
type: "dynamic"
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
query: new Query(tsx, `(program
|
|
484
|
-
(expression_statement
|
|
485
|
-
(call_expression
|
|
486
|
-
function: (identifier) @function.name (#eq? @function.name "require")
|
|
487
|
-
arguments: (arguments (string (string_fragment) @source)))) @statement)
|
|
488
|
-
`),
|
|
489
|
-
type: "dynamic"
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
query: new Query(tsx, "(export_statement source: (string (string_fragment) @source)) @statement"),
|
|
493
|
-
type: "re-export"
|
|
494
|
-
}
|
|
495
|
-
],
|
|
496
|
-
injections: []
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
type: "svelte",
|
|
500
|
-
extensions: [".svelte"],
|
|
501
|
-
language: svelte,
|
|
502
|
-
queries: [],
|
|
503
|
-
injections: [{
|
|
504
|
-
query: new Query(svelte, "(script_element (raw_text) @tsx)"),
|
|
505
|
-
lang: "tsx"
|
|
506
|
-
}]
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
type: "astro",
|
|
510
|
-
extensions: [".astro"],
|
|
511
|
-
language: astro,
|
|
512
|
-
queries: [],
|
|
513
|
-
injections: [{
|
|
514
|
-
query: new Query(astro, "(frontmatter_js_block) @tsx"),
|
|
515
|
-
lang: "tsx"
|
|
516
|
-
}]
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
type: "vue",
|
|
520
|
-
extensions: [".vue"],
|
|
521
|
-
language: vue,
|
|
522
|
-
queries: [],
|
|
523
|
-
injections: [{
|
|
524
|
-
query: new Query(vue, "(document (script_element (raw_text) @tsx))"),
|
|
525
|
-
lang: "tsx"
|
|
526
|
-
}]
|
|
527
|
-
}
|
|
528
|
-
];
|
|
529
|
-
function getSourceType(sourcePath) {
|
|
530
|
-
const extension = extname(sourcePath);
|
|
531
|
-
for (const extractor of extractors) if (extractor.extensions.includes(extension)) return extractor.type;
|
|
532
|
-
}
|
|
533
|
-
function rangeOf(node) {
|
|
534
|
-
return {
|
|
535
|
-
start: {
|
|
536
|
-
line: node.startPosition.row + 1,
|
|
537
|
-
column: node.startPosition.column + 1
|
|
538
|
-
},
|
|
539
|
-
end: {
|
|
540
|
-
line: node.endPosition.row + 1,
|
|
541
|
-
column: node.endPosition.column + 1
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
function reExportKind(statement) {
|
|
546
|
-
for (const child of statement.children) {
|
|
547
|
-
if (child.type === "namespace_export") return "namespace";
|
|
548
|
-
if (child.type === "export_clause") return "named";
|
|
549
|
-
if (child.type === "*") return "wildcard";
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
function collectStatements(extractor, tree) {
|
|
553
|
-
const result = [];
|
|
554
|
-
for (const { query, type } of extractor.queries) for (const match of query.matches(tree.rootNode)) {
|
|
555
|
-
const captures = new Map(match.captures.map((capture) => [capture.name, capture.node]));
|
|
556
|
-
const statement = captures.get("statement");
|
|
557
|
-
const source = captures.get("source");
|
|
558
|
-
if (statement === void 0 || source === void 0) continue;
|
|
559
|
-
const common = {
|
|
560
|
-
source: source.text,
|
|
561
|
-
builtIn: isBuiltin(source.text),
|
|
562
|
-
sourceRange: rangeOf(source),
|
|
563
|
-
statementRange: rangeOf(statement)
|
|
564
|
-
};
|
|
565
|
-
if (type === "re-export") {
|
|
566
|
-
const kind = reExportKind(statement);
|
|
567
|
-
if (kind === void 0) continue;
|
|
568
|
-
result.push({
|
|
569
|
-
type: "re-export",
|
|
570
|
-
kind,
|
|
571
|
-
...common
|
|
572
|
-
});
|
|
573
|
-
} else result.push({
|
|
574
|
-
type: "import",
|
|
575
|
-
dynamic: type === "dynamic",
|
|
576
|
-
...common
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
return result;
|
|
580
|
-
}
|
|
581
|
-
function forEachSyntaxTree(path, visit) {
|
|
582
|
-
const extension = extname(path);
|
|
583
|
-
const extractor = extractors.find((extractor2) => extractor2.extensions.includes(extension));
|
|
584
|
-
if (!extractor) throw new Error(`No extractor found for "${extension}"`);
|
|
585
|
-
const sourceCode = readFileSync(path, "utf8");
|
|
586
|
-
const parser = new Parser();
|
|
587
|
-
parser.setLanguage(extractor.language);
|
|
588
|
-
const tree = parser.parse(sourceCode);
|
|
589
|
-
if (tree === null) return;
|
|
590
|
-
visit(extractor, tree);
|
|
591
|
-
for (const { query, lang } of extractor.injections) {
|
|
592
|
-
const injectedExtractor = extractors.find((extractor2) => extractor2.type === lang);
|
|
593
|
-
if (!injectedExtractor) throw new Error(`No extractor found for "${lang}"`);
|
|
594
|
-
const matches = query.matches(tree.rootNode);
|
|
595
|
-
const includedRanges = [];
|
|
596
|
-
for (const match of matches) for (const capture of match.captures) if (capture.name === lang) includedRanges.push({
|
|
597
|
-
startIndex: capture.node.startIndex,
|
|
598
|
-
endIndex: capture.node.endIndex,
|
|
599
|
-
startPosition: capture.node.startPosition,
|
|
600
|
-
endPosition: capture.node.endPosition
|
|
601
|
-
});
|
|
602
|
-
parser.setLanguage(injectedExtractor.language);
|
|
603
|
-
const injectedTree = parser.parse(sourceCode, null, { includedRanges });
|
|
604
|
-
if (injectedTree === null) continue;
|
|
605
|
-
visit(injectedExtractor, injectedTree);
|
|
606
|
-
injectedTree.delete();
|
|
607
|
-
}
|
|
608
|
-
tree.delete();
|
|
609
|
-
}
|
|
610
|
-
function comparePositions(a, b) {
|
|
611
|
-
return a.start.line - b.start.line || a.start.column - b.start.column;
|
|
612
|
-
}
|
|
613
|
-
function analyzeSourceFile(path) {
|
|
614
|
-
const statements = [];
|
|
615
|
-
forEachSyntaxTree(path, (extractor, tree) => {
|
|
616
|
-
statements.push(...collectStatements(extractor, tree));
|
|
617
|
-
});
|
|
618
|
-
statements.sort((a, b) => comparePositions(a.statementRange, b.statementRange));
|
|
619
|
-
return { statements };
|
|
620
|
-
}
|
|
621
|
-
var moduleAnalysisCache = createFSCache();
|
|
622
|
-
async function analyzeModule(path) {
|
|
623
|
-
let analysis = moduleAnalysisCache.get(path);
|
|
624
|
-
if (!analysis) {
|
|
625
|
-
analysis = analyzeSourceFile(path);
|
|
626
|
-
moduleAnalysisCache.set(path, analysis);
|
|
627
|
-
}
|
|
628
|
-
return analysis;
|
|
629
|
-
}
|
|
630
|
-
async function extractDependencies(path, options) {
|
|
631
|
-
const { statements } = await analyzeModule(path);
|
|
632
|
-
const result = [];
|
|
633
|
-
for (const statement of statements) {
|
|
634
|
-
if (statement.type === "re-export") {
|
|
635
|
-
if (statement.builtIn === true && true) continue;
|
|
636
|
-
result.push({
|
|
637
|
-
path: statement.source,
|
|
638
|
-
builtIn: statement.builtIn,
|
|
639
|
-
dynamic: false,
|
|
640
|
-
start: statement.sourceRange.start,
|
|
641
|
-
end: statement.sourceRange.end
|
|
642
|
-
});
|
|
643
|
-
continue;
|
|
644
|
-
}
|
|
645
|
-
if (statement.type === "import") {
|
|
646
|
-
if (statement.builtIn === true) continue;
|
|
647
|
-
result.push({
|
|
648
|
-
path: statement.source,
|
|
649
|
-
builtIn: statement.builtIn,
|
|
650
|
-
dynamic: statement.dynamic,
|
|
651
|
-
start: statement.sourceRange.start,
|
|
652
|
-
end: statement.sourceRange.end
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
return result;
|
|
657
|
-
}
|
|
658
|
-
async function extractReExports(path) {
|
|
659
|
-
const { statements } = await analyzeModule(path);
|
|
660
|
-
return statements.filter((statement) => statement.type === "re-export");
|
|
661
|
-
}
|
|
662
|
-
var forbidden_imports_default = {
|
|
663
|
-
name: `${NAMESPACE}/forbidden-imports`,
|
|
664
|
-
async check(root) {
|
|
665
|
-
const diagnostics = [];
|
|
666
|
-
const tsConfigs = collectRelatedTsConfigs(await parse$1(root.children[0]?.path ?? root.path));
|
|
667
|
-
const sourceFileIndex = indexSourceFiles(root);
|
|
668
|
-
for (const sourceFile of Object.values(sourceFileIndex)) {
|
|
669
|
-
if (!getSourceType(sourceFile.file.path)) continue;
|
|
670
|
-
const dependencies = await extractDependencies(sourceFile.file.path);
|
|
671
|
-
for (const dependency of dependencies) {
|
|
672
|
-
const resolvedDependency = resolveDependency(dependency.path, sourceFile.file.path, tsConfigs, fs.existsSync, fs.existsSync);
|
|
673
|
-
if (resolvedDependency === null) continue;
|
|
674
|
-
const dependencyLocation = sourceFileIndex[resolvedDependency];
|
|
675
|
-
if (dependencyLocation === void 0) continue;
|
|
676
|
-
if (sourceFile.layerName === dependencyLocation.layerName && sourceFile.sliceName !== dependencyLocation.sliceName) {
|
|
677
|
-
if (dependencyLocation.sliceName !== null && sourceFile.sliceName !== null && !isCrossImportPublicApi(dependencyLocation.file, {
|
|
678
|
-
inSlice: dependencyLocation.sliceName,
|
|
679
|
-
forSlice: sourceFile.sliceName,
|
|
680
|
-
layerPath: dependencyLocation.layerPath
|
|
681
|
-
})) diagnostics.push({
|
|
682
|
-
message: `Forbidden cross-import from slice "${dependencyLocation.sliceName}".`,
|
|
683
|
-
location: {
|
|
684
|
-
path: sourceFile.file.path,
|
|
685
|
-
start: dependency.start,
|
|
686
|
-
end: dependency.end
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
} else if (layerSequence.indexOf(sourceFile.layerName) < layerSequence.indexOf(dependencyLocation.layerName)) diagnostics.push({
|
|
690
|
-
message: `Forbidden import from higher layer "${dependencyLocation.layerName}".`,
|
|
691
|
-
location: {
|
|
692
|
-
path: sourceFile.file.path,
|
|
693
|
-
start: dependency.start,
|
|
694
|
-
end: dependency.end
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return { diagnostics };
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
|
-
var { isPlural, plural, singular } = pluralize;
|
|
703
|
-
var neutralWords = /* @__PURE__ */ new Set([
|
|
704
|
-
"k8s",
|
|
705
|
-
"kubernetes",
|
|
706
|
-
"media"
|
|
707
|
-
]);
|
|
708
|
-
var inconsistent_naming_default = {
|
|
709
|
-
name: `${NAMESPACE}/inconsistent-naming`,
|
|
710
|
-
check(root) {
|
|
711
|
-
const diagnostics = [];
|
|
712
|
-
const { entities } = getLayers(root);
|
|
713
|
-
if (entities === void 0) return { diagnostics };
|
|
714
|
-
const slices = getSlices(entities);
|
|
715
|
-
const sliceNames = groupSlices(Object.keys(slices));
|
|
716
|
-
for (const [groupPrefix, group] of Object.entries(sliceNames)) {
|
|
717
|
-
const namesToCheck = group.filter((g) => !isNeutralWord(g));
|
|
718
|
-
const pluralNames = [];
|
|
719
|
-
const singularNames = [];
|
|
720
|
-
for (const name of namesToCheck) if (isPlural(name)) pluralNames.push(name);
|
|
721
|
-
else singularNames.push(name);
|
|
722
|
-
if (pluralNames.length > 0 && singularNames.length > 0) {
|
|
723
|
-
const message = "Inconsistent pluralization of slice names";
|
|
724
|
-
if (pluralNames.length >= singularNames.length) diagnostics.push({
|
|
725
|
-
message: `${message}. Prefer all plural names`,
|
|
726
|
-
fixes: singularNames.map((name) => ({
|
|
727
|
-
type: "rename",
|
|
728
|
-
path: join(entities.path, groupPrefix, name),
|
|
729
|
-
newName: plural(name)
|
|
730
|
-
})),
|
|
731
|
-
location: { path: join(entities.path, groupPrefix) }
|
|
732
|
-
});
|
|
733
|
-
else diagnostics.push({
|
|
734
|
-
message: `${message}. Prefer all singular names`,
|
|
735
|
-
fixes: pluralNames.map((name) => ({
|
|
736
|
-
type: "rename",
|
|
737
|
-
path: join(entities.path, groupPrefix, name),
|
|
738
|
-
newName: singular(name)
|
|
739
|
-
})),
|
|
740
|
-
location: { path: join(entities.path, groupPrefix) }
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return { diagnostics };
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
function isNeutralWord(name) {
|
|
748
|
-
return neutralWords.has(name.toLowerCase());
|
|
749
|
-
}
|
|
750
|
-
var insignificant_slice_default = {
|
|
751
|
-
name: `${NAMESPACE}/insignificant-slice`,
|
|
752
|
-
async check(root) {
|
|
753
|
-
const diagnostics = [];
|
|
754
|
-
const references = await traceSliceReferences(root);
|
|
755
|
-
for (const [sourceLocationKey, targetLocationKeys] of references) {
|
|
756
|
-
const [sourceLayerName] = sourceLocationKey.split(sep, 2);
|
|
757
|
-
if (!isSliced(sourceLayerName) || sourceLayerName === "pages") continue;
|
|
758
|
-
if (targetLocationKeys.size === 1) {
|
|
759
|
-
const referenceLocationKey = [...targetLocationKeys][0];
|
|
760
|
-
if (unslicedLayers.includes(referenceLocationKey)) {
|
|
761
|
-
if (referenceLocationKey !== "app") diagnostics.push({
|
|
762
|
-
message: `This slice has only one reference on layer "${referenceLocationKey}". Consider moving this code to "${referenceLocationKey}".`,
|
|
763
|
-
location: { path: join(root.path, sourceLocationKey) }
|
|
764
|
-
});
|
|
765
|
-
} else diagnostics.push({
|
|
766
|
-
message: `This slice has only one reference in slice "${referenceLocationKey}". Consider merging them.`,
|
|
767
|
-
location: { path: join(root.path, sourceLocationKey) }
|
|
768
|
-
});
|
|
769
|
-
} else if (targetLocationKeys.size === 0) diagnostics.push({
|
|
770
|
-
message: `This slice has no references. Consider removing it.`,
|
|
771
|
-
location: { path: join(root.path, sourceLocationKey) }
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
return { diagnostics };
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
async function traceSliceReferences(root) {
|
|
778
|
-
const sourceFileIndex = indexSourceFiles(root);
|
|
779
|
-
const tsConfigs = collectRelatedTsConfigs(await parse$1(root.children[0]?.path ?? root.path));
|
|
780
|
-
const references = /* @__PURE__ */ new Map();
|
|
781
|
-
for (const sourceFile of Object.values(sourceFileIndex)) {
|
|
782
|
-
const thisFileLocationKey = [sourceFile.layerName, sourceFile.sliceName].filter(Boolean).join(sep);
|
|
783
|
-
if (!getSourceType(sourceFile.file.path)) continue;
|
|
784
|
-
const dependencies = await extractDependencies(sourceFile.file.path);
|
|
785
|
-
for (const dependency of dependencies) {
|
|
786
|
-
const resolvedDependency = resolveDependency(dependency.path, sourceFile.file.path, tsConfigs, fs.existsSync, fs.existsSync);
|
|
787
|
-
if (resolvedDependency === null) continue;
|
|
788
|
-
const dependencyLocation = sourceFileIndex[resolvedDependency];
|
|
789
|
-
if (dependencyLocation === void 0 || sourceFile.layerName === dependencyLocation.layerName) continue;
|
|
790
|
-
const dependencyLocationKey = [dependencyLocation.layerName, dependencyLocation.sliceName].filter(Boolean).join(sep);
|
|
791
|
-
if (thisFileLocationKey !== dependencyLocationKey) {
|
|
792
|
-
if (!references.has(dependencyLocationKey)) references.set(dependencyLocationKey, /* @__PURE__ */ new Set());
|
|
793
|
-
references.get(dependencyLocationKey)?.add(thisFileLocationKey);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
if (!references.has(thisFileLocationKey)) references.set(thisFileLocationKey, /* @__PURE__ */ new Set());
|
|
797
|
-
}
|
|
798
|
-
return references;
|
|
799
|
-
}
|
|
800
|
-
var exceptionLayers = ["app"];
|
|
801
|
-
var no_layer_public_api_default = {
|
|
802
|
-
name: `${NAMESPACE}/no-layer-public-api`,
|
|
803
|
-
check(root) {
|
|
804
|
-
const diagnostics = [];
|
|
805
|
-
for (const [layerName, layer] of Object.entries(getLayers(root))) {
|
|
806
|
-
const indexes = getIndexes(layer);
|
|
807
|
-
if (!exceptionLayers.includes(layerName)) for (const index of indexes) diagnostics.push({
|
|
808
|
-
message: `Layer "${layerName}" should not have an index file`,
|
|
809
|
-
location: { path: index.path }
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
return { diagnostics };
|
|
813
|
-
}
|
|
814
|
-
};
|
|
815
|
-
var no_public_api_sidestep_default = {
|
|
816
|
-
name: `${NAMESPACE}/no-public-api-sidestep`,
|
|
817
|
-
async check(root) {
|
|
818
|
-
const diagnostics = [];
|
|
819
|
-
const tsConfigs = collectRelatedTsConfigs(await parse$1(root.children[0]?.path ?? root.path));
|
|
820
|
-
const sourceFileIndex = indexSourceFiles(root);
|
|
821
|
-
for (const sourceFile of Object.values(sourceFileIndex)) {
|
|
822
|
-
if (!getSourceType(sourceFile.file.path)) continue;
|
|
823
|
-
const dependencies = await extractDependencies(sourceFile.file.path);
|
|
824
|
-
for (const dependency of dependencies) {
|
|
825
|
-
const resolvedDependency = resolveDependency(dependency.path, sourceFile.file.path, tsConfigs, fs.existsSync, fs.existsSync);
|
|
826
|
-
if (resolvedDependency === null) continue;
|
|
827
|
-
const dependencyLocation = sourceFileIndex[resolvedDependency];
|
|
828
|
-
if (dependencyLocation === void 0) continue;
|
|
829
|
-
if (sourceFile.layerName === dependencyLocation.layerName && (!isSliced(dependencyLocation.layerName) || sourceFile.sliceName === dependencyLocation.sliceName)) continue;
|
|
830
|
-
if (isSliced(dependencyLocation.layerName)) {
|
|
831
|
-
if (dependencyLocation.segmentName !== null && dependencyLocation.segmentName !== "@x") diagnostics.push({
|
|
832
|
-
message: `Forbidden sidestep of public API when importing from "${dependency.path}".`,
|
|
833
|
-
location: {
|
|
834
|
-
path: sourceFile.file.path,
|
|
835
|
-
start: dependency.start,
|
|
836
|
-
end: dependency.end
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
} else if (dependencyLocation.segmentName !== null) {
|
|
840
|
-
const layer = getLayers(root)[dependencyLocation.layerName];
|
|
841
|
-
if (layer === void 0) continue;
|
|
842
|
-
const segment = getSegments(layer)[dependencyLocation.segmentName];
|
|
843
|
-
if (segment === void 0) continue;
|
|
844
|
-
const segmentIndexes = getIndexes(segment);
|
|
845
|
-
if (segment.type === "folder" && !segmentIndexes.map((segmentIndex) => segmentIndex.path).includes(resolvedDependency)) {
|
|
846
|
-
const { layerName, segmentName } = dependencyLocation;
|
|
847
|
-
if (layerName === "shared" && ["ui", "lib"].includes(segmentName)) {
|
|
848
|
-
const pathInSegment = relative(segment.path, resolvedDependency);
|
|
849
|
-
const topLevelFolder = segment.children.find((child) => child.type === "folder" && basename(child.path) === pathInSegment.split(sep)[0]);
|
|
850
|
-
if (topLevelFolder !== void 0) {
|
|
851
|
-
if (!getIndexes(topLevelFolder).map((topLevelFolder2) => topLevelFolder2.path).includes(resolvedDependency)) diagnostics.push({
|
|
852
|
-
message: `Forbidden sidestep of public API when importing from "${dependency.path}".`,
|
|
853
|
-
location: {
|
|
854
|
-
path: sourceFile.file.path,
|
|
855
|
-
start: dependency.start,
|
|
856
|
-
end: dependency.end
|
|
857
|
-
}
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
} else diagnostics.push({
|
|
861
|
-
message: `Forbidden sidestep of public API when importing from "${dependency.path}".`,
|
|
862
|
-
location: {
|
|
863
|
-
path: sourceFile.file.path,
|
|
864
|
-
start: dependency.start,
|
|
865
|
-
end: dependency.end
|
|
866
|
-
}
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
return { diagnostics };
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
|
-
var no_reserved_folder_names_default = {
|
|
876
|
-
name: `${NAMESPACE}/no-reserved-folder-names`,
|
|
877
|
-
check(root) {
|
|
878
|
-
const diagnostics = [];
|
|
879
|
-
for (const { segment } of getAllSegments(root)) {
|
|
880
|
-
if (segment.type === "file") continue;
|
|
881
|
-
for (const child of segment.children) {
|
|
882
|
-
if (child.type === "file") continue;
|
|
883
|
-
for (const violatingFolder of findAllRecursively(child, (entry) => entry.type === "folder" && conventionalSegmentNames.concat("@x").includes(basename(entry.path)))) if (basename(violatingFolder.path) === "@x") diagnostics.push({
|
|
884
|
-
message: `Having a folder with the name "@x" inside a segment could be confusing because that name is reserved for cross-import public APIs. Consider renaming it.`,
|
|
885
|
-
location: { path: violatingFolder.path }
|
|
886
|
-
});
|
|
887
|
-
else diagnostics.push({
|
|
888
|
-
message: `Having a folder with the name "${basename(violatingFolder.path)}" inside a segment could be confusing because that name is commonly used for segments. Consider renaming it.`,
|
|
889
|
-
location: { path: violatingFolder.path }
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
return { diagnostics };
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
var no_segmentless_slices_default = {
|
|
897
|
-
name: `${NAMESPACE}/no-segmentless-slices`,
|
|
898
|
-
check(root) {
|
|
899
|
-
const diagnostics = [];
|
|
900
|
-
for (const layer of Object.values(getLayers(root))) {
|
|
901
|
-
if (!isSliced(layer)) continue;
|
|
902
|
-
let sliceCandidates = layer.children.filter((child) => child.type === "folder");
|
|
903
|
-
while (sliceCandidates.length > 0) {
|
|
904
|
-
const sliceCandidate = sliceCandidates.pop();
|
|
905
|
-
if (sliceCandidate === void 0) continue;
|
|
906
|
-
if (isSliceGroup(sliceCandidate)) sliceCandidates = sliceCandidates.concat(sliceCandidate.children);
|
|
907
|
-
else if (!isSlice(sliceCandidate)) diagnostics.push({
|
|
908
|
-
message: "This slice has no segments. Consider dividing the code inside into segments.",
|
|
909
|
-
location: { path: sliceCandidate.path }
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
return { diagnostics };
|
|
914
|
-
}
|
|
915
|
-
};
|
|
916
|
-
function isSliceGroup(folder) {
|
|
917
|
-
return folder.children.length > 0 && !isSlice(folder) && folder.children.every((child) => child.type === "folder" && (isSlice(child) || child.children.every((grandchild) => grandchild.type === "file") || isSliceGroup(child)));
|
|
918
|
-
}
|
|
919
|
-
var no_segments_on_sliced_layers_default = {
|
|
920
|
-
name: `${NAMESPACE}/no-segments-on-sliced-layers`,
|
|
921
|
-
check(root) {
|
|
922
|
-
const diagnostics = [];
|
|
923
|
-
const layers = Object.values(getLayers(root));
|
|
924
|
-
for (const layer of layers) if (isSliced(layer)) {
|
|
925
|
-
for (const directChild of layer.children) if (directChild.type === "folder") {
|
|
926
|
-
const folderName = basename(directChild.path);
|
|
927
|
-
if (folderName && conventionalSegmentNames.includes(folderName)) diagnostics.push({
|
|
928
|
-
message: `Conventional segment "${folderName}" should not be a direct child of a sliced layer. Consider moving it inside a slice or, if that is a slice, consider a different name for it to avoid confusion with segments.`,
|
|
929
|
-
location: { path: directChild.path }
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
return { diagnostics };
|
|
934
|
-
}
|
|
935
|
-
};
|
|
936
|
-
var no_ui_in_app_default = {
|
|
937
|
-
name: `${NAMESPACE}/no-ui-in-app`,
|
|
938
|
-
check(root) {
|
|
939
|
-
const diagnostics = [];
|
|
940
|
-
const layers = getLayers(root);
|
|
941
|
-
if (layers.app !== void 0) {
|
|
942
|
-
const segments = getSegments(layers.app);
|
|
943
|
-
if (segments.ui !== void 0) diagnostics.push({
|
|
944
|
-
message: "Layer \"app\" should not have \"ui\" segment.",
|
|
945
|
-
location: { path: segments.ui.path }
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
return { diagnostics };
|
|
949
|
-
}
|
|
950
|
-
};
|
|
951
|
-
var public_api_default = {
|
|
952
|
-
name: `${NAMESPACE}/public-api`,
|
|
953
|
-
check(root) {
|
|
954
|
-
const diagnostics = [];
|
|
955
|
-
for (const [layerName, layer] of Object.entries(getLayers(root))) if (!isSliced(layer)) {
|
|
956
|
-
if (layerName === "app") continue;
|
|
957
|
-
for (const [segmentName, segment] of Object.entries(getSegments(layer))) if (getIndexes(segment).length === 0) {
|
|
958
|
-
if (!["ui", "lib"].includes(segmentName)) diagnostics.push({
|
|
959
|
-
message: "This segment is missing a public API.",
|
|
960
|
-
fixes: [{
|
|
961
|
-
type: "create-file",
|
|
962
|
-
path: join(segment.path, `index.js`),
|
|
963
|
-
content: ""
|
|
964
|
-
}],
|
|
965
|
-
location: { path: segment.path }
|
|
966
|
-
});
|
|
967
|
-
else if (segment.type === "folder") {
|
|
968
|
-
for (const child of segment.children) if (child.type === "folder" && getIndexes(child).length === 0) diagnostics.push({
|
|
969
|
-
message: `This top-level folder in shared/${segmentName} is missing a public API.`,
|
|
970
|
-
fixes: [{
|
|
971
|
-
type: "create-file",
|
|
972
|
-
path: join(child.path, `index.js`),
|
|
973
|
-
content: ""
|
|
974
|
-
}],
|
|
975
|
-
location: { path: child.path }
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
} else for (const slice of Object.values(getSlices(layer))) if (getIndexes(slice).length === 0) diagnostics.push({
|
|
980
|
-
message: "This slice is missing a public API.",
|
|
981
|
-
fixes: [{
|
|
982
|
-
type: "create-file",
|
|
983
|
-
path: join(slice.path, `index.js`),
|
|
984
|
-
content: ""
|
|
985
|
-
}],
|
|
986
|
-
location: { path: slice.path }
|
|
987
|
-
});
|
|
988
|
-
return { diagnostics };
|
|
989
|
-
}
|
|
990
|
-
};
|
|
991
|
-
var wordPattern = /(?:[A-Z]+|[a-z]+)[a-z]*/g;
|
|
992
|
-
var repetitive_naming_default = {
|
|
993
|
-
name: `${NAMESPACE}/repetitive-naming`,
|
|
994
|
-
check(root) {
|
|
995
|
-
const diagnostics = [];
|
|
996
|
-
for (const layer of Object.values(getLayers(root))) {
|
|
997
|
-
if (!isSliced(layer)) continue;
|
|
998
|
-
const sliceGroups = groupSlices(Object.keys(getSlices(layer)));
|
|
999
|
-
for (const [group, sliceNames] of Object.entries(sliceGroups)) {
|
|
1000
|
-
const wordsInSliceNames = sliceNames.map((name) => (name.match(wordPattern) ?? []).map((word) => word.toLowerCase()));
|
|
1001
|
-
const mostCommonWords = wordsInSliceNames.flat().reduce((acc, word) => {
|
|
1002
|
-
acc.set(word, (acc.get(word) ?? 0) + 1);
|
|
1003
|
-
return acc;
|
|
1004
|
-
}, /* @__PURE__ */ new Map());
|
|
1005
|
-
for (const [word, count] of mostCommonWords.entries()) if (sliceNames.length > 2 && count >= sliceNames.length && wordsInSliceNames.every((words) => words.includes(word))) diagnostics.push({
|
|
1006
|
-
message: `Repetitive word "${word}" in slice names.`,
|
|
1007
|
-
location: { path: join(layer.path, group) }
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
return { diagnostics };
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
var BAD_NAMES_GENERIC = [
|
|
1015
|
-
"component",
|
|
1016
|
-
"components",
|
|
1017
|
-
"helper",
|
|
1018
|
-
"helpers",
|
|
1019
|
-
"util",
|
|
1020
|
-
"utils",
|
|
1021
|
-
"constant",
|
|
1022
|
-
"constants",
|
|
1023
|
-
"const",
|
|
1024
|
-
"consts",
|
|
1025
|
-
"type",
|
|
1026
|
-
"types",
|
|
1027
|
-
"store",
|
|
1028
|
-
"stores",
|
|
1029
|
-
"modal",
|
|
1030
|
-
"modals",
|
|
1031
|
-
"service",
|
|
1032
|
-
"services",
|
|
1033
|
-
"function",
|
|
1034
|
-
"functions",
|
|
1035
|
-
"class",
|
|
1036
|
-
"classes",
|
|
1037
|
-
"enum",
|
|
1038
|
-
"enums",
|
|
1039
|
-
"interface",
|
|
1040
|
-
"interfaces",
|
|
1041
|
-
"decorator",
|
|
1042
|
-
"decorators",
|
|
1043
|
-
"schema",
|
|
1044
|
-
"schemas",
|
|
1045
|
-
"handler",
|
|
1046
|
-
"handlers",
|
|
1047
|
-
"fixture",
|
|
1048
|
-
"fixtures",
|
|
1049
|
-
"middleware",
|
|
1050
|
-
"middlewares",
|
|
1051
|
-
"validator",
|
|
1052
|
-
"validators",
|
|
1053
|
-
"validation",
|
|
1054
|
-
"validations",
|
|
1055
|
-
"resolver",
|
|
1056
|
-
"resolvers",
|
|
1057
|
-
"mutation",
|
|
1058
|
-
"mutations",
|
|
1059
|
-
"asset",
|
|
1060
|
-
"assets"
|
|
1061
|
-
];
|
|
1062
|
-
var BAD_NAMES_REACT = [
|
|
1063
|
-
"hook",
|
|
1064
|
-
"hooks",
|
|
1065
|
-
"context",
|
|
1066
|
-
"provider",
|
|
1067
|
-
"providers"
|
|
1068
|
-
];
|
|
1069
|
-
var BAD_NAMES_VUE = [
|
|
1070
|
-
"composable",
|
|
1071
|
-
"composables",
|
|
1072
|
-
"directive",
|
|
1073
|
-
"directives"
|
|
1074
|
-
];
|
|
1075
|
-
var BAD_NAMES_REDUX = [
|
|
1076
|
-
"action",
|
|
1077
|
-
"actions",
|
|
1078
|
-
"reducer",
|
|
1079
|
-
"reducers",
|
|
1080
|
-
"selector",
|
|
1081
|
-
"selectors",
|
|
1082
|
-
"effect",
|
|
1083
|
-
"effects",
|
|
1084
|
-
"saga",
|
|
1085
|
-
"sagas",
|
|
1086
|
-
"thunk",
|
|
1087
|
-
"thunks"
|
|
1088
|
-
];
|
|
1089
|
-
var BAD_NAMES_ANGULAR = ["pipe", "pipes"];
|
|
1090
|
-
var BAD_NAMES = /* @__PURE__ */ new Set([
|
|
1091
|
-
...BAD_NAMES_GENERIC,
|
|
1092
|
-
...BAD_NAMES_REACT,
|
|
1093
|
-
...BAD_NAMES_VUE,
|
|
1094
|
-
...BAD_NAMES_REDUX,
|
|
1095
|
-
...BAD_NAMES_ANGULAR
|
|
1096
|
-
]);
|
|
1097
|
-
var segments_by_purpose_default = {
|
|
1098
|
-
name: `${NAMESPACE}/segments-by-purpose`,
|
|
1099
|
-
check(root) {
|
|
1100
|
-
const diagnostics = [];
|
|
1101
|
-
for (const layer of Object.values(getLayers(root))) {
|
|
1102
|
-
if (layer === null) continue;
|
|
1103
|
-
if (!isSliced(layer)) {
|
|
1104
|
-
for (const [segmentName, segment] of Object.entries(getSegments(layer))) if (BAD_NAMES.has(segmentName)) diagnostics.push({
|
|
1105
|
-
message: "This segment's name should describe the purpose of its contents, not what the contents are.",
|
|
1106
|
-
location: { path: segment.path }
|
|
1107
|
-
});
|
|
1108
|
-
} else for (const slice of Object.values(getSlices(layer))) for (const [segmentName, segment] of Object.entries(getSegments(slice))) if (BAD_NAMES.has(segmentName)) diagnostics.push({
|
|
1109
|
-
message: "This segment's name should describe the purpose of its contents, not what the contents are.",
|
|
1110
|
-
location: { path: segment.path }
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
return { diagnostics };
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
var THRESHOLD = 15;
|
|
1117
|
-
var shared_lib_grouping_default = {
|
|
1118
|
-
name: `${NAMESPACE}/shared-lib-grouping`,
|
|
1119
|
-
check(root) {
|
|
1120
|
-
const diagnostics = [];
|
|
1121
|
-
const { shared } = getLayers(root);
|
|
1122
|
-
if (!shared) return { diagnostics };
|
|
1123
|
-
const { lib } = getSegments(shared);
|
|
1124
|
-
if (!lib) return { diagnostics };
|
|
1125
|
-
if (lib.type === "folder" && lib.children.length > THRESHOLD) diagnostics.push({
|
|
1126
|
-
message: `Shared/lib has ${lib.children.length} modules, which is above the recommended threshold of ${THRESHOLD}. Consider grouping them.`,
|
|
1127
|
-
location: { path: lib.path }
|
|
1128
|
-
});
|
|
1129
|
-
return { diagnostics };
|
|
1130
|
-
}
|
|
1131
|
-
};
|
|
1132
|
-
var LEVENSHTEIN_DISTANCE_UPPER_BOUND = 3;
|
|
1133
|
-
var typo_in_layer_name_default = {
|
|
1134
|
-
name: `${NAMESPACE}/typo-in-layer-name`,
|
|
1135
|
-
check(root) {
|
|
1136
|
-
const diagnostics = [];
|
|
1137
|
-
const suggestionsList = root.children.filter((child) => child.type === "folder").flatMap((child) => {
|
|
1138
|
-
const layer = basename(child.path);
|
|
1139
|
-
return layerSequence.map((sequenceLayer) => ({
|
|
1140
|
-
input: layer,
|
|
1141
|
-
suggestion: sequenceLayer,
|
|
1142
|
-
distance: distance(layer, sequenceLayer)
|
|
1143
|
-
})).filter((layer2) => layer2.distance <= LEVENSHTEIN_DISTANCE_UPPER_BOUND);
|
|
1144
|
-
}).sort((a, b) => a.distance - b.distance);
|
|
1145
|
-
const processedInputs = [];
|
|
1146
|
-
const suggestedLayers = [];
|
|
1147
|
-
suggestionsList.forEach((layer) => {
|
|
1148
|
-
if (layer.distance === 0) {
|
|
1149
|
-
suggestedLayers.push(layer.suggestion);
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
1152
|
-
if (processedInputs.includes(layer.input)) return;
|
|
1153
|
-
if (suggestedLayers.includes(layer.suggestion)) return;
|
|
1154
|
-
processedInputs.push(layer.input);
|
|
1155
|
-
suggestedLayers.push(layer.suggestion);
|
|
1156
|
-
diagnostics.push({
|
|
1157
|
-
message: `Layer "${layer.input}" potentially contains a typo. Did you mean "${layer.suggestion}"?`,
|
|
1158
|
-
location: { path: join(root.path, layer.input) }
|
|
1159
|
-
});
|
|
1160
|
-
});
|
|
1161
|
-
return { diagnostics };
|
|
1162
|
-
}
|
|
1163
|
-
};
|
|
1164
|
-
var no_processes_default = {
|
|
1165
|
-
name: `${NAMESPACE}/no-processes`,
|
|
1166
|
-
check(root) {
|
|
1167
|
-
const diagnostics = [];
|
|
1168
|
-
const processesLayer = root.children.find((child) => child.type === "folder" && basename(child.path) === "processes");
|
|
1169
|
-
if (processesLayer !== void 0) diagnostics.push({
|
|
1170
|
-
message: "Layer \"processes\" is deprecated, avoid using it",
|
|
1171
|
-
location: { path: processesLayer.path }
|
|
1172
|
-
});
|
|
1173
|
-
return { diagnostics };
|
|
1174
|
-
}
|
|
1175
|
-
};
|
|
1176
|
-
var package_default = { version: "0.8.2" };
|
|
1177
|
-
var no_cross_imports_default = {
|
|
1178
|
-
name: `${NAMESPACE}/no-cross-imports`,
|
|
1179
|
-
async check(root) {
|
|
1180
|
-
const diagnostics = [];
|
|
1181
|
-
const tsConfigs = collectRelatedTsConfigs(await parse$1(root.children[0]?.path ?? root.path));
|
|
1182
|
-
const sourceFileIndex = indexSourceFiles(root);
|
|
1183
|
-
for (const sourceFile of Object.values(sourceFileIndex)) {
|
|
1184
|
-
if (!getSourceType(sourceFile.file.path)) continue;
|
|
1185
|
-
const dependencies = await extractDependencies(sourceFile.file.path);
|
|
1186
|
-
for (const dependency of dependencies) {
|
|
1187
|
-
const resolvedDependency = resolveDependency(dependency.path, sourceFile.file.path, tsConfigs, fs.existsSync, fs.existsSync);
|
|
1188
|
-
if (resolvedDependency === null) continue;
|
|
1189
|
-
const dependencyLocation = sourceFileIndex[resolvedDependency];
|
|
1190
|
-
if (dependencyLocation === void 0) continue;
|
|
1191
|
-
if (sourceFile.layerName === dependencyLocation.layerName && sourceFile.sliceName !== dependencyLocation.sliceName) {
|
|
1192
|
-
if (dependencyLocation.sliceName !== null && sourceFile.sliceName !== null && !isCrossImportPublicApi(dependencyLocation.file, {
|
|
1193
|
-
inSlice: dependencyLocation.sliceName,
|
|
1194
|
-
forSlice: sourceFile.sliceName,
|
|
1195
|
-
layerPath: dependencyLocation.layerPath
|
|
1196
|
-
})) diagnostics.push({
|
|
1197
|
-
message: `Forbidden cross-import from slice "${dependencyLocation.sliceName}".`,
|
|
1198
|
-
location: {
|
|
1199
|
-
path: sourceFile.file.path,
|
|
1200
|
-
start: dependency.start,
|
|
1201
|
-
end: dependency.end
|
|
1202
|
-
}
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
return { diagnostics };
|
|
1208
|
-
}
|
|
1209
|
-
};
|
|
1210
|
-
var no_higher_level_imports_default = {
|
|
1211
|
-
name: `${NAMESPACE}/no-higher-level-imports`,
|
|
1212
|
-
async check(root) {
|
|
1213
|
-
const diagnostics = [];
|
|
1214
|
-
const tsConfigs = collectRelatedTsConfigs(await parse$1(root.children[0]?.path ?? root.path));
|
|
1215
|
-
const sourceFileIndex = indexSourceFiles(root);
|
|
1216
|
-
for (const sourceFile of Object.values(sourceFileIndex)) {
|
|
1217
|
-
if (!getSourceType(sourceFile.file.path)) continue;
|
|
1218
|
-
const dependencies = await extractDependencies(sourceFile.file.path);
|
|
1219
|
-
for (const dependency of dependencies) {
|
|
1220
|
-
const resolvedDependency = resolveDependency(dependency.path, sourceFile.file.path, tsConfigs, fs.existsSync, fs.existsSync);
|
|
1221
|
-
if (resolvedDependency === null) continue;
|
|
1222
|
-
const dependencyLocation = sourceFileIndex[resolvedDependency];
|
|
1223
|
-
if (dependencyLocation === void 0) continue;
|
|
1224
|
-
if (layerSequence.indexOf(sourceFile.layerName) < layerSequence.indexOf(dependencyLocation.layerName)) diagnostics.push({
|
|
1225
|
-
message: `Forbidden import from higher layer "${dependencyLocation.layerName}".`,
|
|
1226
|
-
location: {
|
|
1227
|
-
path: sourceFile.file.path,
|
|
1228
|
-
start: dependency.start,
|
|
1229
|
-
end: dependency.end
|
|
1230
|
-
}
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
return { diagnostics };
|
|
1235
|
-
}
|
|
1236
|
-
};
|
|
1237
|
-
var import_locality_default = {
|
|
1238
|
-
name: `${NAMESPACE}/import-locality`,
|
|
1239
|
-
async check(root) {
|
|
1240
|
-
const diagnostics = [];
|
|
1241
|
-
const tsConfigs = collectRelatedTsConfigs(await parse$1(root.children[0]?.path ?? root.path));
|
|
1242
|
-
const sourceFileIndex = indexSourceFiles(root);
|
|
1243
|
-
for (const sourceFile of Object.values(sourceFileIndex)) {
|
|
1244
|
-
if (!getSourceType(sourceFile.file.path)) continue;
|
|
1245
|
-
const dependencies = await extractDependencies(sourceFile.file.path);
|
|
1246
|
-
for (const dependency of dependencies) {
|
|
1247
|
-
const resolvedDependency = resolveDependency(dependency.path, sourceFile.file.path, tsConfigs, fs.existsSync, fs.existsSync);
|
|
1248
|
-
if (resolvedDependency === null) continue;
|
|
1249
|
-
const dependencyLocation = sourceFileIndex[resolvedDependency];
|
|
1250
|
-
if (dependencyLocation === void 0) continue;
|
|
1251
|
-
const isRelative = [".", ".."].includes(dependency.path.split("/")[0]);
|
|
1252
|
-
const isWithinSameSlice = sourceFile.layerName === dependencyLocation.layerName && sourceFile.sliceName === dependencyLocation.sliceName;
|
|
1253
|
-
if (isRelative && !isWithinSameSlice) diagnostics.push({
|
|
1254
|
-
message: `Import from "${dependency.path}" should not be relative.`,
|
|
1255
|
-
location: {
|
|
1256
|
-
path: sourceFile.file.path,
|
|
1257
|
-
start: dependency.start,
|
|
1258
|
-
end: dependency.end
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
else if (!isRelative && isWithinSameSlice) diagnostics.push({
|
|
1262
|
-
message: `Import from "${dependency.path}" should be relative.`,
|
|
1263
|
-
location: {
|
|
1264
|
-
path: sourceFile.file.path,
|
|
1265
|
-
start: dependency.start,
|
|
1266
|
-
end: dependency.end
|
|
1267
|
-
}
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
return { diagnostics };
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
|
-
var no_wildcard_exports_default = {
|
|
1275
|
-
name: `${NAMESPACE}/no-wildcard-exports`,
|
|
1276
|
-
async check(root) {
|
|
1277
|
-
const diagnostics = [];
|
|
1278
|
-
for (const sourceFile of Object.values(indexSourceFiles(root))) {
|
|
1279
|
-
if (!isIndex(sourceFile.file)) continue;
|
|
1280
|
-
if (!getSourceType(sourceFile.file.path)) continue;
|
|
1281
|
-
for (const reExport of await extractReExports(sourceFile.file.path)) {
|
|
1282
|
-
if (reExport.kind !== "wildcard" && reExport.kind !== "namespace") continue;
|
|
1283
|
-
diagnostics.push({
|
|
1284
|
-
message: `Wildcard re-export from "${reExport.source}" does not define an explicit public API. Prefer explicit named exports.`,
|
|
1285
|
-
location: {
|
|
1286
|
-
path: sourceFile.file.path,
|
|
1287
|
-
start: reExport.statementRange.start,
|
|
1288
|
-
end: reExport.statementRange.end
|
|
1289
|
-
}
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
return { diagnostics };
|
|
1294
|
-
}
|
|
1295
|
-
};
|
|
1296
|
-
var enabledRules = [
|
|
1297
|
-
ambiguous_slice_names_default,
|
|
1298
|
-
excessive_slicing_default,
|
|
1299
|
-
forbidden_imports_default,
|
|
1300
|
-
inconsistent_naming_default,
|
|
1301
|
-
insignificant_slice_default,
|
|
1302
|
-
no_layer_public_api_default,
|
|
1303
|
-
no_public_api_sidestep_default,
|
|
1304
|
-
no_reserved_folder_names_default,
|
|
1305
|
-
no_segmentless_slices_default,
|
|
1306
|
-
no_segments_on_sliced_layers_default,
|
|
1307
|
-
no_ui_in_app_default,
|
|
1308
|
-
public_api_default,
|
|
1309
|
-
repetitive_naming_default,
|
|
1310
|
-
segments_by_purpose_default,
|
|
1311
|
-
shared_lib_grouping_default,
|
|
1312
|
-
typo_in_layer_name_default,
|
|
1313
|
-
no_processes_default
|
|
1314
|
-
];
|
|
1315
|
-
var disabledRules = [
|
|
1316
|
-
no_cross_imports_default,
|
|
1317
|
-
no_higher_level_imports_default,
|
|
1318
|
-
import_locality_default,
|
|
1319
|
-
no_wildcard_exports_default
|
|
1320
|
-
];
|
|
1321
|
-
var rules = [...enabledRules, ...disabledRules];
|
|
1322
|
-
var plugin$1 = createPlugin({
|
|
1323
|
-
meta: {
|
|
1324
|
-
name: "@feature-sliced/steiger-plugin",
|
|
1325
|
-
version: package_default.version
|
|
1326
|
-
},
|
|
1327
|
-
ruleDefinitions: rules
|
|
1328
|
-
});
|
|
1329
|
-
// src/app/fsd.ts
|
|
1330
|
-
const plugin = {
|
|
1331
|
-
plugin: plugin$1,
|
|
1332
|
-
configs: createConfigs({ recommended: enableSpecificRules(plugin$1, enabledRules) })
|
|
1333
|
-
};
|
|
1334
|
-
export { plugin as default };
|
|
1335
|
-
|
|
1336
|
-
//# sourceMappingURL=fsd.mjs.map
|