@zukhruf/eslint 0.8.22 → 0.8.24
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 +3 -1
- package/dist/nx-project/command-scripts.d.ts +12 -0
- package/dist/nx-project/command-scripts.d.ts.map +1 -0
- package/dist/nx-project/command-scripts.js +127 -0
- package/dist/nx-project/command-scripts.js.map +1 -0
- package/dist/nx-project/config.d.ts.map +1 -1
- package/dist/nx-project/config.js +5 -1
- package/dist/nx-project/config.js.map +1 -1
- package/dist/nx-project/no-missing-dependency-build.d.ts +10 -0
- package/dist/nx-project/no-missing-dependency-build.d.ts.map +1 -0
- package/dist/nx-project/no-missing-dependency-build.js +247 -0
- package/dist/nx-project/no-missing-dependency-build.js.map +1 -0
- package/dist/nx-project/package-entry.d.ts +11 -0
- package/dist/nx-project/package-entry.d.ts.map +1 -0
- package/dist/nx-project/package-entry.js +74 -0
- package/dist/nx-project/package-entry.js.map +1 -0
- package/dist/nx-project/static-imports.d.ts +9 -0
- package/dist/nx-project/static-imports.d.ts.map +1 -0
- package/dist/nx-project/static-imports.js +88 -0
- package/dist/nx-project/static-imports.js.map +1 -0
- package/dist/nx-project/task-closure.d.ts +8 -0
- package/dist/nx-project/task-closure.d.ts.map +1 -0
- package/dist/nx-project/task-closure.js +84 -0
- package/dist/nx-project/task-closure.js.map +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +2 -10
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Put framework configs (for example [`@zukhruf/eslint/react`](#react)) **before**
|
|
|
53
53
|
| `better-auth` | TypeScript, not tests | `no-api-error-instanceof`, `no-on-api-error-throw` |
|
|
54
54
|
| `tailwind` | source | `no-h-screen`, `no-arbitrary-z-index`, `no-will-change` |
|
|
55
55
|
| `pulumi` | TypeScript | `require-server-replace-guard` |
|
|
56
|
-
| `nx-project-json` | `project.json` | `no-missing-asset-input`
|
|
56
|
+
| `nx-project-json` | `project.json` | `no-missing-asset-input`, `no-missing-dependency-build` |
|
|
57
57
|
|
|
58
58
|
`base` turns on typed lint (`parserOptions.projectService`). Each linted TypeScript file must be in a tsconfig.
|
|
59
59
|
|
|
@@ -81,6 +81,8 @@ A lazy memo is not a phase, so the rule does not report it. In a lazy memo, each
|
|
|
81
81
|
|
|
82
82
|
`zukhruf/no-on-api-error-throw` reports `onAPIError: { throw: true }`. With this option, better-auth throws the error again before `onAPIError.onError` and before its own log. The router of better-call catches that error and makes a response from it, so the error handler of the app does not run, and no log shows a 4xx error. Log the error in `onAPIError.onError`.
|
|
83
83
|
|
|
84
|
+
`zukhruf/no-missing-dependency-build` reports a target of a `project.json` that runs a file with `node` or `tsx` when that file imports a workspace package that Node loads from the outputs of the package's `build`, and the target does not run after that build. Locally an old `dist` hides the gap; a clean checkout fails with `ERR_MODULE_NOT_FOUND`. The rule reads the commands of `nx:run-commands` and the package.json script of `nx:run-script`, and the test files of `node --test`, globs included. It follows relative imports from file to file, and the source of a workspace package whose entry is source, as with `--conditions=development`. It resolves each package's `exports` with the command's `--conditions` and Node's own. `import type` loads nothing, so it does not count. A target runs after the build when its `dependsOn`, as Nx resolves it from the cached project graph, reaches that build: `^build`, a target default in `nx.json`, or a target of the same project that depends on `^build`. Without a cached graph, as on a fresh clone, the rule checks nothing. The suggestion adds `"^build"` to `dependsOn`.
|
|
85
|
+
|
|
84
86
|
### Options for a repo
|
|
85
87
|
|
|
86
88
|
Give repo-specific values as rule options. For example:
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A file that one command of a target hands to Node, with the conditions it resolves packages under. */
|
|
2
|
+
export interface Script {
|
|
3
|
+
readonly file: string;
|
|
4
|
+
readonly conditions: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The files that `line`, run from `cwd`, hands to `node` or `tsx` as the
|
|
8
|
+
* script, and the test files of `node --test`, globs expanded as Node expands
|
|
9
|
+
* them. With `node -e`, the code is the first positional, so no file runs.
|
|
10
|
+
*/
|
|
11
|
+
export declare function scriptsRun(line: string, cwd: string): Script[];
|
|
12
|
+
//# sourceMappingURL=command-scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-scripts.d.ts","sourceRoot":"","sources":["../../src/nx-project/command-scripts.ts"],"names":[],"mappings":"AAGA,yGAAyG;AACzG,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AA6GD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAE9D"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { existsSync, globSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
const RUNNERS = new Set(['node', 'tsx']);
|
|
4
|
+
// Node flags whose value is the next word: the value is never the script.
|
|
5
|
+
const VALUE_FLAGS = new Set([
|
|
6
|
+
'--import',
|
|
7
|
+
'-r',
|
|
8
|
+
'--require',
|
|
9
|
+
'--env-file',
|
|
10
|
+
'--env-file-if-exists',
|
|
11
|
+
'--loader',
|
|
12
|
+
'--experimental-loader',
|
|
13
|
+
'--input-type',
|
|
14
|
+
'--test-reporter',
|
|
15
|
+
'--test-reporter-destination',
|
|
16
|
+
'--test-name-pattern',
|
|
17
|
+
'--test-skip-pattern',
|
|
18
|
+
'--test-concurrency',
|
|
19
|
+
'--test-timeout',
|
|
20
|
+
'--watch-path',
|
|
21
|
+
'--tsconfig',
|
|
22
|
+
]);
|
|
23
|
+
const SCRIPT = /\.(?:[cm]?ts|[cm]?js)$/;
|
|
24
|
+
const GLOB = /[*?[{]/;
|
|
25
|
+
const OPERATOR = /^(?:&&|\|\||[;|&\n])/;
|
|
26
|
+
const ENV_ASSIGNMENT = /^[A-Za-z_]\w*=/;
|
|
27
|
+
/**
|
|
28
|
+
* The simple commands of a shell command line, each as its words: quotes are
|
|
29
|
+
* removed, and `&&`, `||`, `;`, `|` and `&` end a command.
|
|
30
|
+
*/
|
|
31
|
+
function simpleCommands(line) {
|
|
32
|
+
const commands = [[]];
|
|
33
|
+
let word;
|
|
34
|
+
let quote;
|
|
35
|
+
const endWord = () => {
|
|
36
|
+
if (word !== undefined)
|
|
37
|
+
commands.at(-1)?.push(word);
|
|
38
|
+
word = undefined;
|
|
39
|
+
};
|
|
40
|
+
for (let index = 0; index < line.length; index++) {
|
|
41
|
+
const char = line.charAt(index);
|
|
42
|
+
if (quote) {
|
|
43
|
+
if (char === quote)
|
|
44
|
+
quote = undefined;
|
|
45
|
+
else if (char === '\\' && quote === '"' && index + 1 < line.length) {
|
|
46
|
+
index++;
|
|
47
|
+
word = (word ?? '') + line.charAt(index);
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
word = (word ?? '') + char;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const operator = OPERATOR.exec(line.slice(index))?.[0];
|
|
54
|
+
if (operator) {
|
|
55
|
+
endWord();
|
|
56
|
+
commands.push([]);
|
|
57
|
+
index += operator.length - 1;
|
|
58
|
+
}
|
|
59
|
+
else if (char === '"' || char === "'") {
|
|
60
|
+
quote = char;
|
|
61
|
+
word ??= '';
|
|
62
|
+
}
|
|
63
|
+
else if (char === '\\' && index + 1 < line.length) {
|
|
64
|
+
index++;
|
|
65
|
+
word = (word ?? '') + line.charAt(index);
|
|
66
|
+
}
|
|
67
|
+
else if (/\s/.test(char)) {
|
|
68
|
+
endWord();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
word = (word ?? '') + char;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
endWord();
|
|
75
|
+
return commands.filter((words) => words.length > 0);
|
|
76
|
+
}
|
|
77
|
+
function scriptsOf(words, cwd) {
|
|
78
|
+
let index = 0;
|
|
79
|
+
while (ENV_ASSIGNMENT.test(words[index] ?? ''))
|
|
80
|
+
index++;
|
|
81
|
+
if (words[index] === 'npx')
|
|
82
|
+
index++;
|
|
83
|
+
if (!RUNNERS.has(words[index] ?? ''))
|
|
84
|
+
return [];
|
|
85
|
+
const conditions = [];
|
|
86
|
+
const positionals = [];
|
|
87
|
+
let test = false;
|
|
88
|
+
for (index++; index < words.length; index++) {
|
|
89
|
+
const word = words[index] ?? '';
|
|
90
|
+
if (word === '--test') {
|
|
91
|
+
test = true;
|
|
92
|
+
}
|
|
93
|
+
else if (word === '--conditions' || word === '-C') {
|
|
94
|
+
index++;
|
|
95
|
+
conditions.push(words[index] ?? '');
|
|
96
|
+
}
|
|
97
|
+
else if (word.startsWith('--conditions=')) {
|
|
98
|
+
conditions.push(word.slice('--conditions='.length));
|
|
99
|
+
}
|
|
100
|
+
else if (VALUE_FLAGS.has(word)) {
|
|
101
|
+
index++;
|
|
102
|
+
}
|
|
103
|
+
else if (!word.startsWith('-')) {
|
|
104
|
+
positionals.push(word);
|
|
105
|
+
// Without --test the first positional is the script; the rest are its arguments.
|
|
106
|
+
if (!test)
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const files = test
|
|
111
|
+
? positionals.flatMap((word) => GLOB.test(word) ? globSync(word, { cwd }) : [word])
|
|
112
|
+
: positionals.slice(0, 1);
|
|
113
|
+
return files
|
|
114
|
+
.filter((file) => SCRIPT.test(file))
|
|
115
|
+
.map((file) => resolve(cwd, file))
|
|
116
|
+
.filter((file) => existsSync(file))
|
|
117
|
+
.map((file) => ({ file, conditions }));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The files that `line`, run from `cwd`, hands to `node` or `tsx` as the
|
|
121
|
+
* script, and the test files of `node --test`, globs expanded as Node expands
|
|
122
|
+
* them. With `node -e`, the code is the first positional, so no file runs.
|
|
123
|
+
*/
|
|
124
|
+
export function scriptsRun(line, cwd) {
|
|
125
|
+
return simpleCommands(line).flatMap((words) => scriptsOf(words, cwd));
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=command-scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-scripts.js","sourceRoot":"","sources":["../../src/nx-project/command-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAEzC,0EAA0E;AAC1E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,UAAU;IACV,IAAI;IACJ,WAAW;IACX,YAAY;IACZ,sBAAsB;IACtB,UAAU;IACV,uBAAuB;IACvB,cAAc;IACd,iBAAiB;IACjB,6BAA6B;IAC7B,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;IACpB,gBAAgB;IAChB,cAAc;IACd,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,wBAAwB,CAAC;AACxC,MAAM,IAAI,GAAG,QAAQ,CAAC;AACtB,MAAM,QAAQ,GAAG,sBAAsB,CAAC;AACxC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC;;;GAGG;AACH,SAAS,cAAc,CAAC,IAAY;IAClC,MAAM,QAAQ,GAAe,CAAC,EAAE,CAAC,CAAC;IAClC,IAAI,IAAwB,CAAC;IAC7B,IAAI,KAAyB,CAAC;IAC9B,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,IAAI,IAAI,KAAK,SAAS;YAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC,CAAC;IACF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG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,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/nx-project/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/nx-project/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,eAAe,CAAC;AAUrD,iGAAiG;AACjG,eAAO,MAAM,aAAa,EAAE,OAY3B,CAAC"}
|
|
@@ -2,7 +2,11 @@ import * as jsonc from 'jsonc-eslint-parser';
|
|
|
2
2
|
import { enable } from "../concept.js";
|
|
3
3
|
import { PROJECT_JSON } from "../files.js";
|
|
4
4
|
import noMissingAssetInput from "./no-missing-asset-input.js";
|
|
5
|
-
|
|
5
|
+
import noMissingDependencyBuild from "./no-missing-dependency-build.js";
|
|
6
|
+
const rules = {
|
|
7
|
+
'no-missing-asset-input': noMissingAssetInput,
|
|
8
|
+
'no-missing-dependency-build': noMissingDependencyBuild,
|
|
9
|
+
};
|
|
6
10
|
/** Nx project.json files: target options that Nx reads without complaint when they are wrong. */
|
|
7
11
|
export const nxProjectJson = {
|
|
8
12
|
name: 'nx-project-json',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/nx-project/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/nx-project/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAC9D,OAAO,wBAAwB,MAAM,kCAAkC,CAAC;AAExE,MAAM,KAAK,GAAG;IACZ,wBAAwB,EAAE,mBAAmB;IAC7C,6BAA6B,EAAE,wBAAwB;CACxD,CAAC;AAEF,iGAAiG;AACjG,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,IAAI,EAAE,iBAAiB;IACvB,KAAK;IACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,EAAE,IAAI,EAAE,iCAAiC,EAAE,OAAO,EAAE;QACpD;YACE,IAAI,EAAE,yBAAyB;YAC/B,KAAK,EAAE,YAAY;YACnB,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;YAClC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACrB;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* A target that runs a file with Node, where the file imports a workspace
|
|
4
|
+
* package that Node loads from the output of that package's build, must run
|
|
5
|
+
* after that build. Locally a stale `dist` hides the gap; a clean checkout
|
|
6
|
+
* fails with ERR_MODULE_NOT_FOUND.
|
|
7
|
+
*/
|
|
8
|
+
declare const rule: Rule.RuleModule;
|
|
9
|
+
export default rule;
|
|
10
|
+
//# sourceMappingURL=no-missing-dependency-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-missing-dependency-build.d.ts","sourceRoot":"","sources":["../../src/nx-project/no-missing-dependency-build.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AA0NnC;;;;;GAKG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA8DhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, join, matchesGlob, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { isAstNode, isType } from "../authoring/ast.js";
|
|
5
|
+
import { objectProperties } from "../authoring/json-ast.js";
|
|
6
|
+
import { isRecord } from "../unknown-values.js";
|
|
7
|
+
import { readJson } from "../workspace/project-manifest.js";
|
|
8
|
+
import { scriptsRun } from "./command-scripts.js";
|
|
9
|
+
import { packageEntry, splitSpecifier } from "./package-entry.js";
|
|
10
|
+
import { loadedSpecifiers, relativeModule } from "./static-imports.js";
|
|
11
|
+
import { taskClosure } from "./task-closure.js";
|
|
12
|
+
const RUNS_SOURCE = /\.(?:[cm]?ts|[cm]?js)$/;
|
|
13
|
+
// @nx/devkit is an optional peer of this entry, which non-Nx repos load too,
|
|
14
|
+
// so it is required only when a project.json is linted.
|
|
15
|
+
function loadDevkit() {
|
|
16
|
+
try {
|
|
17
|
+
return createRequire(import.meta.url)('@nx/devkit');
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (isRecord(error) && error['code'] === 'MODULE_NOT_FOUND') {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// There is no cached graph before Nx builds one, as on a fresh clone; Nx's
|
|
27
|
+
// own lint rules then skip their checks, and so does this one.
|
|
28
|
+
function readCachedGraph(devkit) {
|
|
29
|
+
try {
|
|
30
|
+
return devkit.readCachedProjectGraph();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function toPosix(path) {
|
|
37
|
+
return path.split(sep).join('/');
|
|
38
|
+
}
|
|
39
|
+
function interpolate(text, node) {
|
|
40
|
+
return text
|
|
41
|
+
.replaceAll('{projectRoot}', node.data.root)
|
|
42
|
+
.replaceAll('{workspaceRoot}', '.');
|
|
43
|
+
}
|
|
44
|
+
/** Each command line of a target with the folder it runs in. */
|
|
45
|
+
function commandLines(target, node, root) {
|
|
46
|
+
const options = target.options;
|
|
47
|
+
if (!isRecord(options))
|
|
48
|
+
return [];
|
|
49
|
+
if (target.executor === 'nx:run-commands') {
|
|
50
|
+
const cwd = typeof options['cwd'] === 'string'
|
|
51
|
+
? resolve(root, interpolate(options['cwd'], node))
|
|
52
|
+
: root;
|
|
53
|
+
const commands = [
|
|
54
|
+
options['command'],
|
|
55
|
+
...(Array.isArray(options['commands']) ? options['commands'] : []),
|
|
56
|
+
];
|
|
57
|
+
return commands.flatMap((command) => {
|
|
58
|
+
const line = isRecord(command) ? command['command'] : command;
|
|
59
|
+
return typeof line === 'string'
|
|
60
|
+
? [{ line: interpolate(line, node), cwd }]
|
|
61
|
+
: [];
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (target.executor === 'nx:run-script') {
|
|
65
|
+
const directory = join(root, node.data.root);
|
|
66
|
+
const manifest = readJson(join(directory, 'package.json'));
|
|
67
|
+
const scripts = isRecord(manifest) ? manifest['scripts'] : undefined;
|
|
68
|
+
const script = isRecord(scripts) ? scripts[String(options['script'])] : '';
|
|
69
|
+
return typeof script === 'string' ? [{ line: script, cwd: directory }] : [];
|
|
70
|
+
}
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
function workspacePackages(graph, root) {
|
|
74
|
+
const packages = new Map();
|
|
75
|
+
for (const node of Object.values(graph.nodes)) {
|
|
76
|
+
const directory = join(root, node.data.root);
|
|
77
|
+
const manifest = readJson(join(directory, 'package.json'));
|
|
78
|
+
if (isRecord(manifest) && typeof manifest['name'] === 'string') {
|
|
79
|
+
packages.set(manifest['name'], { node, directory, manifest });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return packages;
|
|
83
|
+
}
|
|
84
|
+
class BuiltImportFinder {
|
|
85
|
+
#devkit;
|
|
86
|
+
#root;
|
|
87
|
+
#packages;
|
|
88
|
+
constructor(devkit, root, graph) {
|
|
89
|
+
this.#devkit = devkit;
|
|
90
|
+
this.#root = root;
|
|
91
|
+
this.#packages = workspacePackages(graph, root);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The workspace packages that `script` loads, through relative imports and
|
|
95
|
+
* the source of packages that resolve to source, whose entry lies in the
|
|
96
|
+
* outputs of their build target.
|
|
97
|
+
*/
|
|
98
|
+
find({ file, conditions }) {
|
|
99
|
+
const found = [];
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
const queue = [file];
|
|
102
|
+
for (let current = queue.pop(); current; current = queue.pop()) {
|
|
103
|
+
if (seen.has(current))
|
|
104
|
+
continue;
|
|
105
|
+
seen.add(current);
|
|
106
|
+
for (const specifier of loadedSpecifiers(current)) {
|
|
107
|
+
if (specifier.startsWith('.')) {
|
|
108
|
+
const module = relativeModule(current, specifier);
|
|
109
|
+
if (module)
|
|
110
|
+
queue.push(module);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const { name, subpath } = splitSpecifier(specifier);
|
|
114
|
+
const pkg = this.#packages.get(name);
|
|
115
|
+
const target = pkg && packageEntry(pkg.manifest, subpath, conditions);
|
|
116
|
+
if (!pkg || target === undefined)
|
|
117
|
+
continue;
|
|
118
|
+
const entry = resolve(pkg.directory, target);
|
|
119
|
+
if (this.#isBuildOutput(pkg.node, entry)) {
|
|
120
|
+
found.push({
|
|
121
|
+
script: file,
|
|
122
|
+
specifier,
|
|
123
|
+
entry,
|
|
124
|
+
project: pkg.node.name,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else if (RUNS_SOURCE.test(entry) && existsSync(entry)) {
|
|
128
|
+
queue.push(entry);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return found;
|
|
133
|
+
}
|
|
134
|
+
#isBuildOutput(node, entry) {
|
|
135
|
+
if (!node.data.targets?.['build'])
|
|
136
|
+
return false;
|
|
137
|
+
const path = toPosix(relative(this.#root, entry));
|
|
138
|
+
return this.#devkit
|
|
139
|
+
.getOutputsForTargetAndConfiguration({ project: node.name, target: 'build' }, {}, node)
|
|
140
|
+
.filter((output) => !output.startsWith('!'))
|
|
141
|
+
.some((output) => path === output ||
|
|
142
|
+
path.startsWith(`${output}/`) ||
|
|
143
|
+
matchesGlob(path, output));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function rootObject(program) {
|
|
147
|
+
if (!isAstNode(program))
|
|
148
|
+
return undefined;
|
|
149
|
+
const [statement] = Array.isArray(program['body']) ? program['body'] : [];
|
|
150
|
+
return isType(statement, 'JSONExpressionStatement') &&
|
|
151
|
+
isType(statement['expression'], 'JSONObjectExpression')
|
|
152
|
+
? statement['expression']
|
|
153
|
+
: undefined;
|
|
154
|
+
}
|
|
155
|
+
function propertyNamed(object, key) {
|
|
156
|
+
return new Map(objectProperties(object)).get(key);
|
|
157
|
+
}
|
|
158
|
+
function keyOf(property) {
|
|
159
|
+
const key = property?.['key'];
|
|
160
|
+
return isAstNode(key) ? key : undefined;
|
|
161
|
+
}
|
|
162
|
+
function addDependencyBuild(target) {
|
|
163
|
+
const value = target['value'];
|
|
164
|
+
if (!isType(value, 'JSONObjectExpression'))
|
|
165
|
+
return undefined;
|
|
166
|
+
const dependsOn = propertyNamed(value, 'dependsOn')?.['value'];
|
|
167
|
+
if (dependsOn !== undefined) {
|
|
168
|
+
if (!isType(dependsOn, 'JSONArrayExpression'))
|
|
169
|
+
return undefined;
|
|
170
|
+
const [first] = Array.isArray(dependsOn['elements'])
|
|
171
|
+
? dependsOn['elements']
|
|
172
|
+
: [];
|
|
173
|
+
return isAstNode(first)
|
|
174
|
+
? (fixer) => fixer.insertTextBefore(first, '"^build", ')
|
|
175
|
+
: (fixer) => fixer.replaceText(dependsOn, '["^build"]');
|
|
176
|
+
}
|
|
177
|
+
const [first] = Array.isArray(value['properties']) ? value['properties'] : [];
|
|
178
|
+
return isType(first, 'JSONProperty')
|
|
179
|
+
? (fixer) => fixer.insertTextBefore(first, '"dependsOn": ["^build"], ')
|
|
180
|
+
: (fixer) => fixer.replaceText(value, '{ "dependsOn": ["^build"] }');
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A target that runs a file with Node, where the file imports a workspace
|
|
184
|
+
* package that Node loads from the output of that package's build, must run
|
|
185
|
+
* after that build. Locally a stale `dist` hides the gap; a clean checkout
|
|
186
|
+
* fails with ERR_MODULE_NOT_FOUND.
|
|
187
|
+
*/
|
|
188
|
+
const rule = {
|
|
189
|
+
meta: {
|
|
190
|
+
type: 'problem',
|
|
191
|
+
hasSuggestions: true,
|
|
192
|
+
docs: {
|
|
193
|
+
description: "Require a target that runs a file importing a built workspace package to depend on that package's build",
|
|
194
|
+
},
|
|
195
|
+
messages: {
|
|
196
|
+
missingDependencyBuild: 'Target "{{target}}" runs {{file}}, which imports {{package}}. Node loads {{entry}}, which {{project}}:build writes. Add "^build" to dependsOn, or a clean checkout fails with ERR_MODULE_NOT_FOUND.',
|
|
197
|
+
addDependencyBuild: 'Add "^build" to dependsOn.',
|
|
198
|
+
},
|
|
199
|
+
schema: [],
|
|
200
|
+
},
|
|
201
|
+
create(context) {
|
|
202
|
+
const projectRoot = dirname(context.physicalFilename);
|
|
203
|
+
return {
|
|
204
|
+
Program() {
|
|
205
|
+
const devkit = loadDevkit();
|
|
206
|
+
const graph = devkit && readCachedGraph(devkit);
|
|
207
|
+
if (!devkit || !graph)
|
|
208
|
+
return;
|
|
209
|
+
const root = devkit.workspaceRoot;
|
|
210
|
+
const node = Object.values(graph.nodes).find((candidate) => resolve(root, candidate.data.root) === projectRoot);
|
|
211
|
+
if (!node)
|
|
212
|
+
return;
|
|
213
|
+
const finder = new BuiltImportFinder(devkit, root, graph);
|
|
214
|
+
const json = rootObject(context.sourceCode.ast);
|
|
215
|
+
const targetsProperty = propertyNamed(json, 'targets');
|
|
216
|
+
for (const [name, target] of Object.entries(node.data.targets ?? {})) {
|
|
217
|
+
const missing = commandLines(target, node, root)
|
|
218
|
+
.flatMap(({ line, cwd }) => scriptsRun(line, cwd))
|
|
219
|
+
.flatMap((script) => finder.find(script));
|
|
220
|
+
if (missing.length === 0)
|
|
221
|
+
continue;
|
|
222
|
+
const closure = taskClosure(graph, node.name, name);
|
|
223
|
+
const unbuilt = missing.find(({ project }) => !closure.has(`${project}:build`));
|
|
224
|
+
if (!unbuilt)
|
|
225
|
+
continue;
|
|
226
|
+
const targetProperty = propertyNamed(targetsProperty?.['value'], name);
|
|
227
|
+
const fix = targetProperty && addDependencyBuild(targetProperty);
|
|
228
|
+
const at = keyOf(targetProperty) ?? keyOf(targetsProperty);
|
|
229
|
+
context.report({
|
|
230
|
+
...(at ? { node: at } : { loc: { line: 1, column: 0 } }),
|
|
231
|
+
messageId: 'missingDependencyBuild',
|
|
232
|
+
data: {
|
|
233
|
+
target: name,
|
|
234
|
+
file: toPosix(relative(root, unbuilt.script)),
|
|
235
|
+
package: unbuilt.specifier,
|
|
236
|
+
entry: toPosix(relative(root, unbuilt.entry)),
|
|
237
|
+
project: unbuilt.project,
|
|
238
|
+
},
|
|
239
|
+
suggest: fix ? [{ messageId: 'addDependencyBuild', fix }] : [],
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
export default rule;
|
|
247
|
+
//# sourceMappingURL=no-missing-dependency-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-missing-dependency-build.js","sourceRoot":"","sources":["../../src/nx-project/no-missing-dependency-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAA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,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;qBAC/D,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package-relative file that Node loads for `subpath` (`.` or `./x`) of a
|
|
3
|
+
* package with `manifest`, under the command's `conditions` and Node's own.
|
|
4
|
+
*/
|
|
5
|
+
export declare function packageEntry(manifest: Record<string, unknown>, subpath: string, conditions: readonly string[]): string | undefined;
|
|
6
|
+
/** The package name and its subpath in a bare specifier: `@a/b/c` → `@a/b`, `./c`. */
|
|
7
|
+
export declare function splitSpecifier(specifier: string): {
|
|
8
|
+
name: string;
|
|
9
|
+
subpath: string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=package-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-entry.d.ts","sourceRoot":"","sources":["../../src/nx-project/package-entry.ts"],"names":[],"mappings":"AA0DA;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,GAAG,SAAS,CAYpB;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAMA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { isRecord } from "../unknown-values.js";
|
|
2
|
+
// The conditions Node itself sets for an ESM import, after the command's own.
|
|
3
|
+
const NODE_CONDITIONS = ['node', 'import', 'module-sync', 'default'];
|
|
4
|
+
function conditionalTarget(value, conditions) {
|
|
5
|
+
if (typeof value === 'string')
|
|
6
|
+
return value;
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
for (const item of value) {
|
|
9
|
+
const target = conditionalTarget(item, conditions);
|
|
10
|
+
if (target !== undefined)
|
|
11
|
+
return target;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
if (!isRecord(value))
|
|
16
|
+
return undefined;
|
|
17
|
+
for (const [condition, nested] of Object.entries(value)) {
|
|
18
|
+
if (!conditions.has(condition))
|
|
19
|
+
continue;
|
|
20
|
+
const target = conditionalTarget(nested, conditions);
|
|
21
|
+
if (target !== undefined)
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function subpathTarget(exports, subpath, conditions) {
|
|
27
|
+
const map = isRecord(exports) &&
|
|
28
|
+
!Array.isArray(exports) &&
|
|
29
|
+
Object.keys(exports).some((key) => key.startsWith('.'))
|
|
30
|
+
? exports
|
|
31
|
+
: { '.': exports };
|
|
32
|
+
if (subpath in map)
|
|
33
|
+
return conditionalTarget(map[subpath], conditions);
|
|
34
|
+
// Node picks the pattern with the longest prefix before its `*`.
|
|
35
|
+
const [pattern] = Object.keys(map)
|
|
36
|
+
.filter((key) => {
|
|
37
|
+
const [prefix, suffix, extra] = key.split('*');
|
|
38
|
+
return (prefix !== undefined &&
|
|
39
|
+
suffix !== undefined &&
|
|
40
|
+
extra === undefined &&
|
|
41
|
+
subpath.length >= prefix.length + suffix.length &&
|
|
42
|
+
subpath.startsWith(prefix) &&
|
|
43
|
+
subpath.endsWith(suffix));
|
|
44
|
+
})
|
|
45
|
+
.toSorted((a, b) => b.indexOf('*') - a.indexOf('*'));
|
|
46
|
+
if (pattern === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
const [prefix = '', suffix = ''] = pattern.split('*');
|
|
49
|
+
const match = subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
50
|
+
return conditionalTarget(map[pattern], conditions)?.replaceAll('*', match);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The package-relative file that Node loads for `subpath` (`.` or `./x`) of a
|
|
54
|
+
* package with `manifest`, under the command's `conditions` and Node's own.
|
|
55
|
+
*/
|
|
56
|
+
export function packageEntry(manifest, subpath, conditions) {
|
|
57
|
+
const exports = manifest['exports'];
|
|
58
|
+
if (exports !== undefined) {
|
|
59
|
+
return subpathTarget(exports, subpath, new Set([...conditions, ...NODE_CONDITIONS]));
|
|
60
|
+
}
|
|
61
|
+
if (subpath !== '.')
|
|
62
|
+
return subpath;
|
|
63
|
+
const main = manifest['main'];
|
|
64
|
+
return typeof main === 'string' ? main : 'index.js';
|
|
65
|
+
}
|
|
66
|
+
/** The package name and its subpath in a bare specifier: `@a/b/c` → `@a/b`, `./c`. */
|
|
67
|
+
export function splitSpecifier(specifier) {
|
|
68
|
+
const segments = specifier.split('/');
|
|
69
|
+
const length = specifier.startsWith('@') ? 2 : 1;
|
|
70
|
+
const name = segments.slice(0, length).join('/');
|
|
71
|
+
const rest = segments.slice(length);
|
|
72
|
+
return { name, subpath: rest.length === 0 ? '.' : `./${rest.join('/')}` };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=package-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-entry.js","sourceRoot":"","sources":["../../src/nx-project/package-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,8EAA8E;AAC9E,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;AAErE,SAAS,iBAAiB,CACxB,KAAc,EACd,UAA+B;IAE/B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACz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CAAC;IACJ,CAAC;IACD,IAAI,OAAO,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC;IACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;AACtD,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,cAAc,CAAC,SAAiB;IAI9C,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The module specifiers that `file` loads when Node runs it; none when it does not parse. */
|
|
2
|
+
export declare function loadedSpecifiers(file: string): readonly string[];
|
|
3
|
+
/**
|
|
4
|
+
* The file that a relative specifier names: Node's exact path, then the
|
|
5
|
+
* TypeScript file behind a `.js` name and the extensionless forms that tsx
|
|
6
|
+
* resolves.
|
|
7
|
+
*/
|
|
8
|
+
export declare function relativeModule(from: string, specifier: string): string | undefined;
|
|
9
|
+
//# sourceMappingURL=static-imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-imports.d.ts","sourceRoot":"","sources":["../../src/nx-project/static-imports.ts"],"names":[],"mappings":"AAwDA,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAmBhE;AAMD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAUpB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import { isAstNode, isType } from "../authoring/ast.js";
|
|
5
|
+
import { isRecord } from "../unknown-values.js";
|
|
6
|
+
// Keyed by absolute path. A changed mtime re-parses, so a long-lived ESLint
|
|
7
|
+
// process (an editor) sees an edit.
|
|
8
|
+
const parsedByFile = new Map();
|
|
9
|
+
function literalString(node) {
|
|
10
|
+
return isType(node, 'Literal') && typeof node['value'] === 'string'
|
|
11
|
+
? node['value']
|
|
12
|
+
: undefined;
|
|
13
|
+
}
|
|
14
|
+
// A value import, a re-export or an `import()` of a literal loads the module
|
|
15
|
+
// when the file runs; `import type` and `export type` are erased first.
|
|
16
|
+
function loadedSpecifier(node) {
|
|
17
|
+
switch (node['type']) {
|
|
18
|
+
case 'ImportDeclaration':
|
|
19
|
+
return node['importKind'] === 'type'
|
|
20
|
+
? undefined
|
|
21
|
+
: literalString(node['source']);
|
|
22
|
+
case 'ExportNamedDeclaration':
|
|
23
|
+
case 'ExportAllDeclaration':
|
|
24
|
+
return node['exportKind'] === 'type'
|
|
25
|
+
? undefined
|
|
26
|
+
: literalString(node['source']);
|
|
27
|
+
case 'ImportExpression':
|
|
28
|
+
return literalString(node['source']);
|
|
29
|
+
default:
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function collect(node, into) {
|
|
34
|
+
if (Array.isArray(node)) {
|
|
35
|
+
for (const child of node)
|
|
36
|
+
collect(child, into);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!isAstNode(node))
|
|
40
|
+
return;
|
|
41
|
+
const specifier = loadedSpecifier(node);
|
|
42
|
+
if (specifier !== undefined)
|
|
43
|
+
into.push(specifier);
|
|
44
|
+
for (const [key, child] of Object.entries(node)) {
|
|
45
|
+
if (key !== 'parent' && isRecord(child))
|
|
46
|
+
collect(child, into);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** The module specifiers that `file` loads when Node runs it; none when it does not parse. */
|
|
50
|
+
export function loadedSpecifiers(file) {
|
|
51
|
+
const { mtimeMs } = statSync(file);
|
|
52
|
+
const cached = parsedByFile.get(file);
|
|
53
|
+
if (cached?.mtimeMs === mtimeMs)
|
|
54
|
+
return cached.specifiers;
|
|
55
|
+
const specifiers = [];
|
|
56
|
+
try {
|
|
57
|
+
collect(tseslint.parser.parseForESLint(readFileSync(file, 'utf8')).ast, specifiers);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
// typescript-estree throws a TSError with a lineNumber on a syntax
|
|
61
|
+
// error; a file Node cannot parse fails on its own, not on a missing build.
|
|
62
|
+
if (!(isRecord(error) && typeof error['lineNumber'] === 'number')) {
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
parsedByFile.set(file, { mtimeMs, specifiers });
|
|
67
|
+
return specifiers;
|
|
68
|
+
}
|
|
69
|
+
function isFile(path) {
|
|
70
|
+
return existsSync(path) && statSync(path).isFile();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The file that a relative specifier names: Node's exact path, then the
|
|
74
|
+
* TypeScript file behind a `.js` name and the extensionless forms that tsx
|
|
75
|
+
* resolves.
|
|
76
|
+
*/
|
|
77
|
+
export function relativeModule(from, specifier) {
|
|
78
|
+
const base = resolve(dirname(from), specifier);
|
|
79
|
+
return [
|
|
80
|
+
base,
|
|
81
|
+
base.replace(/\.(c|m)?js$/, '.$1ts'),
|
|
82
|
+
`${base}.ts`,
|
|
83
|
+
`${base}.js`,
|
|
84
|
+
resolve(base, 'index.ts'),
|
|
85
|
+
resolve(base, 'index.js'),
|
|
86
|
+
].find(isFile);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=static-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-imports.js","sourceRoot":"","sources":["../../src/nx-project/static-imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAOhD,4EAA4E;AAC5E,oCAAoC;AACpC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE/C,SAAS,aAAa,CAAC,IAAa;IAClC,OAAO,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ;QACjE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QACf,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,6EAA6E;AAC7E,wEAAwE;AACxE,SAAS,eAAe,CAAC,IAA6B;IACpD,QAAQ,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACrB,KAAK,mBAAmB;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,MAAM;gBAClC,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACpC,KAAK,wBAAwB,CAAC;QAC9B,KAAK,sBAAsB;YAC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AAO,CACL,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,EAC9D,UAAU,CACX,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mEAAmE;QACnE,4EAA4E;QAC5E,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;YAClE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,SAAiB;IAEjB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;IAC/C,OAAO;QACL,IAAI;QACJ,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC;QACpC,GAAG,IAAI,KAAK;QACZ,GAAG,IAAI,KAAK;QACZ,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC;QACzB,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC;KAC1B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProjectGraph } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* The ids (`project:target`) of every task that Nx runs before `target` of
|
|
4
|
+
* `project`, through the `dependsOn` of each task as the project graph holds
|
|
5
|
+
* it: target defaults and inferred targets included.
|
|
6
|
+
*/
|
|
7
|
+
export declare function taskClosure(graph: ProjectGraph, project: string, target: string): ReadonlySet<string>;
|
|
8
|
+
//# sourceMappingURL=task-closure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-closure.d.ts","sourceRoot":"","sources":["../../src/nx-project/task-closure.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA0E/C;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,MAAM,CAAC,CAcrB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { matchesGlob } from 'node:path';
|
|
2
|
+
import { isRecord } from "../unknown-values.js";
|
|
3
|
+
function hasTarget(graph, project, target) {
|
|
4
|
+
return graph.nodes[project]?.data.targets?.[target] !== undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* `target` of each project that `project` depends on. A dependency without
|
|
8
|
+
* the target is passed through to its own dependencies, as Nx's task graph
|
|
9
|
+
* does with a dummy task.
|
|
10
|
+
*/
|
|
11
|
+
function dependencyTasks(graph, project, target, visited = new Set()) {
|
|
12
|
+
if (visited.has(project))
|
|
13
|
+
return [];
|
|
14
|
+
visited.add(project);
|
|
15
|
+
return (graph.dependencies[project] ?? []).flatMap(({ target: dependency }) => {
|
|
16
|
+
if (!graph.nodes[dependency])
|
|
17
|
+
return [];
|
|
18
|
+
return hasTarget(graph, dependency, target)
|
|
19
|
+
? [[dependency, target]]
|
|
20
|
+
: dependencyTasks(graph, dependency, target, visited);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function matchingProjects(graph, pattern) {
|
|
24
|
+
return Object.values(graph.nodes)
|
|
25
|
+
.filter((node) => pattern.startsWith('tag:')
|
|
26
|
+
? node.data.tags?.includes(pattern.slice('tag:'.length))
|
|
27
|
+
: node.name === pattern || matchesGlob(node.name, pattern))
|
|
28
|
+
.map((node) => node.name);
|
|
29
|
+
}
|
|
30
|
+
// One `dependsOn` entry as Nx expands it: `target`, `^target`,
|
|
31
|
+
// `project:target`, or `{ target, dependencies?, projects? }`.
|
|
32
|
+
function expand(graph, project, entry) {
|
|
33
|
+
if (typeof entry === 'string') {
|
|
34
|
+
if (entry.startsWith('^')) {
|
|
35
|
+
return dependencyTasks(graph, project, entry.slice(1));
|
|
36
|
+
}
|
|
37
|
+
const colon = entry.indexOf(':');
|
|
38
|
+
const named = entry.slice(0, colon);
|
|
39
|
+
return colon > 0 && graph.nodes[named]
|
|
40
|
+
? [[named, entry.slice(colon + 1)]]
|
|
41
|
+
: [[project, entry]];
|
|
42
|
+
}
|
|
43
|
+
if (!isRecord(entry) || typeof entry['target'] !== 'string')
|
|
44
|
+
return [];
|
|
45
|
+
const target = entry['target'];
|
|
46
|
+
if (entry['dependencies'] === true) {
|
|
47
|
+
return dependencyTasks(graph, project, target);
|
|
48
|
+
}
|
|
49
|
+
const projects = entry['projects'];
|
|
50
|
+
if (projects === undefined)
|
|
51
|
+
return [[project, target]];
|
|
52
|
+
return [projects].flat().flatMap((pattern) => {
|
|
53
|
+
if (pattern === 'self')
|
|
54
|
+
return [[project, target]];
|
|
55
|
+
if (pattern === 'dependencies') {
|
|
56
|
+
return dependencyTasks(graph, project, target);
|
|
57
|
+
}
|
|
58
|
+
return typeof pattern === 'string'
|
|
59
|
+
? matchingProjects(graph, pattern).map((name) => [name, target])
|
|
60
|
+
: [];
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The ids (`project:target`) of every task that Nx runs before `target` of
|
|
65
|
+
* `project`, through the `dependsOn` of each task as the project graph holds
|
|
66
|
+
* it: target defaults and inferred targets included.
|
|
67
|
+
*/
|
|
68
|
+
export function taskClosure(graph, project, target) {
|
|
69
|
+
const closure = new Set();
|
|
70
|
+
const queue = [[project, target]];
|
|
71
|
+
for (let task = queue.pop(); task; task = queue.pop()) {
|
|
72
|
+
const [name, targetName] = task;
|
|
73
|
+
const id = `${name}:${targetName}`;
|
|
74
|
+
if (closure.has(id))
|
|
75
|
+
continue;
|
|
76
|
+
closure.add(id);
|
|
77
|
+
const dependsOn = graph.nodes[name]?.data.targets?.[targetName]?.dependsOn;
|
|
78
|
+
for (const entry of dependsOn ?? []) {
|
|
79
|
+
queue.push(...expand(graph, name, entry));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return closure;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=task-closure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-closure.js","sourceRoot":"","sources":["../../src/nx-project/task-closure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,SAAS,SAAS,CAAC,KAAmB,EAAE,OAAe,EAAE,MAAc;IACrE,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CACtB,KAAmB,EACnB,OAAe,EACf,MAAc,EACd,UAAU,IAAI,GAAG,EAAU;IAE3B,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAChD,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE;QACzB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC;YAAE,OAAO,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC,KAAK,EAAE,UAAU,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,EACnB,OAAe,EACf,MAAc;IAEd,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,KAAK,GAAW,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC;QACtD,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;QAChC,MAAM,EAAE,GAAG,GAAG,IAAI,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAS;QAC9B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC;QAC3E,KAAK,MAAM,KAAK,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAkC7C,QAAA,MAAM,MAAM;;;;;;;;;;CAUa,CAAC;AAM1B,eAAe,MAAM,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { findPackageJSON } from 'node:module';
|
|
1
|
+
import manifest from '../package.json' with { type: 'json' };
|
|
3
2
|
import { base } from "./base/config.js";
|
|
4
3
|
import { betterAuth } from "./better-auth/config.js";
|
|
5
4
|
import { diagnostics } from "./diagnostics/config.js";
|
|
@@ -12,7 +11,6 @@ import { reactRouter } from "./react-router/config.js";
|
|
|
12
11
|
import { react } from "./react/config.js";
|
|
13
12
|
import { tailwind } from "./tailwind/config.js";
|
|
14
13
|
import { tests } from "./test-files/config.js";
|
|
15
|
-
import { isRecord } from "./unknown-values.js";
|
|
16
14
|
const concepts = [
|
|
17
15
|
base,
|
|
18
16
|
tests,
|
|
@@ -27,17 +25,11 @@ const concepts = [
|
|
|
27
25
|
pulumi,
|
|
28
26
|
nxProjectJson,
|
|
29
27
|
];
|
|
30
|
-
function packageVersion() {
|
|
31
|
-
const manifest = JSON.parse(readFileSync(findPackageJSON(import.meta.url) ?? '', 'utf8'));
|
|
32
|
-
return isRecord(manifest) && typeof manifest['version'] === 'string'
|
|
33
|
-
? manifest['version']
|
|
34
|
-
: '0.0.0';
|
|
35
|
-
}
|
|
36
28
|
const configs = {};
|
|
37
29
|
const plugin = {
|
|
38
30
|
meta: {
|
|
39
31
|
name: '@zukhruf/eslint',
|
|
40
|
-
version:
|
|
32
|
+
version: manifest.version,
|
|
41
33
|
namespace: 'zukhruf',
|
|
42
34
|
},
|
|
43
35
|
rules: Object.fromEntries(concepts.flatMap((concept) => Object.entries(concept.rules))),
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,M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AAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,eAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/eslint",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.24",
|
|
4
4
|
"description": "ESLint rules and configs shared across workspaces. Each check is its own named rule, so a repo's own config cannot silently erase it. This workspace lints itself with it.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -68,8 +68,9 @@
|
|
|
68
68
|
"ts-api-utils": "^2.5.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@zukhruf/fs": "^0.8.
|
|
72
|
-
"@zukhruf/testing": "^0.8.
|
|
71
|
+
"@zukhruf/fs": "^0.8.24",
|
|
72
|
+
"@zukhruf/testing": "^0.8.24",
|
|
73
|
+
"esbuild": "0.28.2"
|
|
73
74
|
},
|
|
74
75
|
"peerDependencies": {
|
|
75
76
|
"@e18e/eslint-plugin": "^0.8.1",
|