@zukhruf/eslint 0.3.10 → 0.3.12
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 +6 -3
- package/dist/manifest/dependency-checks.d.ts.map +1 -1
- package/dist/manifest/dependency-checks.js +7 -1
- package/dist/manifest/dependency-checks.js.map +1 -1
- package/dist/manifest/manifest-policy.d.ts +6 -6
- package/dist/manifest/manifest-policy.d.ts.map +1 -1
- package/dist/manifest/manifest-policy.js +10 -16
- package/dist/manifest/manifest-policy.js.map +1 -1
- package/dist/manifest/project-build.d.ts +29 -0
- package/dist/manifest/project-build.d.ts.map +1 -0
- package/dist/manifest/project-build.js +65 -0
- package/dist/manifest/project-build.js.map +1 -0
- package/dist/nx.d.ts +1 -1
- package/dist/nx.js +1 -1
- package/dist/workspace/cached-project-graph.d.ts +16 -0
- package/dist/workspace/cached-project-graph.d.ts.map +1 -0
- package/dist/workspace/cached-project-graph.js +32 -0
- package/dist/workspace/cached-project-graph.js.map +1 -0
- package/package.json +8 -1
- package/dist/manifest/project-shape.d.ts +0 -19
- package/dist/manifest/project-shape.d.ts.map +0 -1
- package/dist/manifest/project-shape.js +0 -37
- package/dist/manifest/project-shape.js.map +0 -1
- package/dist/workspace/workspace-packages.d.ts +0 -7
- package/dist/workspace/workspace-packages.d.ts.map +0 -1
- package/dist/workspace/workspace-packages.js +0 -35
- package/dist/workspace/workspace-packages.js.map +0 -1
package/README.md
CHANGED
|
@@ -139,7 +139,11 @@ An island is an Nx project tagged `layer:island`. Its tags come from its `projec
|
|
|
139
139
|
- A **bundled** project is an application whose build inlines the workspace packages it imports. Their manifests are not there when it is deployed, so its own manifest declares every npm package they pull in. Workspace packages themselves are not demanded.
|
|
140
140
|
- Every other project is **unbundled**. It declares what its own code imports.
|
|
141
141
|
|
|
142
|
-
An application bundles unless its build is `nx:noop`, or esbuild with `bundle: false`.
|
|
142
|
+
The rule reads the build target as Nx resolves it: `project.json`, the target defaults in `nx.json`, and the targets that Nx plugins infer. An application bundles unless its build is `nx:noop`, or esbuild with `bundle: false`.
|
|
143
|
+
|
|
144
|
+
An esbuild app can name workspace packages in `external`. Its build does not inline those packages, so they come from `node_modules` when the app runs. When the app imports one of them, it is unbundled, and its manifest declares them. Its manifest does not declare the workspace packages that its build still inlines. The rule reads the list that Nx gives esbuild: `external` and `esbuildOptions.external`, less the entries in `excludeFromExternal`. A `*` in an entry is esbuild's wildcard, as in `@acme/*`.
|
|
145
|
+
|
|
146
|
+
Nx's check follows the imports of all workspace packages, or of none. So when an app inlines some workspace packages and names others in `external`, the rule does not check the npm imports of the inlined packages.
|
|
143
147
|
|
|
144
148
|
```js
|
|
145
149
|
import island, { manifest } from '@zukhruf/eslint/nx';
|
|
@@ -161,7 +165,7 @@ export default defineConfig({
|
|
|
161
165
|
});
|
|
162
166
|
```
|
|
163
167
|
|
|
164
|
-
The rule decides each manifest's options itself, so your options add to the shared policy and never replace it. `projects` keys are folders relative to the workspace root. Like Nx's own rule, it needs the project graph that `nx` caches; without it, the rule checks nothing. It
|
|
168
|
+
The rule decides each manifest's options itself, so your options add to the shared policy and never replace it. `projects` keys are folders relative to the workspace root. Like Nx's own rule, it needs the project graph that `nx` caches; without it, the rule checks nothing. It needs `@nx/devkit`, which `@nx/eslint-plugin` installs.
|
|
165
169
|
|
|
166
170
|
## React Native: Hermes
|
|
167
171
|
|
|
@@ -188,7 +192,6 @@ The workspace lints itself with this package's source: the root `eslint.config.m
|
|
|
188
192
|
|
|
189
193
|
```sh
|
|
190
194
|
npx nx run eslint:test # builds, then runs the rule and composition tests
|
|
191
|
-
npm run verify:packages # installs the packed tarball and imports each export
|
|
192
195
|
```
|
|
193
196
|
|
|
194
197
|
The composition tests run the real ESLint CLI on temporary workspaces. They load the built package, which is what consumers install.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-checks.d.ts","sourceRoot":"","sources":["../../src/manifest/dependency-checks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"dependency-checks.d.ts","sourceRoot":"","sources":["../../src/manifest/dependency-checks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AA0DnC;;;;;;GAMG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA2ChB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -2,6 +2,7 @@ import nx from '@nx/eslint-plugin';
|
|
|
2
2
|
import { isRecord, stringsAt } from "../authoring/ast.js";
|
|
3
3
|
import { ruleOf } from "../authoring/rule-module.js";
|
|
4
4
|
import { inIsland } from "../island/island-scope.js";
|
|
5
|
+
import { cachedProjectGraph, projectNodeAt, } from "../workspace/cached-project-graph.js";
|
|
5
6
|
import { projectOf } from "../workspace/project-manifest.js";
|
|
6
7
|
import { manifestPolicy, } from "./manifest-policy.js";
|
|
7
8
|
const nxDependencyChecks = ruleOf(nx, 'dependency-checks');
|
|
@@ -80,7 +81,12 @@ const rule = {
|
|
|
80
81
|
const project = projectOf(context.physicalFilename);
|
|
81
82
|
if (!project || inIsland(context))
|
|
82
83
|
return {};
|
|
83
|
-
|
|
84
|
+
// Nx's rule checks nothing without the graph or a project in it.
|
|
85
|
+
const graph = cachedProjectGraph();
|
|
86
|
+
const node = graph && projectNodeAt(graph, project.root);
|
|
87
|
+
if (!graph || !node)
|
|
88
|
+
return {};
|
|
89
|
+
const options = manifestPolicy(graph, node, optionsOf(context.options[0]));
|
|
84
90
|
const projectContext = Object.create(context, {
|
|
85
91
|
options: { value: [options] },
|
|
86
92
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-checks.js","sourceRoot":"","sources":["../../src/manifest/dependency-checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGnC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,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CAAC;QACpD,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,CAAC;QAC7C,iEAAiE;QACjE,MAAM,KAAK,GAAG,kBAAkB,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,MAAM,cAAc,GAAqB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;YAC9D,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE;SAC9B,CAAC,CAAC;QACH,OAAO,kBAAkB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACnD,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProjectGraph, ProjectGraphProjectNode } from '@nx/devkit';
|
|
1
2
|
import { type DependencyPolicyOptions } from '../nx-policy/dependency-policy.ts';
|
|
2
3
|
export interface ProjectExtras {
|
|
3
4
|
/** Packages this project's manifest may leave out, on top of the repo's. */
|
|
@@ -9,13 +10,12 @@ export interface ManifestPolicyOptions extends Omit<DependencyPolicyOptions, 'in
|
|
|
9
10
|
projects?: Record<string, ProjectExtras>;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
* The complete `@nx/dependency-checks` options for the
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* themselves, which its build inlines.
|
|
13
|
+
* The complete `@nx/dependency-checks` options for `project`: the shared
|
|
14
|
+
* policy, the repo's entries, the project's own extras, and what its shape
|
|
15
|
+
* demands. A bundled project declares the npm packages its workspace imports
|
|
16
|
+
* pull in. No project declares the workspace packages its build inlines.
|
|
17
17
|
*/
|
|
18
|
-
export declare function manifestPolicy(
|
|
18
|
+
export declare function manifestPolicy(graph: ProjectGraph, project: ProjectGraphProjectNode, { projects, ignoredDependencies, ...options }?: ManifestPolicyOptions): {
|
|
19
19
|
ignoredFiles: string[];
|
|
20
20
|
ignoredDependencies: string[];
|
|
21
21
|
includeTransitiveDependencies: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-policy.d.ts","sourceRoot":"","sources":["../../src/manifest/manifest-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest-policy.d.ts","sourceRoot":"","sources":["../../src/manifest/manifest-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAExE,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,mCAAmC,CAAC;AAG3C,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,8FAA8F;AAC9F,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,uBAAuB,EACvB,+BAA+B,CAChC;IACC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,uBAAuB,EAChC,EACE,QAAa,EACb,mBAAwB,EACxB,GAAG,OAAO,EACX,GAAE,qBAA0B;;;;;;;;EAY9B"}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { relative, sep } from 'node:path';
|
|
2
1
|
import { dependencyPolicy, } from "../nx-policy/dependency-policy.js";
|
|
3
|
-
import {
|
|
4
|
-
import { workspaceRootOf } from "../workspace/workspace-root.js";
|
|
5
|
-
import { projectShape } from "./project-shape.js";
|
|
2
|
+
import { ProjectBuild } from "./project-build.js";
|
|
6
3
|
/**
|
|
7
|
-
* The complete `@nx/dependency-checks` options for the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* themselves, which its build inlines.
|
|
4
|
+
* The complete `@nx/dependency-checks` options for `project`: the shared
|
|
5
|
+
* policy, the repo's entries, the project's own extras, and what its shape
|
|
6
|
+
* demands. A bundled project declares the npm packages its workspace imports
|
|
7
|
+
* pull in. No project declares the workspace packages its build inlines.
|
|
12
8
|
*/
|
|
13
|
-
export function manifestPolicy(
|
|
14
|
-
const
|
|
15
|
-
const folder = relative(workspaceRoot, projectRoot).split(sep).join('/');
|
|
16
|
-
const bundled = projectShape(projectRoot) === 'bundled';
|
|
9
|
+
export function manifestPolicy(graph, project, { projects = {}, ignoredDependencies = [], ...options } = {}) {
|
|
10
|
+
const build = new ProjectBuild(graph, project);
|
|
17
11
|
return dependencyPolicy({
|
|
18
12
|
...options,
|
|
19
|
-
includeTransitiveDependencies: bundled,
|
|
13
|
+
includeTransitiveDependencies: build.shape === 'bundled',
|
|
20
14
|
ignoredDependencies: [
|
|
21
|
-
...
|
|
15
|
+
...build.inlined,
|
|
22
16
|
...ignoredDependencies,
|
|
23
|
-
...(projects[
|
|
17
|
+
...(projects[project.data.root]?.ignoredDependencies ?? []),
|
|
24
18
|
],
|
|
25
19
|
});
|
|
26
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-policy.js","sourceRoot":"","sources":["../../src/manifest/manifest-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest-policy.js","sourceRoot":"","sources":["../../src/manifest/manifest-policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gBAAgB,GACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgBlD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAmB,EACnB,OAAgC,EAChC,EACE,QAAQ,GAAG,EAAE,EACb,mBAAmB,GAAG,EAAE,EACxB,GAAG,OAAO,KACe,EAAE;IAE7B,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO,gBAAgB,CAAC;QACtB,GAAG,OAAO;QACV,6BAA6B,EAAE,KAAK,CAAC,KAAK,KAAK,SAAS;QACxD,mBAAmB,EAAE;YACnB,GAAG,KAAK,CAAC,OAAO;YAChB,GAAG,mBAAmB;YACtB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,mBAAmB,IAAI,EAAE,CAAC;SAC5D;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ProjectGraph, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* What a project's package.json must declare.
|
|
4
|
+
*
|
|
5
|
+
* - `bundled`: an application whose build inlines the workspace packages it
|
|
6
|
+
* imports. Their manifests are not there when it is deployed, so its own
|
|
7
|
+
* manifest declares every npm package they pull in, transitively.
|
|
8
|
+
* - `unbundled`: everything else. It declares only what its own code imports;
|
|
9
|
+
* whoever installs it resolves the rest.
|
|
10
|
+
*/
|
|
11
|
+
export type ProjectShape = 'bundled' | 'unbundled';
|
|
12
|
+
/**
|
|
13
|
+
* How one project's build ships the workspace packages, read from the project
|
|
14
|
+
* as Nx resolves it: project.json, the target defaults in nx.json, and the
|
|
15
|
+
* targets that Nx plugins infer.
|
|
16
|
+
*
|
|
17
|
+
* An application bundles unless its build is `nx:noop` (it ships what other
|
|
18
|
+
* projects built), esbuild with `bundle: false` (it transpiles file by file),
|
|
19
|
+
* or esbuild that leaves a workspace package it imports to node_modules (it
|
|
20
|
+
* installs that package, and inlines only the others). esbuild bundles by
|
|
21
|
+
* default.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ProjectBuild {
|
|
24
|
+
readonly shape: ProjectShape;
|
|
25
|
+
/** The workspace packages the build copies into its output. The project's manifest never declares them. */
|
|
26
|
+
readonly inlined: readonly string[];
|
|
27
|
+
constructor(graph: ProjectGraph, project: ProjectGraphProjectNode);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=project-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-build.d.ts","sourceRoot":"","sources":["../../src/manifest/project-build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAKxE;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;AA4BnD;;;;;;;;;;GAUG;AACH,qBAAa,YAAY;IACvB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,2GAA2G;IAC3G,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;gBAExB,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,uBAAuB;CAyBlE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isRecord, stringsAt } from "../authoring/ast.js";
|
|
2
|
+
import { workspacePackageName } from "../workspace/cached-project-graph.js";
|
|
3
|
+
/**
|
|
4
|
+
* The patterns esbuild leaves to node_modules, as Nx hands them over:
|
|
5
|
+
* `esbuildOptions.external` and `external`, less `excludeFromExternal`.
|
|
6
|
+
*/
|
|
7
|
+
function esbuildExternals(options) {
|
|
8
|
+
if (!isRecord(options))
|
|
9
|
+
return [];
|
|
10
|
+
const excluded = new Set(stringsAt(options, 'excludeFromExternal'));
|
|
11
|
+
return [
|
|
12
|
+
...stringsAt(options['esbuildOptions'], 'external'),
|
|
13
|
+
...stringsAt(options, 'external'),
|
|
14
|
+
].filter((pattern) => !excluded.has(pattern));
|
|
15
|
+
}
|
|
16
|
+
/** esbuild's rule: a pattern has at most one `*`, which stands for any text. */
|
|
17
|
+
function matchesExternal(name, pattern) {
|
|
18
|
+
const star = pattern.indexOf('*');
|
|
19
|
+
if (star === -1)
|
|
20
|
+
return name === pattern;
|
|
21
|
+
const prefix = pattern.slice(0, star);
|
|
22
|
+
const suffix = pattern.slice(star + 1);
|
|
23
|
+
return (name.length >= prefix.length + suffix.length &&
|
|
24
|
+
name.startsWith(prefix) &&
|
|
25
|
+
name.endsWith(suffix));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* How one project's build ships the workspace packages, read from the project
|
|
29
|
+
* as Nx resolves it: project.json, the target defaults in nx.json, and the
|
|
30
|
+
* targets that Nx plugins infer.
|
|
31
|
+
*
|
|
32
|
+
* An application bundles unless its build is `nx:noop` (it ships what other
|
|
33
|
+
* projects built), esbuild with `bundle: false` (it transpiles file by file),
|
|
34
|
+
* or esbuild that leaves a workspace package it imports to node_modules (it
|
|
35
|
+
* installs that package, and inlines only the others). esbuild bundles by
|
|
36
|
+
* default.
|
|
37
|
+
*/
|
|
38
|
+
export class ProjectBuild {
|
|
39
|
+
shape;
|
|
40
|
+
/** The workspace packages the build copies into its output. The project's manifest never declares them. */
|
|
41
|
+
inlined;
|
|
42
|
+
constructor(graph, project) {
|
|
43
|
+
const build = project.data.targets?.['build'];
|
|
44
|
+
const esbuild = build?.executor?.includes('esbuild') === true;
|
|
45
|
+
if (project.data.projectType !== 'application' ||
|
|
46
|
+
build?.executor === 'nx:noop' ||
|
|
47
|
+
(esbuild && build?.options?.bundle === false)) {
|
|
48
|
+
this.shape = 'unbundled';
|
|
49
|
+
this.inlined = [];
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const externals = esbuild ? esbuildExternals(build?.options) : [];
|
|
53
|
+
const external = (name) => externals.some((pattern) => matchesExternal(name, pattern));
|
|
54
|
+
const installs = graph.dependencies[project.name]?.some(({ target }) => {
|
|
55
|
+
const dependency = graph.nodes[target];
|
|
56
|
+
const name = dependency && workspacePackageName(dependency);
|
|
57
|
+
return name !== undefined && external(name);
|
|
58
|
+
});
|
|
59
|
+
this.shape = installs ? 'unbundled' : 'bundled';
|
|
60
|
+
this.inlined = Object.values(graph.nodes)
|
|
61
|
+
.flatMap((node) => workspacePackageName(node) ?? [])
|
|
62
|
+
.filter((name) => !external(name));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=project-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-build.js","sourceRoot":"","sources":["../../src/manifest/project-build.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAa5E;;;GAGG;AACH,SAAS,gBAAgB,CAAC,OAAgB;IACxC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACpE,OAAO;QACL,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC;QACnD,GAAG,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC;KAClC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,gFAAgF;AAChF,SAAS,eAAe,CAAC,IAAY,EAAE,OAAe;IACpD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,KAAK,OAAO,CAAC;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,OAAO,C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AAE;YACrE,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,UAAU,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;YAC5D,OAAO,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;aACtC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aACnD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC;CACF"}
|
package/dist/nx.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default } from './island/plugin.ts';
|
|
2
2
|
export { default as manifest } from './manifest/plugin.ts';
|
|
3
3
|
export { manifestPolicy, type ManifestPolicyOptions, type ProjectExtras, } from './manifest/manifest-policy.ts';
|
|
4
|
-
export {
|
|
4
|
+
export { ProjectBuild, type ProjectShape } from './manifest/project-build.ts';
|
|
5
5
|
export { dependencyPolicy, type DependencyPolicyOptions, } from './nx-policy/dependency-policy.ts';
|
|
6
6
|
export { ISLAND_TAG, islandConstraint } from './nx-policy/island-constraint.ts';
|
|
7
7
|
export { type DepConstraint, moduleBoundaries, type ModuleBoundaryOptions, } from './nx-policy/module-boundaries.ts';
|
package/dist/nx.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default } from "./island/plugin.js";
|
|
2
2
|
export { default as manifest } from "./manifest/plugin.js";
|
|
3
3
|
export { manifestPolicy, } from "./manifest/manifest-policy.js";
|
|
4
|
-
export {
|
|
4
|
+
export { ProjectBuild } from "./manifest/project-build.js";
|
|
5
5
|
export { dependencyPolicy, } from "./nx-policy/dependency-policy.js";
|
|
6
6
|
export { ISLAND_TAG, islandConstraint } from "./nx-policy/island-constraint.js";
|
|
7
7
|
export { moduleBoundaries, } from "./nx-policy/module-boundaries.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ProjectGraph, type ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* The project graph that `nx` caches, read as Nx's own lint rules read it.
|
|
4
|
+
* There is none before Nx builds one, as on a fresh clone; Nx's rules then
|
|
5
|
+
* skip their checks.
|
|
6
|
+
*/
|
|
7
|
+
export declare function cachedProjectGraph(): ProjectGraph | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* The npm name of a workspace project, from the package.json in its folder:
|
|
10
|
+
* the name Nx's dependency-checks demands for it. The graph's own metadata
|
|
11
|
+
* leaves it out for some projects.
|
|
12
|
+
*/
|
|
13
|
+
export declare function workspacePackageName(node: ProjectGraphProjectNode): string | undefined;
|
|
14
|
+
/** The graph's project whose folder is `projectRoot`, an absolute path. */
|
|
15
|
+
export declare function projectNodeAt(graph: ProjectGraph, projectRoot: string): ProjectGraphProjectNode | undefined;
|
|
16
|
+
//# sourceMappingURL=cached-project-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-project-graph.d.ts","sourceRoot":"","sources":["../../src/workspace/cached-project-graph.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAG7B,MAAM,YAAY,CAAC;AAKpB;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,GAAG,SAAS,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,uBAAuB,GAC5B,MAAM,GAAG,SAAS,CAMpB;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAC3B,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,GAClB,uBAAuB,GAAG,SAAS,CAIrC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { join, resolve } from 'node:path';
|
|
2
|
+
import { readCachedProjectGraph, workspaceRoot, } from '@nx/devkit';
|
|
3
|
+
import { isRecord } from "../authoring/ast.js";
|
|
4
|
+
import { readJson } from "./project-manifest.js";
|
|
5
|
+
/**
|
|
6
|
+
* The project graph that `nx` caches, read as Nx's own lint rules read it.
|
|
7
|
+
* There is none before Nx builds one, as on a fresh clone; Nx's rules then
|
|
8
|
+
* skip their checks.
|
|
9
|
+
*/
|
|
10
|
+
export function cachedProjectGraph() {
|
|
11
|
+
try {
|
|
12
|
+
return readCachedProjectGraph();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The npm name of a workspace project, from the package.json in its folder:
|
|
20
|
+
* the name Nx's dependency-checks demands for it. The graph's own metadata
|
|
21
|
+
* leaves it out for some projects.
|
|
22
|
+
*/
|
|
23
|
+
export function workspacePackageName(node) {
|
|
24
|
+
const manifest = readJson(join(workspaceRoot, node.data.root, 'package.json'));
|
|
25
|
+
const name = isRecord(manifest) ? manifest['name'] : undefined;
|
|
26
|
+
return typeof name === 'string' ? name : undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The graph's project whose folder is `projectRoot`, an absolute path. */
|
|
29
|
+
export function projectNodeAt(graph, projectRoot) {
|
|
30
|
+
return Object.values(graph.nodes).find((node) => resolve(workspaceRoot, node.data.root) === projectRoot);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=cached-project-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-project-graph.js","sourceRoot":"","sources":["../../src/workspace/cached-project-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAGL,sBAAsB,EACtB,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC;QACH,OAAO,sBAAsB,EAAE,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAA6B;IAE7B,MAAM,QAAQ,GAAG,QAAQ,CACvB,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CACpD,CAAC;IACF,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAC3B,KAAmB,EACnB,WAAmB;IAEnB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CACpC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,WAAW,CACjE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/eslint",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "ESLint rules and configs shared across workspaces. Every check is its own named rule, so a repo's own config cannot silently erase it.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,16 +23,19 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
"./package.json": "./package.json",
|
|
25
25
|
".": {
|
|
26
|
+
"@zukhruf/source": "./src/index.ts",
|
|
26
27
|
"types": "./dist/index.d.ts",
|
|
27
28
|
"import": "./dist/index.js",
|
|
28
29
|
"default": "./dist/index.js"
|
|
29
30
|
},
|
|
30
31
|
"./nx": {
|
|
32
|
+
"@zukhruf/source": "./src/nx.ts",
|
|
31
33
|
"types": "./dist/nx.d.ts",
|
|
32
34
|
"import": "./dist/nx.js",
|
|
33
35
|
"default": "./dist/nx.js"
|
|
34
36
|
},
|
|
35
37
|
"./react-native": {
|
|
38
|
+
"@zukhruf/source": "./src/react-native.ts",
|
|
36
39
|
"types": "./dist/react-native.d.ts",
|
|
37
40
|
"import": "./dist/react-native.js",
|
|
38
41
|
"default": "./dist/react-native.js"
|
|
@@ -55,6 +58,7 @@
|
|
|
55
58
|
},
|
|
56
59
|
"peerDependencies": {
|
|
57
60
|
"@eslint/js": "^9.30.0 || ^10.0.0",
|
|
61
|
+
"@nx/devkit": ">=21.0.0",
|
|
58
62
|
"@nx/eslint-plugin": ">=21.0.0",
|
|
59
63
|
"eslint": "^9.30.0 || ^10.0.0",
|
|
60
64
|
"eslint-plugin-es-x": "^9.7.0 || ^10.0.0",
|
|
@@ -65,6 +69,9 @@
|
|
|
65
69
|
"typescript-eslint": "^8.47.0"
|
|
66
70
|
},
|
|
67
71
|
"peerDependenciesMeta": {
|
|
72
|
+
"@nx/devkit": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
68
75
|
"@nx/eslint-plugin": {
|
|
69
76
|
"optional": true
|
|
70
77
|
},
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What a project's package.json must declare.
|
|
3
|
-
*
|
|
4
|
-
* - `bundled`: an application whose build inlines the workspace packages it
|
|
5
|
-
* imports. Their manifests are not there when it is deployed, so its own
|
|
6
|
-
* manifest declares every npm package they pull in, transitively.
|
|
7
|
-
* - `unbundled`: everything else. It declares only what its own code imports;
|
|
8
|
-
* whoever installs it resolves the rest.
|
|
9
|
-
*/
|
|
10
|
-
export type ProjectShape = 'bundled' | 'unbundled';
|
|
11
|
-
/**
|
|
12
|
-
* The shape of the project at `projectRoot`, from its build target. An
|
|
13
|
-
* application bundles unless its build is `nx:noop` (it ships what other
|
|
14
|
-
* projects built) or esbuild with `bundle: false` (it transpiles file by file).
|
|
15
|
-
* esbuild bundles by default. A build target that an Nx plugin infers, such as
|
|
16
|
-
* Vite's, is not in project.json, and counts as bundling.
|
|
17
|
-
*/
|
|
18
|
-
export declare function projectShape(projectRoot: string): ProjectShape;
|
|
19
|
-
//# sourceMappingURL=project-shape.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-shape.d.ts","sourceRoot":"","sources":["../../src/manifest/project-shape.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;AAWnD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAc9D"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { isRecord } from "../authoring/ast.js";
|
|
3
|
-
import { readJson } from "../workspace/project-manifest.js";
|
|
4
|
-
/** project.json, or the `nx` field of package.json for a project without one. */
|
|
5
|
-
function nxConfiguration(projectRoot) {
|
|
6
|
-
const projectJson = readJson(join(projectRoot, 'project.json'));
|
|
7
|
-
if (isRecord(projectJson))
|
|
8
|
-
return projectJson;
|
|
9
|
-
const packageJson = readJson(join(projectRoot, 'package.json'));
|
|
10
|
-
const nx = isRecord(packageJson) ? packageJson['nx'] : undefined;
|
|
11
|
-
return isRecord(nx) ? nx : {};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The shape of the project at `projectRoot`, from its build target. An
|
|
15
|
-
* application bundles unless its build is `nx:noop` (it ships what other
|
|
16
|
-
* projects built) or esbuild with `bundle: false` (it transpiles file by file).
|
|
17
|
-
* esbuild bundles by default. A build target that an Nx plugin infers, such as
|
|
18
|
-
* Vite's, is not in project.json, and counts as bundling.
|
|
19
|
-
*/
|
|
20
|
-
export function projectShape(projectRoot) {
|
|
21
|
-
const project = nxConfiguration(projectRoot);
|
|
22
|
-
if (project['projectType'] !== 'application')
|
|
23
|
-
return 'unbundled';
|
|
24
|
-
const targets = project['targets'];
|
|
25
|
-
const build = isRecord(targets) ? targets['build'] : undefined;
|
|
26
|
-
const executor = isRecord(build) ? build['executor'] : undefined;
|
|
27
|
-
if (executor === 'nx:noop')
|
|
28
|
-
return 'unbundled';
|
|
29
|
-
if (typeof executor === 'string' && executor.includes('esbuild')) {
|
|
30
|
-
const options = isRecord(build) ? build['options'] : undefined;
|
|
31
|
-
return isRecord(options) && options['bundle'] === false
|
|
32
|
-
? 'unbundled'
|
|
33
|
-
: 'bundled';
|
|
34
|
-
}
|
|
35
|
-
return 'bundled';
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=project-shape.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-shape.js","sourceRoot":"","sources":["../../src/manifest/project-shape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAa5D,iFAAiF;AACjF,SAAS,eAAe,CAAC,WAAmB;IAC1C,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;IAChE,IAAI,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,WAAW,CAAC;IAC9C,MAAM,WAAW,GAAG,QAAQ,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+0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The name of every package in the workspace, the root manifest aside. The
|
|
3
|
-
* folders are scanned, not the root `workspaces` globs: a single-level `*`
|
|
4
|
-
* there misses nested packages.
|
|
5
|
-
*/
|
|
6
|
-
export declare function workspacePackages(workspaceRoot: string): readonly string[];
|
|
7
|
-
//# sourceMappingURL=workspace-packages.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-packages.d.ts","sourceRoot":"","sources":["../../src/workspace/workspace-packages.ts"],"names":[],"mappings":"AA0BA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAM1E"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { globSync } from 'node:fs';
|
|
2
|
-
import { basename, join } from 'node:path';
|
|
3
|
-
import { isRecord } from "../authoring/ast.js";
|
|
4
|
-
import { readJson } from "./project-manifest.js";
|
|
5
|
-
// Build output, installed packages, and dot-folders (worktrees of other
|
|
6
|
-
// checkouts among them) hold manifests that are not this workspace's packages.
|
|
7
|
-
const skipped = (path) => {
|
|
8
|
-
const name = basename(path);
|
|
9
|
-
return name === 'node_modules' || name === 'dist' || name.startsWith('.');
|
|
10
|
-
};
|
|
11
|
-
// One scan per workspace for the life of the process.
|
|
12
|
-
const packagesByRoot = new Map();
|
|
13
|
-
function scan(workspaceRoot) {
|
|
14
|
-
return globSync('**/package.json', { cwd: workspaceRoot, exclude: skipped })
|
|
15
|
-
.filter((path) => path !== 'package.json')
|
|
16
|
-
.flatMap((path) => {
|
|
17
|
-
const manifest = readJson(join(workspaceRoot, path));
|
|
18
|
-
const name = isRecord(manifest) ? manifest['name'] : undefined;
|
|
19
|
-
return typeof name === 'string' ? [name] : [];
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The name of every package in the workspace, the root manifest aside. The
|
|
24
|
-
* folders are scanned, not the root `workspaces` globs: a single-level `*`
|
|
25
|
-
* there misses nested packages.
|
|
26
|
-
*/
|
|
27
|
-
export function workspacePackages(workspaceRoot) {
|
|
28
|
-
const known = packagesByRoot.get(workspaceRoot);
|
|
29
|
-
if (known)
|
|
30
|
-
return known;
|
|
31
|
-
const names = scan(workspaceRoot);
|
|
32
|
-
packagesByRoot.set(workspaceRoot, names);
|
|
33
|
-
return names;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=workspace-packages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-packages.js","sourceRoot":"","sources":["../../src/workspace/workspace-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,wEAAwE;AACxE,+EAA+E;AAC/E,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE;IAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,sDAAsD;AACtD,MAAM,cAAc,GAAG,IAAI,GAAG,EAA6B,CAAC;AAE5D,SAAS,IAAI,CAAC,aAAqB;IACjC,OAAO,QAAQ,CAAC,iBAAiB,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;SACzE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC;SACzC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,MAAM,QAAQ,GAAG,QAAQ,CAAC,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