eslint-plugin-fast-import 2.2.0 → 2.2.2
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/CHANGELOG.md +8 -0
- package/README.md +29 -5
- package/dist/module/computePackageInfo.d.ts +2 -0
- package/dist/module/computePackageInfo.js +4 -0
- package/dist/module/computePackageInfo.js.map +1 -0
- package/dist/module/computeRepoInfo.d.ts +5 -0
- package/dist/module/computeRepoInfo.js +100 -0
- package/dist/module/computeRepoInfo.js.map +1 -0
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +4 -1
- package/dist/plugin.js.map +1 -1
- package/dist/rules/no-cycle/cycle.d.ts +4 -0
- package/dist/rules/no-cycle/cycle.js +140 -0
- package/dist/rules/no-cycle/cycle.js.map +1 -0
- package/dist/rules/no-cycle/rule.d.ts +4 -0
- package/dist/rules/no-cycle/rule.js +319 -0
- package/dist/rules/no-cycle/rule.js.map +1 -0
- package/dist/rules/no-empty-entry-points/rule.d.ts +3 -0
- package/dist/rules/no-empty-entry-points/rule.js +57 -0
- package/dist/rules/no-empty-entry-points/rule.js.map +1 -0
- package/dist/rules/no-entry-point-imports/entryPoint.d.ts +3 -0
- package/dist/rules/no-entry-point-imports/entryPoint.js +57 -0
- package/dist/rules/no-entry-point-imports/entryPoint.js.map +1 -0
- package/dist/rules/no-entry-point-imports/rule.d.ts +3 -0
- package/dist/rules/no-entry-point-imports/rule.js +60 -0
- package/dist/rules/no-entry-point-imports/rule.js.map +1 -0
- package/dist/rules/no-external-barrel-reexports/externalBarrelReexports.d.ts +3 -0
- package/dist/rules/no-external-barrel-reexports/externalBarrelReexports.js +42 -0
- package/dist/rules/no-external-barrel-reexports/externalBarrelReexports.js.map +1 -0
- package/dist/rules/no-external-barrel-reexports/rule.d.ts +3 -0
- package/dist/rules/no-external-barrel-reexports/rule.js +42 -0
- package/dist/rules/no-external-barrel-reexports/rule.js.map +1 -0
- package/dist/rules/no-named-as-default/namedAsDefault.d.ts +3 -0
- package/dist/rules/no-named-as-default/namedAsDefault.js +77 -0
- package/dist/rules/no-named-as-default/namedAsDefault.js.map +1 -0
- package/dist/rules/no-named-as-default/rule.d.ts +3 -0
- package/dist/rules/no-named-as-default/rule.js +79 -0
- package/dist/rules/no-named-as-default/rule.js.map +1 -0
- package/dist/rules/no-node-builtins/nodeBuiltins.d.ts +3 -0
- package/dist/rules/no-node-builtins/nodeBuiltins.js +48 -0
- package/dist/rules/no-node-builtins/nodeBuiltins.js.map +1 -0
- package/dist/rules/no-node-builtins/rule.d.ts +3 -0
- package/dist/rules/no-node-builtins/rule.js +49 -0
- package/dist/rules/no-node-builtins/rule.js.map +1 -0
- package/dist/rules/no-restricted-imports/restricted.d.ts +31 -0
- package/dist/rules/no-restricted-imports/restricted.js +196 -0
- package/dist/rules/no-restricted-imports/restricted.js.map +1 -0
- package/dist/rules/no-restricted-imports/rule.d.ts +31 -0
- package/dist/rules/no-restricted-imports/rule.js +204 -0
- package/dist/rules/no-restricted-imports/rule.js.map +1 -0
- package/dist/rules/no-test-imports-in-prod/rule.d.ts +3 -0
- package/dist/rules/no-test-imports-in-prod/rule.js +57 -0
- package/dist/rules/no-test-imports-in-prod/rule.js.map +1 -0
- package/dist/rules/no-test-imports-in-prod/testInProd.d.ts +3 -0
- package/dist/rules/no-test-imports-in-prod/testInProd.js +49 -0
- package/dist/rules/no-test-imports-in-prod/testInProd.js.map +1 -0
- package/dist/rules/no-test-only-imports/rule.d.ts +3 -0
- package/dist/rules/no-test-only-imports/rule.js +69 -0
- package/dist/rules/no-test-only-imports/rule.js.map +1 -0
- package/dist/rules/no-unnamed-entry-point-exports/rule.d.ts +3 -0
- package/dist/rules/no-unnamed-entry-point-exports/rule.js +41 -0
- package/dist/rules/no-unnamed-entry-point-exports/rule.js.map +1 -0
- package/dist/rules/no-unresolved-imports/rule.d.ts +3 -0
- package/dist/rules/no-unresolved-imports/rule.js +139 -0
- package/dist/rules/no-unresolved-imports/rule.js.map +1 -0
- package/dist/rules/no-unresolved-imports/unresolved.d.ts +3 -0
- package/dist/rules/no-unresolved-imports/unresolved.js +135 -0
- package/dist/rules/no-unresolved-imports/unresolved.js.map +1 -0
- package/dist/rules/no-unused-exports/rule.d.ts +3 -0
- package/dist/rules/no-unused-exports/rule.js +60 -0
- package/dist/rules/no-unused-exports/rule.js.map +1 -0
- package/dist/rules/no-unused-package-exports/rule.d.ts +3 -0
- package/dist/rules/no-unused-package-exports/rule.js +57 -0
- package/dist/rules/no-unused-package-exports/rule.js.map +1 -0
- package/dist/rules/prefer-alias-imports/alias.d.ts +6 -0
- package/dist/rules/prefer-alias-imports/alias.js +210 -0
- package/dist/rules/prefer-alias-imports/alias.js.map +1 -0
- package/dist/rules/prefer-alias-imports/rule.d.ts +6 -0
- package/dist/rules/prefer-alias-imports/rule.js +214 -0
- package/dist/rules/prefer-alias-imports/rule.js.map +1 -0
- package/dist/rules/require-node-prefix/nodePrefix.d.ts +3 -0
- package/dist/rules/require-node-prefix/nodePrefix.js +59 -0
- package/dist/rules/require-node-prefix/nodePrefix.js.map +1 -0
- package/dist/rules/require-node-prefix/rule.d.ts +3 -0
- package/dist/rules/require-node-prefix/rule.js +60 -0
- package/dist/rules/require-node-prefix/rule.js.map +1 -0
- package/dist/settings/framework.d.ts +3 -0
- package/dist/settings/framework.js +91 -0
- package/dist/settings/framework.js.map +1 -0
- package/dist/settings/package.d.ts +6 -0
- package/dist/settings/package.js +64 -0
- package/dist/settings/package.js.map +1 -0
- package/dist/settings/repo.d.ts +1 -0
- package/dist/settings/repo.js +6 -0
- package/dist/settings/repo.js.map +1 -0
- package/dist/util/getSubpathEntry.d.ts +4 -0
- package/dist/util/getSubpathEntry.js +22 -0
- package/dist/util/getSubpathEntry.js.map +1 -0
- package/fast-import.config.json +3 -4
- package/package.json +12 -8
- package/dist/package/package.d.ts +0 -8
- package/dist/package/package.js +0 -41
- package/dist/package/package.js.map +0 -1
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import { exitWithInternalError } from '../../util/error.js';
|
|
3
|
+
import { createRule, getESMInfo, getLocFromRange, registerUpdateListener, } from '../util.js';
|
|
4
|
+
// Maximum number of nodes rendered in the displayed cycle path before we
|
|
5
|
+
// truncate the middle. Long cycles are unreadable past this point and the
|
|
6
|
+
// truncated form is more informative anyway.
|
|
7
|
+
const CYCLE_PATH_DISPLAY_CAP = 8;
|
|
8
|
+
const sccCaches = new Map();
|
|
9
|
+
registerUpdateListener((root) => {
|
|
10
|
+
sccCaches.delete(root);
|
|
11
|
+
});
|
|
12
|
+
// This is only used in tests, since update listeners aren't guaranteed to be
|
|
13
|
+
// called on each run. Name preserved for backward compatibility with existing
|
|
14
|
+
// test imports.
|
|
15
|
+
export function _testOnlyResetCycleMap() {
|
|
16
|
+
sccCaches.clear();
|
|
17
|
+
}
|
|
18
|
+
// Returns the resolved file paths of all first-party, non-type import and
|
|
19
|
+
// reexport edges originating from `filePath`. The list intentionally excludes
|
|
20
|
+
// dynamic imports (which are runtime-only and are not considered cyclic by
|
|
21
|
+
// this rule) and matches the edge set used by the previous DFS.
|
|
22
|
+
function getOutgoingEdges(filePath, packageInfo) {
|
|
23
|
+
const fileDetails = packageInfo.files.get(filePath);
|
|
24
|
+
if (!fileDetails || fileDetails.fileType !== 'code') {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const edges = [];
|
|
28
|
+
for (const importEntry of [
|
|
29
|
+
...fileDetails.singleImports,
|
|
30
|
+
...fileDetails.singleReexports,
|
|
31
|
+
...fileDetails.barrelImports,
|
|
32
|
+
...fileDetails.barrelReexports,
|
|
33
|
+
...fileDetails.sideEffectImports,
|
|
34
|
+
]) {
|
|
35
|
+
if (
|
|
36
|
+
// Type imports/reexports are erased at compile time, so they cannot
|
|
37
|
+
// participate in runtime cycles
|
|
38
|
+
('isTypeImport' in importEntry && importEntry.isTypeImport) ||
|
|
39
|
+
('isTypeReexport' in importEntry && importEntry.isTypeReexport) ||
|
|
40
|
+
importEntry.resolvedModuleType !== 'firstPartyCode') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
edges.push(importEntry.resolvedModulePath);
|
|
44
|
+
}
|
|
45
|
+
return edges;
|
|
46
|
+
}
|
|
47
|
+
// Iterative Tarjan's strongly-connected-components algorithm. Iterative form
|
|
48
|
+
// is required because the import graph in large repos (e.g. the VS Code
|
|
49
|
+
// codebase) is deep enough to overflow the JS call stack with the recursive
|
|
50
|
+
// formulation.
|
|
51
|
+
function computeSccs(packageInfo) {
|
|
52
|
+
const sccId = new Map();
|
|
53
|
+
const selfLoops = new Set();
|
|
54
|
+
// Tarjan bookkeeping
|
|
55
|
+
const index = new Map();
|
|
56
|
+
const lowLink = new Map();
|
|
57
|
+
const onStack = new Set();
|
|
58
|
+
const sccStack = [];
|
|
59
|
+
let nextIndex = 0;
|
|
60
|
+
let nextSccId = 0;
|
|
61
|
+
const workStack = [];
|
|
62
|
+
const pushNode = (v) => {
|
|
63
|
+
index.set(v, nextIndex);
|
|
64
|
+
lowLink.set(v, nextIndex);
|
|
65
|
+
nextIndex++;
|
|
66
|
+
sccStack.push(v);
|
|
67
|
+
onStack.add(v);
|
|
68
|
+
workStack.push({
|
|
69
|
+
node: v,
|
|
70
|
+
edges: getOutgoingEdges(v, packageInfo),
|
|
71
|
+
edgeIdx: 0,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
for (const filePath of packageInfo.files.keys()) {
|
|
75
|
+
if (index.has(filePath)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const fileDetails = packageInfo.files.get(filePath);
|
|
79
|
+
if (!fileDetails || fileDetails.fileType !== 'code') {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
pushNode(filePath);
|
|
83
|
+
while (workStack.length > 0) {
|
|
84
|
+
const frame = workStack[workStack.length - 1];
|
|
85
|
+
const v = frame.node;
|
|
86
|
+
if (frame.edgeIdx < frame.edges.length) {
|
|
87
|
+
const w = frame.edges[frame.edgeIdx++];
|
|
88
|
+
// A self-edge does not enlarge the SCC v sits in (Tarjan only links
|
|
89
|
+
// through stack neighbors), but it does mean the edge itself is part
|
|
90
|
+
// of a cycle. Track it separately.
|
|
91
|
+
if (w === v) {
|
|
92
|
+
selfLoops.add(v);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const wDetails = packageInfo.files.get(w);
|
|
96
|
+
if (!wDetails || wDetails.fileType !== 'code') {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (!index.has(w)) {
|
|
100
|
+
// Tree edge: descend into w
|
|
101
|
+
pushNode(w);
|
|
102
|
+
}
|
|
103
|
+
else if (onStack.has(w)) {
|
|
104
|
+
// Back-edge: w is an ancestor in the current DFS, update v's lowlink
|
|
105
|
+
const vLow = lowLink.get(v);
|
|
106
|
+
const wIndex = index.get(w);
|
|
107
|
+
/* istanbul ignore if */
|
|
108
|
+
if (vLow === undefined || wIndex === undefined) {
|
|
109
|
+
exitWithInternalError('Tarjan low/index missing for stacked nodes');
|
|
110
|
+
}
|
|
111
|
+
lowLink.set(v, Math.min(vLow, wIndex));
|
|
112
|
+
}
|
|
113
|
+
// else: cross-edge into a previously-completed SCC, ignored
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// Finished exploring all edges from v
|
|
117
|
+
workStack.pop();
|
|
118
|
+
if (lowLink.get(v) === index.get(v)) {
|
|
119
|
+
// v is the root of a new SCC; pop everything above it
|
|
120
|
+
const id = nextSccId++;
|
|
121
|
+
let popped;
|
|
122
|
+
do {
|
|
123
|
+
popped = sccStack.pop();
|
|
124
|
+
/* istanbul ignore if */
|
|
125
|
+
if (popped === undefined) {
|
|
126
|
+
exitWithInternalError('Tarjan SCC stack unexpectedly empty while popping component');
|
|
127
|
+
}
|
|
128
|
+
onStack.delete(popped);
|
|
129
|
+
sccId.set(popped, id);
|
|
130
|
+
} while (popped !== v);
|
|
131
|
+
}
|
|
132
|
+
// Propagate v's lowlink up to the parent (the recursive equivalent of
|
|
133
|
+
// `lowlink[parent] = min(lowlink[parent], lowlink[v])` after returning)
|
|
134
|
+
if (workStack.length > 0) {
|
|
135
|
+
const parent = workStack[workStack.length - 1];
|
|
136
|
+
const parentLow = lowLink.get(parent.node);
|
|
137
|
+
const vLow = lowLink.get(v);
|
|
138
|
+
/* istanbul ignore if */
|
|
139
|
+
if (parentLow === undefined || vLow === undefined) {
|
|
140
|
+
exitWithInternalError('Tarjan lowlink missing while propagating to parent');
|
|
141
|
+
}
|
|
142
|
+
lowLink.set(parent.node, Math.min(parentLow, vLow));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return { sccId, selfLoops };
|
|
148
|
+
}
|
|
149
|
+
function getSccData(packageInfo) {
|
|
150
|
+
let scc = sccCaches.get(packageInfo.packageRootDir);
|
|
151
|
+
if (!scc) {
|
|
152
|
+
scc = computeSccs(packageInfo);
|
|
153
|
+
sccCaches.set(packageInfo.packageRootDir, scc);
|
|
154
|
+
}
|
|
155
|
+
return scc;
|
|
156
|
+
}
|
|
157
|
+
function isEdgeInCycle(u, v, scc) {
|
|
158
|
+
if (u === v) {
|
|
159
|
+
return scc.selfLoops.has(u);
|
|
160
|
+
}
|
|
161
|
+
const idU = scc.sccId.get(u);
|
|
162
|
+
if (idU === undefined) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return idU === scc.sccId.get(v);
|
|
166
|
+
}
|
|
167
|
+
// Recovers a representative cycle path `[u, v, ..., u]` for an edge `u → v`
|
|
168
|
+
// known to be part of a cycle. Uses BFS within the shared SCC, so the
|
|
169
|
+
// recovered path is a shortest cycle through the edge. Returns undefined for
|
|
170
|
+
// the unexpected case where the path could not be found (treated as
|
|
171
|
+
// best-effort; the rule still reports the violation, just with a fallback
|
|
172
|
+
// message).
|
|
173
|
+
function findCyclePath(u, v, packageInfo, scc) {
|
|
174
|
+
// Self-edge: the cycle is u → u directly
|
|
175
|
+
if (u === v) {
|
|
176
|
+
return [u, u];
|
|
177
|
+
}
|
|
178
|
+
const targetSccId = scc.sccId.get(u);
|
|
179
|
+
/* istanbul ignore if */
|
|
180
|
+
if (targetSccId === undefined || targetSccId !== scc.sccId.get(v)) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
// BFS from v looking for u, restricted to nodes in the same SCC. Since u
|
|
184
|
+
// and v share an SCC, a path is guaranteed to exist and the BFS is bounded
|
|
185
|
+
// by the SCC's size.
|
|
186
|
+
const visited = new Set([v]);
|
|
187
|
+
const parents = new Map();
|
|
188
|
+
const queue = [v];
|
|
189
|
+
search: while (queue.length > 0) {
|
|
190
|
+
const current = queue.shift();
|
|
191
|
+
/* istanbul ignore if */
|
|
192
|
+
if (current === undefined) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
for (const next of getOutgoingEdges(current, packageInfo)) {
|
|
196
|
+
if (visited.has(next)) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (scc.sccId.get(next) !== targetSccId) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
visited.add(next);
|
|
203
|
+
parents.set(next, current);
|
|
204
|
+
if (next === u) {
|
|
205
|
+
break search;
|
|
206
|
+
}
|
|
207
|
+
queue.push(next);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/* istanbul ignore if */
|
|
211
|
+
if (!parents.has(u)) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
// Reconstruct path v → ... → u, then prepend u to form the closed cycle.
|
|
215
|
+
const pathFromV = [u];
|
|
216
|
+
let cursor = u;
|
|
217
|
+
while (cursor !== v) {
|
|
218
|
+
const p = parents.get(cursor);
|
|
219
|
+
/* istanbul ignore if */
|
|
220
|
+
if (p === undefined) {
|
|
221
|
+
exitWithInternalError(`Could not reconstruct cycle path for ${u} → ${v}`);
|
|
222
|
+
}
|
|
223
|
+
pathFromV.unshift(p);
|
|
224
|
+
cursor = p;
|
|
225
|
+
}
|
|
226
|
+
return [u, ...pathFromV];
|
|
227
|
+
}
|
|
228
|
+
function renderCyclePath(packageRootDir, cycle) {
|
|
229
|
+
/* istanbul ignore if */
|
|
230
|
+
if (!cycle || cycle.length === 0) {
|
|
231
|
+
return '<cycle path unavailable>';
|
|
232
|
+
}
|
|
233
|
+
const toLabel = (filePath) => relative(packageRootDir, filePath) || filePath;
|
|
234
|
+
if (cycle.length <= CYCLE_PATH_DISPLAY_CAP + 1) {
|
|
235
|
+
return cycle.map(toLabel).join(' → ');
|
|
236
|
+
}
|
|
237
|
+
// Truncate: keep first half and last half of the display cap, indicate the
|
|
238
|
+
// omitted middle. The path always starts and ends at the same file (the
|
|
239
|
+
// current rule's anchor), so the head/tail bias is informative.
|
|
240
|
+
const headSize = Math.ceil(CYCLE_PATH_DISPLAY_CAP / 2);
|
|
241
|
+
const tailSize = Math.floor(CYCLE_PATH_DISPLAY_CAP / 2);
|
|
242
|
+
const head = cycle.slice(0, headSize);
|
|
243
|
+
const tail = cycle.slice(cycle.length - tailSize);
|
|
244
|
+
const omitted = cycle.length - head.length - tail.length;
|
|
245
|
+
return [
|
|
246
|
+
...head.map(toLabel),
|
|
247
|
+
`... ${String(omitted)} more file${omitted === 1 ? '' : 's'} ...`,
|
|
248
|
+
...tail.map(toLabel),
|
|
249
|
+
].join(' → ');
|
|
250
|
+
}
|
|
251
|
+
export const noCycle = createRule({
|
|
252
|
+
name: 'no-cycle',
|
|
253
|
+
meta: {
|
|
254
|
+
docs: {
|
|
255
|
+
description: 'Ensures that there are no cycles in imports/reexports',
|
|
256
|
+
},
|
|
257
|
+
schema: [],
|
|
258
|
+
fixable: undefined,
|
|
259
|
+
type: 'problem',
|
|
260
|
+
messages: {
|
|
261
|
+
noCycles: 'Imports/reexports cannot form a cycle: {{cyclePath}}',
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
defaultOptions: [],
|
|
265
|
+
create(context) {
|
|
266
|
+
const esmInfo = getESMInfo(context);
|
|
267
|
+
// No package info means this file wasn't found as part of the package,
|
|
268
|
+
// e.g. because it's ignored
|
|
269
|
+
/* istanbul ignore if */
|
|
270
|
+
if (!esmInfo) {
|
|
271
|
+
return {};
|
|
272
|
+
}
|
|
273
|
+
const { fileInfo, packageInfo } = esmInfo;
|
|
274
|
+
/* istanbul ignore if */
|
|
275
|
+
if (fileInfo.fileType !== 'code') {
|
|
276
|
+
return {};
|
|
277
|
+
}
|
|
278
|
+
const scc = getSccData(packageInfo);
|
|
279
|
+
// Dedupe by target so multiple imports of the same file produce one
|
|
280
|
+
// report, matching the previous rule's behavior.
|
|
281
|
+
const reportedTargets = new Set();
|
|
282
|
+
// We intentionally skip dynamic imports because they are always safe to
|
|
283
|
+
// import in a cycle, since they're guaranteed to happen after the entire
|
|
284
|
+
// file is done loading (and thus can't cause a deadlock), but they're the
|
|
285
|
+
// only type of import this is true of. Side effect imports can still cause
|
|
286
|
+
// deadlock issues though, especially if they modify globalThis.
|
|
287
|
+
for (const importEntry of [
|
|
288
|
+
...fileInfo.singleImports,
|
|
289
|
+
...fileInfo.singleReexports,
|
|
290
|
+
...fileInfo.barrelImports,
|
|
291
|
+
...fileInfo.barrelReexports,
|
|
292
|
+
...fileInfo.sideEffectImports,
|
|
293
|
+
]) {
|
|
294
|
+
if (('isTypeImport' in importEntry && importEntry.isTypeImport) ||
|
|
295
|
+
('isTypeReexport' in importEntry && importEntry.isTypeReexport) ||
|
|
296
|
+
importEntry.resolvedModuleType !== 'firstPartyCode') {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const target = importEntry.resolvedModulePath;
|
|
300
|
+
if (reportedTargets.has(target)) {
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (!isEdgeInCycle(context.filename, target, scc)) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
reportedTargets.add(target);
|
|
307
|
+
const cycle = findCyclePath(context.filename, target, packageInfo, scc);
|
|
308
|
+
context.report({
|
|
309
|
+
messageId: 'noCycles',
|
|
310
|
+
loc: getLocFromRange(context, importEntry.statementNodeRange),
|
|
311
|
+
data: {
|
|
312
|
+
cyclePath: renderCyclePath(packageInfo.packageRootDir, cycle),
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return {};
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
//# sourceMappingURL=rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../../../src/rules/no-cycle/rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAKpB,yEAAyE;AACzE,0EAA0E;AAC1E,6CAA6C;AAC7C,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAYjC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;AAE7C,sBAAsB,CAAC,CAAC,IAAI,EAAE,EAAE;IAC9B,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,6EAA6E;AAC7E,8EAA8E;AAC9E,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,0EAA0E;AAC1E,8EAA8E;AAC9E,2EAA2E;AAC3E,gEAAgE;AAChE,SAAS,gBAAgB,CACvB,QAAgB,EAChB,WAAgC;IAEhC,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QACpD,OAAO,EAAE,CAAC;IAC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AI,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBAChC,SAAS;YACX,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;gBAClD,SAAS;YACX,CAAC;YACD,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5B,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;YACxE,OAAO,CAAC,MAAM,CAAC;gBACb,SAAS,EAAE,UAAU;gBACrB,GAAG,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,kBAAkB,CAAC;gBAC7D,IAAI,EAAE;oBACJ,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,cAAc,EAAE,KAAK,CAAC;iBAC9D;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRule, getESMInfo } from '../util.js';
|
|
2
|
+
export const noEmptyEntryPoints = createRule({
|
|
3
|
+
name: 'no-empty-entry-points',
|
|
4
|
+
meta: {
|
|
5
|
+
docs: {
|
|
6
|
+
description: 'Flags entry points and externally imported files with no exports',
|
|
7
|
+
},
|
|
8
|
+
schema: [],
|
|
9
|
+
type: 'problem',
|
|
10
|
+
messages: {
|
|
11
|
+
noEmptyEntryPoints: 'Entry point file "{{filePath}}" has no exports',
|
|
12
|
+
noEmptyExternallyImportedFiles: 'Externally imported file "{{filePath}}" has no exports',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultOptions: [],
|
|
16
|
+
create(context) {
|
|
17
|
+
const esmInfo = getESMInfo(context);
|
|
18
|
+
// No package info means this file wasn't found as part of the package, e.g.
|
|
19
|
+
// because it's ignored
|
|
20
|
+
/* istanbul ignore if */
|
|
21
|
+
if (!esmInfo) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const { fileInfo } = esmInfo;
|
|
25
|
+
/* istanbul ignore if */
|
|
26
|
+
if (fileInfo.fileType !== 'code') {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
// Bail if this isn't an entry point or externally imported file
|
|
30
|
+
if (!fileInfo.isExternallyImported && !fileInfo.entryPointSpecifier) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
// Ignore config files, since they're added by default
|
|
34
|
+
if (context.filename.includes('.config.')) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
Program: (node) => {
|
|
39
|
+
// Check if there are no exports, barrel reexports, or single reexports
|
|
40
|
+
if (fileInfo.exports.length === 0 &&
|
|
41
|
+
fileInfo.barrelReexports.length === 0 &&
|
|
42
|
+
fileInfo.singleReexports.length === 0) {
|
|
43
|
+
context.report({
|
|
44
|
+
loc: node.loc,
|
|
45
|
+
messageId: fileInfo.isExternallyImported
|
|
46
|
+
? 'noEmptyExternallyImportedFiles'
|
|
47
|
+
: 'noEmptyEntryPoints',
|
|
48
|
+
data: {
|
|
49
|
+
filePath: context.filename,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../../../src/rules/no-empty-entry-points/rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;IAC3C,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EACT,kEAAkE;SACrE;QACD,MAAM,EAAE,E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;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRule, getESMInfo, getLocFromRange } from '../util.js';
|
|
2
|
+
export const noEntryPointImports = createRule({
|
|
3
|
+
name: 'no-entry-point-imports',
|
|
4
|
+
meta: {
|
|
5
|
+
docs: {
|
|
6
|
+
description: 'Ensures that exports in entry point files are not imported',
|
|
7
|
+
},
|
|
8
|
+
schema: [],
|
|
9
|
+
fixable: undefined,
|
|
10
|
+
type: 'problem',
|
|
11
|
+
messages: {
|
|
12
|
+
noEntryPointImports: 'Entry point exports should be not imported',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultOptions: [],
|
|
16
|
+
create(context) {
|
|
17
|
+
const esmInfo = getESMInfo(context);
|
|
18
|
+
// No project info means this file wasn't found as part of the project, e.g.
|
|
19
|
+
// because it's ignored
|
|
20
|
+
/* istanbul ignore if */
|
|
21
|
+
if (!esmInfo) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const { fileInfo, projectInfo } = esmInfo;
|
|
25
|
+
/* istanbul ignore if */
|
|
26
|
+
if (fileInfo.fileType !== 'code') {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
for (const importEntry of fileInfo.singleImports) {
|
|
30
|
+
if (importEntry.rootModuleType === 'firstPartyCode' &&
|
|
31
|
+
(importEntry.rootExportEntry.isEntryPoint ||
|
|
32
|
+
importEntry.rootExportEntry.isExternallyImported)) {
|
|
33
|
+
context.report({
|
|
34
|
+
messageId: 'noEntryPointImports',
|
|
35
|
+
loc: getLocFromRange(context, importEntry.reportNodeRange),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const importEntry of fileInfo.barrelImports) {
|
|
40
|
+
if (!importEntry.resolvedModulePath) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const fileDetails = projectInfo.files.get(importEntry.resolvedModulePath);
|
|
44
|
+
if (fileDetails?.fileType !== 'code') {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (fileDetails.hasEntryPoints || fileDetails.hasExternallyImported) {
|
|
48
|
+
context.report({
|
|
49
|
+
messageId: 'noEntryPointImports',
|
|
50
|
+
loc: getLocFromRange(context, importEntry.reportNodeRange),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {};
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=entryPoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entryPoint.js","sourceRoot":"","sources":["../../../src/rules/no-entry-point-imports/entryPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC5C,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;SAC1E;QACD,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACR,mBAAmB,EAAE,4CAA4C;SAClE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QAEpC,4EAA4E;QAC5E,uBAAuB;QACvB,wBAAwB;QACxB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAC1C,wBAAwB;QACxB,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;YACjD,IACE,WAAW,CAAC,cAAc,KAAK,gBAAgB;gBAC/C,CAAC,WAAW,CAAC,eAAe,CAAC,YAAY;oBACvC,WAAW,CAAC,eAAe,CAAC,oBAAoB,CAAC,EACnD,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC;oBACb,SAAS,EAAE,qBAAqB;oBAChC,GAAG,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC;iBAC3D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;YACjD,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBACpC,SAAS;YACX,CAAC;YACD,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAC1E,IAAI,WAAW,EAAE,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACrC,SAAS;YACX,CAAC;YACD,IAAI,WAAW,CAAC,cAAc,IAAI,WAAW,CAAC,qBAAqB,EAAE,CAAC;gBACpE,OAAO,CAAC,MAAM,CAAC;oBACb,SAAS,EAAE,qBAAqB;oBAChC,GAAG,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC;iBAC3D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createRule, getESMInfo, getLocFromRange } from '../util.js';
|
|
2
|
+
export const noEntryPointImports = createRule({
|
|
3
|
+
name: 'no-entry-point-imports',
|
|
4
|
+
meta: {
|
|
5
|
+
docs: {
|
|
6
|
+
description: 'Ensures that exports in entry point files are not imported',
|
|
7
|
+
},
|
|
8
|
+
schema: [],
|
|
9
|
+
fixable: undefined,
|
|
10
|
+
type: 'problem',
|
|
11
|
+
messages: {
|
|
12
|
+
noEntryPointImports: 'Entry point exports should be not imported',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultOptions: [],
|
|
16
|
+
create(context) {
|
|
17
|
+
const esmInfo = getESMInfo(context);
|
|
18
|
+
// No package info means this file wasn't found as part of the package, e.g.
|
|
19
|
+
// because it's ignored
|
|
20
|
+
/* istanbul ignore if */
|
|
21
|
+
if (!esmInfo) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const { fileInfo, packageInfo } = esmInfo;
|
|
25
|
+
/* istanbul ignore if */
|
|
26
|
+
if (fileInfo.fileType !== 'code') {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
for (const importEntry of fileInfo.singleImports) {
|
|
30
|
+
if (importEntry.rootModuleType === 'firstPartyCode' &&
|
|
31
|
+
(importEntry.rootExportEntry.isEntryPoint ||
|
|
32
|
+
importEntry.rootExportEntry.isExternallyImported)) {
|
|
33
|
+
context.report({
|
|
34
|
+
messageId: 'noEntryPointImports',
|
|
35
|
+
loc: getLocFromRange(context, importEntry.reportNodeRange),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const importEntry of [
|
|
40
|
+
...fileInfo.barrelImports,
|
|
41
|
+
...fileInfo.sideEffectImports,
|
|
42
|
+
]) {
|
|
43
|
+
if (!importEntry.resolvedModulePath) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const fileDetails = packageInfo.files.get(importEntry.resolvedModulePath);
|
|
47
|
+
if (fileDetails?.fileType !== 'code') {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (fileDetails.entryPointSpecifier || fileDetails.isExternallyImported) {
|
|
51
|
+
context.report({
|
|
52
|
+
messageId: 'noEntryPointImports',
|
|
53
|
+
loc: getLocFromRange(context, importEntry.reportNodeRange),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../../../src/rules/no-entry-point-imports/rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC5C,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;SAC1E;QACD,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACR,mBAAmB,EAAE,4CAA4C;SAClE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QAEpC,4EAA4E;QAC5E,uBAAuB;QACvB,wBAAwB;QACxB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAC1C,wBAAwB;QACxB,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;YACjD,IACE,WAAW,CAAC,cAAc,KAAK,gBAAgB;gBAC/C,CAAC,WAAW,CAAC,eAAe,CAAC,YAAY;oBACvC,WAAW,CAAC,eAAe,CAAC,oBAAoB,CAAC,EACnD,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC;oBACb,SAAS,EAAE,qBAAqB;oBAChC,GAAG,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC;iBAC3D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,KAAK,MAAM,WAAW,IAAI;YACxB,GAAG,QAAQ,CAAC,aAAa;YACzB,GAAG,QAAQ,CAAC,iBAAiB;SAC9B,EAAE,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBACpC,SAAS;YACX,CAAC;YACD,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAC1E,IAAI,WAAW,EAAE,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACrC,SAAS;YACX,CAAC;YACD,IAAI,WAAW,CAAC,mBAAmB,IAAI,WAAW,CAAC,oBAAoB,EAAE,CAAC;gBACxE,OAAO,CAAC,MAAM,CAAC;oBACb,SAAS,EAAE,qBAAqB;oBAChC,GAAG,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC;iBAC3D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRule, getESMInfo, getLocFromRange } from '../util.js';
|
|
2
|
+
export const noExternalBarrelReexports = createRule({
|
|
3
|
+
name: 'no-external-barrel-reexports',
|
|
4
|
+
meta: {
|
|
5
|
+
docs: {
|
|
6
|
+
description: 'Ensures that code does not barrel reexport builtin or third party modules. Doing so is not supported by fast-import for performance reasons',
|
|
7
|
+
},
|
|
8
|
+
schema: [],
|
|
9
|
+
fixable: undefined,
|
|
10
|
+
type: 'problem',
|
|
11
|
+
messages: {
|
|
12
|
+
noExternalBarrelReexports: 'Barrel reexporting builtin or third party modules is not supported',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultOptions: [],
|
|
16
|
+
create(context) {
|
|
17
|
+
const esmInfo = getESMInfo(context);
|
|
18
|
+
// No project info means this file wasn't found as part of the project, e.g.
|
|
19
|
+
// because it's ignored
|
|
20
|
+
/* istanbul ignore if */
|
|
21
|
+
if (!esmInfo) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const { fileInfo } = esmInfo;
|
|
25
|
+
/* istanbul ignore if */
|
|
26
|
+
if (fileInfo.fileType !== 'code') {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
// Now check reexports
|
|
30
|
+
for (const reexportEntry of fileInfo.barrelReexports) {
|
|
31
|
+
if (reexportEntry.resolvedModuleType === 'builtin' ||
|
|
32
|
+
reexportEntry.resolvedModuleType === 'thirdParty') {
|
|
33
|
+
context.report({
|
|
34
|
+
loc: getLocFromRange(context, reexportEntry.reportNodeRange),
|
|
35
|
+
messageId: 'noExternalBarrelReexports',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=externalBarrelReexports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"externalBarrelReexports.js","sourceRoot":"","sources":["../../../src/rules/no-external-barrel-reexports/externalBarrelReexports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC;IAClD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EACT,6IAA6I;SAChJ;QACD,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACR,yBAAyB,EACvB,oEAAoE;SACvE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QAEpC,4EAA4E;QAC5E,uBAAuB;QACvB,wBAAwB;QACxB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAC7B,wBAAwB;QACxB,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,sBAAsB;QACtB,KAAK,MAAM,aAAa,IAAI,QAAQ,CAAC,eAAe,EAAE,CAAC;YACrD,IACE,aAAa,CAAC,kBAAkB,KAAK,SAAS;gBAC9C,aAAa,CAAC,kBAAkB,KAAK,YAAY,EACjD,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC;oBACb,GAAG,EAAE,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC;oBAC5D,SAAS,EAAE,2BAA2B;iBACvC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRule, getESMInfo, getLocFromRange } from '../util.js';
|
|
2
|
+
export const noExternalBarrelReexports = createRule({
|
|
3
|
+
name: 'no-external-barrel-reexports',
|
|
4
|
+
meta: {
|
|
5
|
+
docs: {
|
|
6
|
+
description: 'Ensures that code does not barrel reexport builtin or third party modules. Doing so is not supported by import-integrity for performance reasons',
|
|
7
|
+
},
|
|
8
|
+
schema: [],
|
|
9
|
+
fixable: undefined,
|
|
10
|
+
type: 'problem',
|
|
11
|
+
messages: {
|
|
12
|
+
noExternalBarrelReexports: 'Barrel reexporting builtin or third party modules is not supported',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultOptions: [],
|
|
16
|
+
create(context) {
|
|
17
|
+
const esmInfo = getESMInfo(context);
|
|
18
|
+
// No package info means this file wasn't found as part of the package, e.g.
|
|
19
|
+
// because it's ignored
|
|
20
|
+
/* istanbul ignore if */
|
|
21
|
+
if (!esmInfo) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const { fileInfo } = esmInfo;
|
|
25
|
+
/* istanbul ignore if */
|
|
26
|
+
if (fileInfo.fileType !== 'code') {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
// Now check reexports
|
|
30
|
+
for (const reexportEntry of fileInfo.barrelReexports) {
|
|
31
|
+
if (reexportEntry.resolvedModuleType === 'builtin' ||
|
|
32
|
+
reexportEntry.resolvedModuleType === 'thirdParty') {
|
|
33
|
+
context.report({
|
|
34
|
+
loc: getLocFromRange(context, reexportEntry.reportNodeRange),
|
|
35
|
+
messageId: 'noExternalBarrelReexports',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../../../src/rules/no-external-barrel-reexports/rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC;IAClD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EACT,kJAAkJ;SACrJ;QACD,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACR,yBAAyB,EACvB,oEAAoE;SACvE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QAEpC,4EAA4E;QAC5E,uBAAuB;QACvB,wBAAwB;QACxB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,M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