@astrale-os/sdk 0.4.12 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/run.d.ts +8 -2
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +51 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/define/remote-function.d.ts +3 -1
- package/dist/define/remote-function.d.ts.map +1 -1
- package/dist/define/remote-function.js.map +1 -1
- package/dist/dispatch/dispatcher.d.ts +10 -20
- package/dist/dispatch/dispatcher.d.ts.map +1 -1
- package/dist/dispatch/dispatcher.js +55 -54
- package/dist/dispatch/dispatcher.js.map +1 -1
- package/dist/dispatch/execute.d.ts +2 -1
- package/dist/dispatch/execute.d.ts.map +1 -1
- package/dist/dispatch/execute.js +1 -0
- package/dist/dispatch/execute.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/linter/analyze.d.ts +6 -0
- package/dist/linter/analyze.d.ts.map +1 -0
- package/dist/linter/analyze.js +12 -0
- package/dist/linter/analyze.js.map +1 -0
- package/dist/linter/diagnostic.d.ts +32 -0
- package/dist/linter/diagnostic.d.ts.map +1 -0
- package/dist/linter/diagnostic.js +35 -0
- package/dist/linter/diagnostic.js.map +1 -0
- package/dist/linter/index.d.ts +10 -0
- package/dist/linter/index.d.ts.map +1 -0
- package/dist/linter/index.js +6 -0
- package/dist/linter/index.js.map +1 -0
- package/dist/linter/lint.d.ts +8 -0
- package/dist/linter/lint.d.ts.map +1 -0
- package/dist/linter/lint.js +26 -0
- package/dist/linter/lint.js.map +1 -0
- package/dist/linter/oxlint/config.d.ts +14 -0
- package/dist/linter/oxlint/config.d.ts.map +1 -0
- package/dist/linter/oxlint/config.js +18 -0
- package/dist/linter/oxlint/config.js.map +1 -0
- package/dist/linter/oxlint/plugin.d.ts +13 -0
- package/dist/linter/oxlint/plugin.d.ts.map +1 -0
- package/dist/linter/oxlint/plugin.js +14 -0
- package/dist/linter/oxlint/plugin.js.map +1 -0
- package/dist/linter/oxlint/run.d.ts +7 -0
- package/dist/linter/oxlint/run.d.ts.map +1 -0
- package/dist/linter/oxlint/run.js +122 -0
- package/dist/linter/oxlint/run.js.map +1 -0
- package/dist/linter/preflight.d.ts +2 -0
- package/dist/linter/preflight.d.ts.map +1 -0
- package/dist/linter/preflight.js +162 -0
- package/dist/linter/preflight.js.map +1 -0
- package/dist/linter/project.d.ts +12 -0
- package/dist/linter/project.d.ts.map +1 -0
- package/dist/linter/project.js +88 -0
- package/dist/linter/project.js.map +1 -0
- package/dist/linter/report.d.ts +4 -0
- package/dist/linter/report.d.ts.map +1 -0
- package/dist/linter/report.js +22 -0
- package/dist/linter/report.js.map +1 -0
- package/dist/linter/rules/catalog.d.ts +56 -0
- package/dist/linter/rules/catalog.d.ts.map +1 -0
- package/dist/linter/rules/catalog.js +53 -0
- package/dist/linter/rules/catalog.js.map +1 -0
- package/dist/linter/rules/core-has-no-async.d.ts +3 -0
- package/dist/linter/rules/core-has-no-async.d.ts.map +1 -0
- package/dist/linter/rules/core-has-no-async.js +43 -0
- package/dist/linter/rules/core-has-no-async.js.map +1 -0
- package/dist/linter/rules/core-is-pure.d.ts +3 -0
- package/dist/linter/rules/core-is-pure.d.ts.map +1 -0
- package/dist/linter/rules/core-is-pure.js +74 -0
- package/dist/linter/rules/core-is-pure.js.map +1 -0
- package/dist/linter/rules/no-nested-steps.d.ts +3 -0
- package/dist/linter/rules/no-nested-steps.d.ts.map +1 -0
- package/dist/linter/rules/no-nested-steps.js +32 -0
- package/dist/linter/rules/no-nested-steps.js.map +1 -0
- package/dist/linter/rules/no-read-inside-mutate.d.ts +3 -0
- package/dist/linter/rules/no-read-inside-mutate.d.ts.map +1 -0
- package/dist/linter/rules/no-read-inside-mutate.js +64 -0
- package/dist/linter/rules/no-read-inside-mutate.js.map +1 -0
- package/dist/linter/rules/one-remote-definition-per-file.d.ts +3 -0
- package/dist/linter/rules/one-remote-definition-per-file.d.ts.map +1 -0
- package/dist/linter/rules/one-remote-definition-per-file.js +23 -0
- package/dist/linter/rules/one-remote-definition-per-file.js.map +1 -0
- package/dist/linter/rules/oxlint-ast.d.ts +30 -0
- package/dist/linter/rules/oxlint-ast.d.ts.map +1 -0
- package/dist/linter/rules/oxlint-ast.js +104 -0
- package/dist/linter/rules/oxlint-ast.js.map +1 -0
- package/dist/linter/rules/oxlint-rule.d.ts +45 -0
- package/dist/linter/rules/oxlint-rule.d.ts.map +1 -0
- package/dist/linter/rules/oxlint-rule.js +2 -0
- package/dist/linter/rules/oxlint-rule.js.map +1 -0
- package/dist/linter/rules/project-rule.d.ts +10 -0
- package/dist/linter/rules/project-rule.d.ts.map +1 -0
- package/dist/linter/rules/project-rule.js +24 -0
- package/dist/linter/rules/project-rule.js.map +1 -0
- package/dist/linter/rules/thin-schema-composition-root.d.ts +3 -0
- package/dist/linter/rules/thin-schema-composition-root.d.ts.map +1 -0
- package/dist/linter/rules/thin-schema-composition-root.js +23 -0
- package/dist/linter/rules/thin-schema-composition-root.js.map +1 -0
- package/dist/linter/source.d.ts +24 -0
- package/dist/linter/source.d.ts.map +1 -0
- package/dist/linter/source.js +279 -0
- package/dist/linter/source.js.map +1 -0
- package/dist/linter/suppression.d.ts +3 -0
- package/dist/linter/suppression.d.ts.map +1 -0
- package/dist/linter/suppression.js +11 -0
- package/dist/linter/suppression.js.map +1 -0
- package/dist/method/context.d.ts +3 -1
- package/dist/method/context.d.ts.map +1 -1
- package/dist/server/auxiliary-routes.d.ts.map +1 -1
- package/dist/server/auxiliary-routes.js +4 -4
- package/dist/server/auxiliary-routes.js.map +1 -1
- package/dist/server/create.js +1 -1
- package/dist/server/create.js.map +1 -1
- package/dist/server/start.d.ts.map +1 -1
- package/dist/server/start.js.map +1 -1
- package/package.json +27 -7
- package/src/cli/run.ts +53 -2
- package/src/define/remote-function.ts +3 -1
- package/src/dispatch/dispatcher.ts +62 -69
- package/src/dispatch/execute.ts +3 -1
- package/src/index.ts +2 -2
- package/src/linter/analyze.ts +17 -0
- package/src/linter/diagnostic.ts +68 -0
- package/src/linter/docs/DIAGNOSTICS.md +47 -0
- package/src/linter/docs/JUDGMENT.md +81 -0
- package/src/linter/docs/PRINCIPLES.md +97 -0
- package/src/linter/docs/README.md +38 -0
- package/src/linter/docs/RULE-AUTHORING.md +144 -0
- package/src/linter/docs/RULES.md +153 -0
- package/src/linter/index.ts +14 -0
- package/src/linter/lint.ts +32 -0
- package/src/linter/oxlint/astrale-ox.d.ts +5 -0
- package/src/linter/oxlint/config.ts +19 -0
- package/src/linter/oxlint/plugin.js +16 -0
- package/src/linter/oxlint/run.ts +162 -0
- package/src/linter/preflight.ts +181 -0
- package/src/linter/project.ts +108 -0
- package/src/linter/report.ts +25 -0
- package/src/linter/rules/catalog.ts +67 -0
- package/src/linter/rules/core-has-no-async.js +43 -0
- package/src/linter/rules/core-is-pure.ts +103 -0
- package/src/linter/rules/no-nested-steps.js +37 -0
- package/src/linter/rules/no-read-inside-mutate.js +72 -0
- package/src/linter/rules/one-remote-definition-per-file.ts +29 -0
- package/src/linter/rules/oxlint-ast.js +110 -0
- package/src/linter/rules/oxlint-rule.ts +35 -0
- package/src/linter/rules/project-rule.ts +37 -0
- package/src/linter/rules/thin-schema-composition-root.ts +26 -0
- package/src/linter/source.ts +323 -0
- package/src/linter/suppression.ts +11 -0
- package/src/method/context.ts +3 -1
- package/src/server/auxiliary-routes.ts +9 -4
- package/src/server/create.ts +1 -1
- package/src/server/start.ts +2 -1
- package/dist/defer/index.d.ts +0 -24
- package/dist/defer/index.d.ts.map +0 -1
- package/dist/defer/index.js +0 -42
- package/dist/defer/index.js.map +0 -1
- package/src/defer/index.ts +0 -64
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SourceFile } from './source.js';
|
|
2
|
+
export type DomainProject = {
|
|
3
|
+
root: string;
|
|
4
|
+
files: readonly SourceFile[];
|
|
5
|
+
filesByPath: ReadonlyMap<string, SourceFile>;
|
|
6
|
+
};
|
|
7
|
+
export declare function discoverProject(root: string): Promise<DomainProject>;
|
|
8
|
+
export declare function normalizePath(path: string): string;
|
|
9
|
+
export declare function isProductionSource(relativePath: string): boolean;
|
|
10
|
+
export declare function isProductionCore(relativePath: string): boolean;
|
|
11
|
+
export declare function resolveProjectImport(project: DomainProject, importer: SourceFile, specifier: string): SourceFile | undefined;
|
|
12
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/linter/project.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAkBzD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;IAC5B,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAC7C,CAAA;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAiB1E;AAmBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAOhE;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,UAAU,EACpB,SAAS,EAAE,MAAM,GAChB,UAAU,GAAG,SAAS,CAQxB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { readdir, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { scanSource } from './source.js';
|
|
4
|
+
const ignoredDirectories = new Set([
|
|
5
|
+
'.astrale',
|
|
6
|
+
'.dist',
|
|
7
|
+
'.domain-studio',
|
|
8
|
+
'.git',
|
|
9
|
+
'.output',
|
|
10
|
+
'.turbo',
|
|
11
|
+
'.wrangler',
|
|
12
|
+
'coverage',
|
|
13
|
+
'dist',
|
|
14
|
+
'dist-client',
|
|
15
|
+
'node_modules',
|
|
16
|
+
]);
|
|
17
|
+
const sourceExtensions = new Set(['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx']);
|
|
18
|
+
export async function discoverProject(root) {
|
|
19
|
+
const projectRoot = await realpath(resolve(root));
|
|
20
|
+
const paths = [];
|
|
21
|
+
await collectSourcePaths(projectRoot, paths);
|
|
22
|
+
paths.sort();
|
|
23
|
+
const files = await Promise.all(paths.map(async (path) => {
|
|
24
|
+
const text = await readFile(path, 'utf8');
|
|
25
|
+
return scanSource(path, normalizePath(relative(projectRoot, path)), text);
|
|
26
|
+
}));
|
|
27
|
+
return {
|
|
28
|
+
root: projectRoot,
|
|
29
|
+
files,
|
|
30
|
+
filesByPath: new Map(files.map((file) => [file.path, file])),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function collectSourcePaths(directory, result) {
|
|
34
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
35
|
+
await Promise.all(entries.map(async (entry) => {
|
|
36
|
+
if (entry.isSymbolicLink())
|
|
37
|
+
return;
|
|
38
|
+
const path = join(directory, entry.name);
|
|
39
|
+
if (entry.isDirectory()) {
|
|
40
|
+
if (!ignoredDirectories.has(entry.name))
|
|
41
|
+
await collectSourcePaths(path, result);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!entry.isFile() || !sourceExtensions.has(extname(entry.name)))
|
|
45
|
+
return;
|
|
46
|
+
if (entry.name.endsWith('.d.ts') || entry.name.includes('.gen.'))
|
|
47
|
+
return;
|
|
48
|
+
result.push(path);
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
export function normalizePath(path) {
|
|
52
|
+
return sep === '/' ? path : path.split(sep).join('/');
|
|
53
|
+
}
|
|
54
|
+
export function isProductionSource(relativePath) {
|
|
55
|
+
const normalized = normalizePath(relativePath);
|
|
56
|
+
return (!normalized.split('/').includes('__tests__') &&
|
|
57
|
+
!/\.(?:test|spec|bench|perf)\.[cm]?[jt]sx?$/.test(normalized) &&
|
|
58
|
+
!normalized.includes('.gen.'));
|
|
59
|
+
}
|
|
60
|
+
export function isProductionCore(relativePath) {
|
|
61
|
+
const normalized = normalizePath(relativePath);
|
|
62
|
+
return (normalized === 'core' || normalized.startsWith('core/')) && isProductionSource(normalized);
|
|
63
|
+
}
|
|
64
|
+
export function resolveProjectImport(project, importer, specifier) {
|
|
65
|
+
if (!specifier.startsWith('.'))
|
|
66
|
+
return undefined;
|
|
67
|
+
const unresolved = resolve(dirname(importer.path), specifier);
|
|
68
|
+
for (const candidate of importCandidates(unresolved)) {
|
|
69
|
+
const file = project.filesByPath.get(candidate);
|
|
70
|
+
if (file)
|
|
71
|
+
return file;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
function importCandidates(path) {
|
|
76
|
+
const extension = extname(path);
|
|
77
|
+
const candidates = [path];
|
|
78
|
+
if (extension === '.js' || extension === '.jsx' || extension === '.mjs' || extension === '.cjs') {
|
|
79
|
+
const stem = path.slice(0, -extension.length);
|
|
80
|
+
candidates.push(`${stem}.ts`, `${stem}.tsx`, `${stem}.mts`, `${stem}.cts`);
|
|
81
|
+
}
|
|
82
|
+
if (!extension) {
|
|
83
|
+
candidates.push(`${path}.ts`, `${path}.tsx`, `${path}.mts`, `${path}.cts`);
|
|
84
|
+
candidates.push(join(path, 'index.ts'), join(path, 'index.tsx'));
|
|
85
|
+
}
|
|
86
|
+
return candidates.map((candidate) => (isAbsolute(candidate) ? candidate : resolve(candidate)));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/linter/project.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K,KAAK,IAAI,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QAChG,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAC7C,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAA;IAC5E,CAAC;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAA;QAC1E,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAA;IAClE,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;AAChG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/linter/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAAA;AAEjD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,GAAE,gBAA4B,GAAG,MAAM,CAoBjG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function formatLintResult(result, format = 'stylish') {
|
|
2
|
+
if (format === 'json')
|
|
3
|
+
return `${JSON.stringify(result, null, 2)}\n`;
|
|
4
|
+
const lines = [];
|
|
5
|
+
for (const diagnostic of result.diagnostics) {
|
|
6
|
+
const location = diagnostic.location
|
|
7
|
+
? `${diagnostic.location.path}:${diagnostic.location.line}:${diagnostic.location.column}`
|
|
8
|
+
: result.root;
|
|
9
|
+
lines.push(`${location} ${diagnostic.severity} ${diagnostic.id} ${diagnostic.message}`);
|
|
10
|
+
if (diagnostic.help)
|
|
11
|
+
lines.push(` ${diagnostic.help}`);
|
|
12
|
+
}
|
|
13
|
+
const errors = result.diagnostics.filter((diagnostic) => diagnostic.severity === 'error').length;
|
|
14
|
+
const warnings = result.diagnostics.length - errors;
|
|
15
|
+
if (lines.length > 0)
|
|
16
|
+
lines.push('');
|
|
17
|
+
lines.push(errors === 0
|
|
18
|
+
? `\u2713 ${result.files} files linted in ${result.durationMs}ms${warnings ? ` (${warnings} warnings)` : ''}`
|
|
19
|
+
: `\u2717 ${errors} ${errors === 1 ? 'error' : 'errors'}, ${warnings} ${warnings === 1 ? 'warning' : 'warnings'} in ${result.durationMs}ms`);
|
|
20
|
+
return `${lines.join('\n')}\n`;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/linter/report.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,gBAAgB,CAAC,MAAkB,EAAE,MAAM,GAAqB,SAAS;IACvF,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAA;IACpE,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ;YAClC,CAAC,CAAC,GAAG,UAAU,CAAC,QAAQ,CA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
+
export type RuleOwner = 'analyzer' | 'oxlint' | 'sdk';
|
|
2
|
+
export type RuleInfo = {
|
|
3
|
+
slug: string;
|
|
4
|
+
owner: RuleOwner;
|
|
5
|
+
message: string;
|
|
6
|
+
help: string;
|
|
7
|
+
url: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const ruleCatalog: {
|
|
10
|
+
readonly 'thin-schema-composition-root': {
|
|
11
|
+
readonly slug: 'thin-schema-composition-root';
|
|
12
|
+
readonly owner: 'analyzer';
|
|
13
|
+
readonly message: 'The schema composition root defines a schema member inline.';
|
|
14
|
+
readonly help: 'Move this member definition to its bounded-context module and import it here.';
|
|
15
|
+
readonly url: string;
|
|
16
|
+
};
|
|
17
|
+
readonly 'one-remote-definition-per-file': {
|
|
18
|
+
readonly slug: 'one-remote-definition-per-file';
|
|
19
|
+
readonly owner: 'analyzer';
|
|
20
|
+
readonly message: 'This file defines more than one Astrale remote callable.';
|
|
21
|
+
readonly help: 'Keep one remoteMethod or defineRemoteFunction definition per implementation file.';
|
|
22
|
+
readonly url: string;
|
|
23
|
+
};
|
|
24
|
+
readonly 'core-is-pure': {
|
|
25
|
+
readonly slug: 'core-is-pure';
|
|
26
|
+
readonly owner: 'analyzer';
|
|
27
|
+
readonly message: 'Pure core code depends on an effectful or runtime-only module.';
|
|
28
|
+
readonly help: 'Move I/O orchestration to runtime or integrations and pass pure data into core.';
|
|
29
|
+
readonly url: string;
|
|
30
|
+
};
|
|
31
|
+
readonly 'core-has-no-async': {
|
|
32
|
+
readonly slug: 'core-has-no-async';
|
|
33
|
+
readonly owner: 'oxlint';
|
|
34
|
+
readonly message: 'Production core code contains asynchronous syntax.';
|
|
35
|
+
readonly help: 'Keep core deterministic and synchronous; perform asynchronous work in runtime or integrations.';
|
|
36
|
+
readonly url: string;
|
|
37
|
+
};
|
|
38
|
+
readonly 'no-nested-steps': {
|
|
39
|
+
readonly slug: 'no-nested-steps';
|
|
40
|
+
readonly owner: 'oxlint';
|
|
41
|
+
readonly message: 'A durable step directly contains another durable step.';
|
|
42
|
+
readonly help: 'Give each stage one step boundary and call helper-owned steps outside another step callback.';
|
|
43
|
+
readonly url: string;
|
|
44
|
+
};
|
|
45
|
+
readonly 'no-read-inside-mutate': {
|
|
46
|
+
readonly slug: 'no-read-inside-mutate';
|
|
47
|
+
readonly owner: 'oxlint';
|
|
48
|
+
readonly message: 'A graph mutation builder performs a read or is asynchronous.';
|
|
49
|
+
readonly help: 'Read before mutate, then keep the mutation callback synchronous and limited to patch construction.';
|
|
50
|
+
readonly url: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type ImplementedRuleSlug = keyof typeof ruleCatalog;
|
|
54
|
+
export declare function ruleId(slug: ImplementedRuleSlug): `astrale/${ImplementedRuleSlug}`;
|
|
55
|
+
export declare function ruleInfo(id: string): RuleInfo | undefined;
|
|
56
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/linter/rules/catalog.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAA;AAErD,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAID,eAAO,MAAM,WAAW;;iBAEpB,IAAI,EAAE,8BAA8B;iBACpC,KAAK,EAAE,UAAU;iBACjB,OAAO,EAAE,6DAA6D;iBACtE,IAAI,EAAE,+EAA+E;iBACrF,GAAG;;;iBAGH,IAAI,EAAE,gCAAgC;iBACtC,KAAK,EAAE,UAAU;iBACjB,OAAO,EAAE,0DAA0D;iBACnE,IAAI,EAAE,mFAAmF;iBACzF,GAAG;;;iBAGH,IAAI,EAAE,cAAc;iBACpB,KAAK,EAAE,UAAU;iBACjB,OAAO,EAAE,gEAAgE;iBACzE,IAAI,EAAE,iFAAiF;iBACvF,GAAG;;;iBAGH,IAAI,EAAE,mBAAmB;iBACzB,KAAK,EAAE,QAAQ;iBACf,OAAO,EAAE,oDAAoD;iBAC7D,IAAI,EAAE,gGAAgG;iBACtG,GAAG;;;iBAGH,IAAI,EAAE,iBAAiB;iBACvB,KAAK,EAAE,QAAQ;iBACf,OAAO,EAAE,wDAAwD;iBACjE,IAAI,EAAE,8FAA8F;iBACpG,GAAG;;;iBAGH,IAAI,EAAE,uBAAuB;iBAC7B,KAAK,EAAE,QAAQ;iBACf,OAAO,EAAE,8DAA8D;iBACvE,IAAI,EAAE,oGAAoG;iBAC1G,GAAG;;CAEsC,CAAA;AAE7C,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,WAAW,CAAA;AAE1D,wBAAgB,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG,WAAW,mBAAmB,EAAE,CAElF;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAGzD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const ruleDocsUrl = (slug) => `https://docs.astrale.ai/linter/rules/${slug}`;
|
|
2
|
+
export const ruleCatalog = {
|
|
3
|
+
'thin-schema-composition-root': {
|
|
4
|
+
slug: 'thin-schema-composition-root',
|
|
5
|
+
owner: 'analyzer',
|
|
6
|
+
message: 'The schema composition root defines a schema member inline.',
|
|
7
|
+
help: 'Move this member definition to its bounded-context module and import it here.',
|
|
8
|
+
url: ruleDocsUrl('thin-schema-composition-root'),
|
|
9
|
+
},
|
|
10
|
+
'one-remote-definition-per-file': {
|
|
11
|
+
slug: 'one-remote-definition-per-file',
|
|
12
|
+
owner: 'analyzer',
|
|
13
|
+
message: 'This file defines more than one Astrale remote callable.',
|
|
14
|
+
help: 'Keep one remoteMethod or defineRemoteFunction definition per implementation file.',
|
|
15
|
+
url: ruleDocsUrl('one-remote-definition-per-file'),
|
|
16
|
+
},
|
|
17
|
+
'core-is-pure': {
|
|
18
|
+
slug: 'core-is-pure',
|
|
19
|
+
owner: 'analyzer',
|
|
20
|
+
message: 'Pure core code depends on an effectful or runtime-only module.',
|
|
21
|
+
help: 'Move I/O orchestration to runtime or integrations and pass pure data into core.',
|
|
22
|
+
url: ruleDocsUrl('core-is-pure'),
|
|
23
|
+
},
|
|
24
|
+
'core-has-no-async': {
|
|
25
|
+
slug: 'core-has-no-async',
|
|
26
|
+
owner: 'oxlint',
|
|
27
|
+
message: 'Production core code contains asynchronous syntax.',
|
|
28
|
+
help: 'Keep core deterministic and synchronous; perform asynchronous work in runtime or integrations.',
|
|
29
|
+
url: ruleDocsUrl('core-has-no-async'),
|
|
30
|
+
},
|
|
31
|
+
'no-nested-steps': {
|
|
32
|
+
slug: 'no-nested-steps',
|
|
33
|
+
owner: 'oxlint',
|
|
34
|
+
message: 'A durable step directly contains another durable step.',
|
|
35
|
+
help: 'Give each stage one step boundary and call helper-owned steps outside another step callback.',
|
|
36
|
+
url: ruleDocsUrl('no-nested-steps'),
|
|
37
|
+
},
|
|
38
|
+
'no-read-inside-mutate': {
|
|
39
|
+
slug: 'no-read-inside-mutate',
|
|
40
|
+
owner: 'oxlint',
|
|
41
|
+
message: 'A graph mutation builder performs a read or is asynchronous.',
|
|
42
|
+
help: 'Read before mutate, then keep the mutation callback synchronous and limited to patch construction.',
|
|
43
|
+
url: ruleDocsUrl('no-read-inside-mutate'),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export function ruleId(slug) {
|
|
47
|
+
return `astrale/${slug}`;
|
|
48
|
+
}
|
|
49
|
+
export function ruleInfo(id) {
|
|
50
|
+
const slug = id.startsWith('astrale/') ? id.slice('astrale/'.length) : id;
|
|
51
|
+
return ruleCatalog[slug];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AA;AAI7C,MAAM,UAAU,MAAM,CAAC,IAAyB;IAC9C,OAAO,WAAW,IAAI,EAAE,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,IAAI,GAAG,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACzE,OAAO,WAAW,CAAC,IAA2B,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-has-no-async.d.ts","sourceRoot":"","sources":["../../../src/linter/rules/core-has-no-async.js"],"names":[],"mappings":"AAMA,oDAAoD;AACpD,eAAO,MAAM,cAAc,EADhB,OAAO,kBAAkB,EAAE,UAoCrC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { isProductionCoreFile, nearestFunction, reportUnlessSuppressed } from './oxlint-ast.js';
|
|
3
|
+
const id = 'astrale/core-has-no-async';
|
|
4
|
+
/** @type {import('./oxlint-rule.js').OxlintRule} */
|
|
5
|
+
export const coreHasNoAsync = {
|
|
6
|
+
meta: {
|
|
7
|
+
type: 'problem',
|
|
8
|
+
docs: {
|
|
9
|
+
description: 'Production core code contains asynchronous syntax.',
|
|
10
|
+
url: 'https://docs.astrale.ai/linter/rules/core-has-no-async',
|
|
11
|
+
},
|
|
12
|
+
messages: {
|
|
13
|
+
asyncFunction: 'Production core functions must be synchronous.',
|
|
14
|
+
topLevelAwait: 'Production core modules must not use top-level await.',
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
if (!isProductionCoreFile(context))
|
|
20
|
+
return {};
|
|
21
|
+
/** @param {import('./oxlint-rule.js').AstNode} node */
|
|
22
|
+
const reportFunction = (node) => {
|
|
23
|
+
if (node.async)
|
|
24
|
+
reportUnlessSuppressed(context, node, id, 'asyncFunction');
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
FunctionDeclaration: reportFunction,
|
|
28
|
+
FunctionExpression: reportFunction,
|
|
29
|
+
ArrowFunctionExpression: reportFunction,
|
|
30
|
+
AwaitExpression(node) {
|
|
31
|
+
if (!nearestFunction(node.parent)) {
|
|
32
|
+
reportUnlessSuppressed(context, node, id, 'topLevelAwait');
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
ForOfStatement(node) {
|
|
36
|
+
if (node.await && !nearestFunction(node.parent)) {
|
|
37
|
+
reportUnlessSuppressed(context, node, id, 'topLevelAwait');
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=core-has-no-async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-has-no-async.js","sourceRoot":"","sources":["../../../src/linter/rules/core-has-no-async.js"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAE/F,MAAM,EAAE,GAAG,2BAA2B,CAAA;AAEtC,oDAAoD;AACpD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,oDAAoD;YACjE,GAAG,EAAE,wDAAwD;SAC9D;QACD,QAAQ,EAAE;YACR,aAAa,EAAE,gDAAgD;YAC/D,aAAa,EAAE,uDAAuD;SACvE;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,CAAA;QAC7C,uDAAuD;QACvD,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,EAAE;YAC9B,IAAI,IAAI,CAAC,KAAK;gBAAE,sBAAsB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,eAAe,CAAC,CAAA;QAC5E,CAAC,CAAA;QACD,OAAO;YACL,mBAAmB,EAAE,cAAc;YACnC,kBAAkB,EAAE,cAAc;YAClC,uBAAuB,EAAE,cAAc;YACvC,eAAe,CAAC,IAAI;gBAClB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;oBAClC,sBAAsB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,eAAe,CAAC,CAAA;gBAC5D,CAAC;YACH,CAAC;YACD,cAAc,CAAC,IAAI;gBACjB,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;oBAChD,sBAAsB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,eAAe,CAAC,CAAA;gBAC5D,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-is-pure.d.ts","sourceRoot":"","sources":["../../../src/linter/rules/core-is-pure.ts"],"names":[],"mappings":"AASA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AA2BzE,eAAO,MAAM,UAAU,EAAE,YA0CxB,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { isProductionCore, isProductionSource, resolveProjectImport, } from '../project.js';
|
|
2
|
+
import { analyzerDiagnostic } from './project-rule.js';
|
|
3
|
+
const forbiddenPackages = new Set([
|
|
4
|
+
'@astrale-os/adapter-astrale',
|
|
5
|
+
'@astrale-os/adapter-cloudflare',
|
|
6
|
+
'@astrale-os/kernel-api',
|
|
7
|
+
'@astrale-os/kernel-client',
|
|
8
|
+
'@astrale-os/kernel-server',
|
|
9
|
+
'@astrale-os/kernel-test',
|
|
10
|
+
'@astrale-os/sdk',
|
|
11
|
+
'node:child_process',
|
|
12
|
+
'node:cluster',
|
|
13
|
+
'node:dgram',
|
|
14
|
+
'node:dns',
|
|
15
|
+
'node:fs',
|
|
16
|
+
'node:fs/promises',
|
|
17
|
+
'node:http',
|
|
18
|
+
'node:http2',
|
|
19
|
+
'node:https',
|
|
20
|
+
'node:net',
|
|
21
|
+
'node:tls',
|
|
22
|
+
'node:worker_threads',
|
|
23
|
+
]);
|
|
24
|
+
const forbiddenRoots = new Set(['client', 'functions', 'integrations', 'runtime', 'simulation']);
|
|
25
|
+
const forbiddenRootFiles = new Set(['astrale.config.ts', 'deps.ts', 'domain.ts', 'env.ts']);
|
|
26
|
+
export const coreIsPure = {
|
|
27
|
+
slug: 'core-is-pure',
|
|
28
|
+
analyze(project) {
|
|
29
|
+
const diagnostics = [];
|
|
30
|
+
const visited = new Set();
|
|
31
|
+
const pending = project.files.filter((file) => isProductionCore(file.relativePath));
|
|
32
|
+
while (pending.length > 0) {
|
|
33
|
+
const file = pending.pop();
|
|
34
|
+
if (visited.has(file.path))
|
|
35
|
+
continue;
|
|
36
|
+
visited.add(file.path);
|
|
37
|
+
for (const sourceImport of file.imports) {
|
|
38
|
+
const forbiddenPackage = forbiddenPackageName(sourceImport.specifier);
|
|
39
|
+
if (forbiddenPackage) {
|
|
40
|
+
pushDiagnostic(diagnostics, this.slug, file, sourceImport, `Import ${forbiddenPackage} crosses the pure-core boundary.`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const dependency = resolveProjectImport(project, file, sourceImport.specifier);
|
|
44
|
+
if (!dependency || !isProductionSource(dependency.relativePath))
|
|
45
|
+
continue;
|
|
46
|
+
if (isForbiddenProjectLayer(dependency.relativePath)) {
|
|
47
|
+
pushDiagnostic(diagnostics, this.slug, file, sourceImport, `Import ${sourceImport.specifier} reaches ${dependency.relativePath}.`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
pending.push(dependency);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return diagnostics;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
function forbiddenPackageName(specifier) {
|
|
57
|
+
if (forbiddenPackages.has(specifier))
|
|
58
|
+
return specifier;
|
|
59
|
+
for (const name of forbiddenPackages) {
|
|
60
|
+
if (specifier.startsWith(`${name}/`))
|
|
61
|
+
return name;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function isForbiddenProjectLayer(relativePath) {
|
|
66
|
+
const [root] = relativePath.split('/');
|
|
67
|
+
return forbiddenRoots.has(root ?? '') || forbiddenRootFiles.has(relativePath);
|
|
68
|
+
}
|
|
69
|
+
function pushDiagnostic(diagnostics, slug, file, sourceImport, detail) {
|
|
70
|
+
const diagnostic = analyzerDiagnostic(slug, file, sourceImport.token, detail);
|
|
71
|
+
if (diagnostic)
|
|
72
|
+
diagnostics.push(diagnostic);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=core-is-pure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-is-pure.js","sourceRoot":"","sources":["../../../src/linter/rules/core-is-pure.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,kBAAkB,EAAqB,MAAM,mBAAmB,CAAA;AAEzE,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,6BAA6B;IAC7B,gCAAgC;IAChC,wBAAwB;IACxB,2BAA2B;IAC3B,2BAA2B;IAC3B,yBAAyB;IACzB,iBAAiB;IACjB,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,UAAU;IACV,SAAS;IACT,kBAAkB;IAClB,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,UAAU;IACV,qBAAqB;CACtB,CAAC,CAAA;AAEF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAA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-nested-steps.js"],"names":[],"mappings":"AAYA,oDAAoD;AACpD,eAAO,MAAM,aAAa,EADf,OAAO,kBAAkB,EAAE,UAwBrC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { callbackCall, isProductionFile, isStepRun, nearestFunction, reportUnlessSuppressed, } from './oxlint-ast.js';
|
|
3
|
+
const id = 'astrale/no-nested-steps';
|
|
4
|
+
/** @type {import('./oxlint-rule.js').OxlintRule} */
|
|
5
|
+
export const noNestedSteps = {
|
|
6
|
+
meta: {
|
|
7
|
+
type: 'problem',
|
|
8
|
+
docs: {
|
|
9
|
+
description: 'A durable step directly contains another durable step.',
|
|
10
|
+
url: 'https://docs.astrale.ai/linter/rules/no-nested-steps',
|
|
11
|
+
},
|
|
12
|
+
messages: {
|
|
13
|
+
nested: 'A step.run callback must not directly invoke another step.run.',
|
|
14
|
+
},
|
|
15
|
+
schema: [],
|
|
16
|
+
},
|
|
17
|
+
create(context) {
|
|
18
|
+
if (!isProductionFile(context))
|
|
19
|
+
return {};
|
|
20
|
+
return {
|
|
21
|
+
CallExpression(node) {
|
|
22
|
+
if (!isStepRun(node))
|
|
23
|
+
return;
|
|
24
|
+
const containingFunction = nearestFunction(node.parent);
|
|
25
|
+
if (!containingFunction || !isStepRun(callbackCall(containingFunction)))
|
|
26
|
+
return;
|
|
27
|
+
reportUnlessSuppressed(context, node, id, 'nested');
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=no-nested-steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-nested-steps.js","sourceRoot":"","sources":["../../../src/linter/rules/no-nested-steps.js"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AAExB,MAAM,EAAE,GAAG,yBAAyB,CAAA;AAEpC,oDAAoD;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,wDAAwD;YACrE,GAAG,EAAE,sDAAsD;SAC5D;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,gEAAgE;SACzE;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,CAAA;QACzC,OAAO;YACL,cAAc,CAAC,IAAI;gBACjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;oBAAE,OAAM;gBAC5B,MAAM,kBAAkB,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBACvD,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;oBAAE,OAAM;gBAC/E,sBAAsB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;YACrD,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-read-inside-mutate.d.ts","sourceRoot":"","sources":["../../../src/linter/rules/no-read-inside-mutate.js"],"names":[],"mappings":"AAyBA,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,EADpB,OAAO,kBAAkB,EAAE,UAuCrC,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { callbackCall, isFunctionNode, isMutateCall, isProductionFile, nearestFunction, reportUnlessSuppressed, staticMember, } from './oxlint-ast.js';
|
|
3
|
+
const id = 'astrale/no-read-inside-mutate';
|
|
4
|
+
const readMethods = new Set([
|
|
5
|
+
'call',
|
|
6
|
+
'check',
|
|
7
|
+
'children',
|
|
8
|
+
'get',
|
|
9
|
+
'getOrThrow',
|
|
10
|
+
'neighbors',
|
|
11
|
+
'query',
|
|
12
|
+
'refresh',
|
|
13
|
+
'whoami',
|
|
14
|
+
]);
|
|
15
|
+
/** @type {import('./oxlint-rule.js').OxlintRule} */
|
|
16
|
+
export const noReadInsideMutate = {
|
|
17
|
+
meta: {
|
|
18
|
+
type: 'problem',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'A graph mutation builder performs a read or is asynchronous.',
|
|
21
|
+
url: 'https://docs.astrale.ai/linter/rules/no-read-inside-mutate',
|
|
22
|
+
},
|
|
23
|
+
messages: {
|
|
24
|
+
asyncCallback: 'A kernel.mutate callback must be synchronous.',
|
|
25
|
+
read: 'Read graph state before kernel.mutate; its callback only constructs a patch.',
|
|
26
|
+
},
|
|
27
|
+
schema: [],
|
|
28
|
+
},
|
|
29
|
+
create(context) {
|
|
30
|
+
if (!isProductionFile(context))
|
|
31
|
+
return {};
|
|
32
|
+
return {
|
|
33
|
+
CallExpression(node) {
|
|
34
|
+
if (isMutateCall(node)) {
|
|
35
|
+
const callback = node.arguments?.find(isFunctionNode);
|
|
36
|
+
if (callback?.async) {
|
|
37
|
+
reportUnlessSuppressed(context, callback, id, 'asyncCallback');
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const callback = nearestFunction(node.parent);
|
|
42
|
+
if (!callback || callback.async)
|
|
43
|
+
return;
|
|
44
|
+
const mutate = callbackCall(callback);
|
|
45
|
+
if (!isMutateCall(mutate))
|
|
46
|
+
return;
|
|
47
|
+
const mutationMember = staticMember(mutate?.callee);
|
|
48
|
+
const readMember = staticMember(node.callee);
|
|
49
|
+
if (!mutationMember || !readMember || !readMethods.has(readMember.property))
|
|
50
|
+
return;
|
|
51
|
+
if (!sameKernelRoot(context, mutationMember.object, readMember.object))
|
|
52
|
+
return;
|
|
53
|
+
reportUnlessSuppressed(context, node, id, 'read');
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
/** @param {import('./oxlint-rule.js').OxlintRuleContext} context @param {import('./oxlint-rule.js').AstNode} mutationRoot @param {import('./oxlint-rule.js').AstNode} readRoot */
|
|
59
|
+
function sameKernelRoot(context, mutationRoot, readRoot) {
|
|
60
|
+
const mutationText = context.sourceCode.getText(mutationRoot);
|
|
61
|
+
const readText = context.sourceCode.getText(readRoot);
|
|
62
|
+
return readText === mutationText || readText.startsWith(`${mutationText}.`);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=no-read-inside-mutate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-read-inside-mutate.js","sourceRoot":"","sources":["../../../src/linter/rules/no-read-inside-mutate.js"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,YAAY,GACb,MAAM,iBAAiB,CAAA;AAExB,MAAM,EAAE,GAAG,+BAA+B,CAAA;AAC1C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,MAAM;IACN,OAAO;IACP,UAAU;IACV,KAAK;IACL,YAAY;IACZ,WAAW;IACX,OAAO;IACP,SAAS;IACT,QAAQ;CACT,CAAC,CAAA;AAEF,oDAAoD;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,8DAA8D;YAC3E,GAAG,EAAE,4DAA4D;SAClE;QACD,QAAQ,EAAE;YACR,aAAa,EAAE,+CAA+C;YAC9D,IAAI,EAAE,8EAA8E;SACrF;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,CAAA;QACzC,OAAO;YACL,cAAc,CAAC,IAAI;gBACjB,IAAI,YAAY,CAAC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,QAAQ,KAAK,YAAY,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY,GAAG,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-remote-definition-per-file.d.ts","sourceRoot":"","sources":["../../../src/linter/rules/one-remote-definition-per-file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKzE,eAAO,MAAM,0BAA0B,EAAE,YAmBxC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isProductionSource } from '../project.js';
|
|
2
|
+
import { importedCalls } from '../source.js';
|
|
3
|
+
import { analyzerDiagnostic } from './project-rule.js';
|
|
4
|
+
const sdkModules = new Set(['@astrale-os/sdk']);
|
|
5
|
+
const remoteDefinitions = new Set(['defineRemoteFunction', 'remoteMethod']);
|
|
6
|
+
export const oneRemoteDefinitionPerFile = {
|
|
7
|
+
slug: 'one-remote-definition-per-file',
|
|
8
|
+
analyze(project) {
|
|
9
|
+
const diagnostics = [];
|
|
10
|
+
for (const file of project.files) {
|
|
11
|
+
if (!isProductionSource(file.relativePath))
|
|
12
|
+
continue;
|
|
13
|
+
const definitions = importedCalls(file, sdkModules, remoteDefinitions);
|
|
14
|
+
for (const definition of definitions.slice(1)) {
|
|
15
|
+
const diagnostic = analyzerDiagnostic(this.slug, file, definition, `Found ${definitions.length} definitions.`);
|
|
16
|
+
if (diagnostic)
|
|
17
|
+
diagnostics.push(diagnostic);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return diagnostics;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=one-remote-definition-per-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-remote-definition-per-file.js","sourceRoot":"","sources":["../../../src/linter/rules/one-remote-definition-per-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,eAAe,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAqB,MAAM,mBAAmB,CAAA;AAEzE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAC/C,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC,CAAA;AAE3E,MAAM,CAAC,MAAM,0BAA0B,GAAiB;IACtD,IAAI,EAAE,gCAAgC;IACtC,OAAO,CAAC,OAAsB;QAC5B,MAAM,WAAW,GAAqB,EAAE,CAAA;QACxC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACjC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC;gBAAE,SAAQ;YACpD,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAA;YACtE,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9C,MAAM,UAAU,GAAG,kBAAkB,CACnC,IAAI,CAAC,IAAI,EACT,IAAI,EACJ,UAAU,EACV,SAAS,WAAW,CAAC,MAAM,eAAe,CAC3C,CAAA;gBACD,IAAI,UAAU;oBAAE,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YAC9C,CAAC;QACH,CAAC;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type AstNode = import('./oxlint-rule.js').AstNode;
|
|
2
|
+
export type OxlintRuleContext = import('./oxlint-rule.js').OxlintRuleContext;
|
|
3
|
+
export type StaticMember = {
|
|
4
|
+
object: AstNode;
|
|
5
|
+
property: string;
|
|
6
|
+
};
|
|
7
|
+
/** @typedef {import('./oxlint-rule.js').AstNode} AstNode */
|
|
8
|
+
/** @typedef {import('./oxlint-rule.js').OxlintRuleContext} OxlintRuleContext */
|
|
9
|
+
/** @typedef {{ object: AstNode, property: string }} StaticMember */
|
|
10
|
+
/** @param {AstNode | undefined} node @returns {StaticMember | undefined} */
|
|
11
|
+
export declare function staticMember(node: AstNode | undefined): StaticMember | undefined;
|
|
12
|
+
/** @param {AstNode | undefined} node */
|
|
13
|
+
export declare function isFunctionNode(node: AstNode | undefined): boolean;
|
|
14
|
+
/** @param {AstNode | undefined} node @returns {AstNode | undefined} */
|
|
15
|
+
export declare function nearestFunction(node: AstNode | undefined): AstNode | undefined;
|
|
16
|
+
/** @param {AstNode} callback @returns {AstNode | undefined} */
|
|
17
|
+
export declare function callbackCall(callback: AstNode): AstNode | undefined;
|
|
18
|
+
/** @param {AstNode | undefined} call */
|
|
19
|
+
export declare function isStepRun(call: AstNode | undefined): boolean;
|
|
20
|
+
/** @param {AstNode | undefined} call */
|
|
21
|
+
export declare function isMutateCall(call: AstNode | undefined): boolean;
|
|
22
|
+
/** @param {OxlintRuleContext} context */
|
|
23
|
+
export declare function relativeFilename(context: OxlintRuleContext): string;
|
|
24
|
+
/** @param {OxlintRuleContext} context */
|
|
25
|
+
export declare function isProductionFile(context: OxlintRuleContext): boolean;
|
|
26
|
+
/** @param {OxlintRuleContext} context */
|
|
27
|
+
export declare function isProductionCoreFile(context: OxlintRuleContext): boolean;
|
|
28
|
+
/** @param {OxlintRuleContext} context @param {AstNode} node @param {string} id @param {string} messageId */
|
|
29
|
+
export declare function reportUnlessSuppressed(context: OxlintRuleContext, node: AstNode, id: string, messageId: string): void;
|
|
30
|
+
//# sourceMappingURL=oxlint-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxlint-ast.d.ts","sourceRoot":"","sources":["../../../src/linter/rules/oxlint-ast.js"],"names":[],"mappings":"AAII,YAA8C,OAAO,GAA3C,OAAO,kBAAkB,EAAE,OAAO,CAAS;AACrD,YAAwD,iBAAiB,GAA/D,OAAO,kBAAkB,EAAE,iBAAiB,CAAmB;AACzE,YAAiD,YAAY,GAAnD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAc;AAFjE,4DAA4D;AAC5D,gFAAgF;AAChF,oEAAoE;AAEpE,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EADrB,OAAO,GAAG,SACW,GADe,YAAY,GAAG,SAAS,CAKvE;AAED,wCAAwC;AACxC,wBAAgB,cAAc,CAAC,IAAI,EADvB,OAAO,GAAG,SACa,WAMlC;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,IAAI,EADxB,OAAO,GAAG,SACc,GADY,OAAO,GAAG,SAAS,CAQlE;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,QAAQ,EADzB,OACyB,GADG,OAAO,GAAG,SAAS,CAO1D;AAaD,wCAAwC;AACxC,wBAAgB,SAAS,CAAC,IAAI,EADlB,OAAO,GAAG,SACQ,WAM7B;AAED,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,IAAI,EADrB,OAAO,GAAG,SACW,WAMhC;AAED,yCAAyC;AACzC,wBAAgB,gBAAgB,CAAC,OAAO,EAD5B,iBAC4B,UAGvC;AAED,yCAAyC;AACzC,wBAAgB,gBAAgB,CAAC,OAAO,EAD5B,iBAC4B,WAOvC;AAED,yCAAyC;AACzC,wBAAgB,oBAAoB,CAAC,OAAO,EADhC,iBACgC,WAG3C;AAED,4GAA4G;AAC5G,wBAAgB,sBAAsB,CAAC,OAAO,EADlC,iBACkC,EAAE,IAAI,EADL,OACK,EAAE,EAAE,EADa,MACb,EAAE,SAAS,EADqB,MACrB,QAGlE"}
|