@starci/eslint-canon-fe 5.1.2 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -2
- package/README.md +17 -18
- package/brand-values.mjs +1 -3
- package/class-names.mjs +9 -9
- package/client-boundary.mjs +125 -37
- package/comments.mjs +14 -21
- package/docs/client-boundary.md +26 -1
- package/docs/grammar-boundary.md +33 -0
- package/docs/hygiene.md +15 -4
- package/docs/lint-escape-hatch.md +3 -1
- package/docs/next-conventions.md +26 -0
- package/docs/size-growth.md +29 -0
- package/docs/spec-quality.md +15 -7
- package/docs/status-colors.md +32 -0
- package/docs/translation.md +4 -0
- package/docs/transport.md +36 -9
- package/e2e-shape.mjs +20 -23
- package/env-owner.mjs +1 -1
- package/file-layout.mjs +105 -103
- package/formatting.mjs +2 -4
- package/grammar-boundary.mjs +85 -9
- package/hooks-folder.mjs +17 -16
- package/hygiene.mjs +370 -92
- package/icon.mjs +21 -20
- package/index.mjs +27 -85
- package/landmark.mjs +0 -11
- package/lib/bindings.mjs +144 -0
- package/lib/config.mjs +79 -0
- package/lib/hfs.mjs +48 -0
- package/lib/next.mjs +6 -0
- package/lib/platform.mjs +66 -0
- package/lib/react.mjs +28 -0
- package/lib/scope.mjs +119 -19
- package/lib/status-tones.generated.mjs +9 -0
- package/lib/types.mjs +63 -0
- package/lib/why.mjs +41 -11
- package/lint-escape-hatch.mjs +17 -15
- package/loading.mjs +9 -16
- package/naming.mjs +8 -2
- package/next-conventions.mjs +109 -25
- package/package.json +9 -4
- package/props-and-slots.mjs +19 -13
- package/runtime/engine/plain-object.mjs +5 -0
- package/runtime/engine/runtime-root.mjs +32 -0
- package/runtime/engine/yaml.mjs +161 -0
- package/runtime/knowledge/hfs/slots.yaml +1072 -0
- package/runtime/scripts/lib/git.mjs +53 -0
- package/runtime/scripts/lib/glob.mjs +23 -0
- package/runtime/scripts/lib/hfs-allows.mjs +42 -0
- package/runtime/scripts/lib/hfs-slots.mjs +722 -0
- package/runtime/scripts/lib/hfs-view.mjs +68 -0
- package/runtime/scripts/lib/next-contract.mjs +14 -0
- package/runtime/scripts/lib/path-key.mjs +17 -0
- package/runtime/scripts/lib/recorded-lines.mjs +27 -0
- package/served-locale.mjs +30 -16
- package/shape-slot.mjs +22 -20
- package/size-and-state-budget.mjs +41 -23
- package/size-growth.mjs +58 -0
- package/spec-quality.mjs +95 -16
- package/status-colors.mjs +139 -0
- package/the-split.mjs +13 -13
- package/tokens.mjs +26 -34
- package/translation.mjs +52 -19
- package/transport.mjs +437 -89
- package/type-safety.mjs +8 -17
- package/typography.mjs +7 -11
- package/vendor-boundary.mjs +5 -27
- package/lint-adoption.mjs +0 -79
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// git.mjs — the one spawn the runtime's guard/kernel scripts run git through.
|
|
2
|
+
//
|
|
3
|
+
// Every copy spelt the same options by hand - encoding:'utf8', windowsHide:true, sometimes a
|
|
4
|
+
// timeout - with two shapes: `git args` in a cwd (shim's pathspec scans, footprint-scan,
|
|
5
|
+
// safe-remove's prune) and `git -C dir args` (settle-landed, install, terminal-dedupe's worktree
|
|
6
|
+
// list). gitOutput is the throwing shape (stdout text, or an Error on a non-zero exit). gitSpawn keeps the spawnSync(file, args, options) signature so an injected runner or a
|
|
7
|
+
// spec's fake takes the same three arguments; runGit is the `-C` convenience; gitResult folds the
|
|
8
|
+
// result into settle-landed's {ok, stdout, error} envelope.
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Spawn `file` (the git binary) once with `args`: utf8 text, a hidden window, never a shell.
|
|
13
|
+
* Options pass through last, so cwd, timeout, input, env or maxBuffer land as given. encoding:'buffer'
|
|
14
|
+
* is a request for raw bytes, not an encoding: spawnSync encodes a string `input` with it and throws
|
|
15
|
+
* ERR_UNKNOWN_ENCODING, so it reaches spawnSync as encoding:null (Buffer output either way).
|
|
16
|
+
*/
|
|
17
|
+
export const gitSpawn = (file, args, options = {}) => {
|
|
18
|
+
const spawn = { encoding: 'utf8', windowsHide: true, ...options };
|
|
19
|
+
if (spawn.encoding === 'buffer') spawn.encoding = null;
|
|
20
|
+
return spawnSync(file, args, spawn);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** `git args` in `cwd`, or `git -C dir args` when `dir` is given. `git` overrides the binary. */
|
|
24
|
+
export const runGit = (args, { cwd = null, dir = null, git = 'git', ...options } = {}) =>
|
|
25
|
+
gitSpawn(git, [...(dir ? ['-C', dir] : []), ...args], cwd ? { cwd, ...options } : options);
|
|
26
|
+
|
|
27
|
+
/** runGit's stdout as text; throws the spawn error, or an Error carrying git's stderr and exit status, unless git exits 0. */
|
|
28
|
+
export function gitOutput(args, options = {}) {
|
|
29
|
+
const r = runGit(args, options);
|
|
30
|
+
if (r.error) throw r.error;
|
|
31
|
+
if (r.status !== 0) throw Object.assign(new Error(`git ${args.join(' ')} exited ${r.status}: ${(r.stderr ?? '').trim()}`), { status: r.status, stderr: r.stderr });
|
|
32
|
+
return r.stdout;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** runGit's result as {ok, stdout, error}: ok only on a clean exit, error from stderr or the spawn. */
|
|
36
|
+
export function gitResult(args, options = {}) {
|
|
37
|
+
const r = runGit(args, options);
|
|
38
|
+
return {
|
|
39
|
+
ok: !r.error && r.status === 0,
|
|
40
|
+
stdout: r.stdout ?? '',
|
|
41
|
+
error: (r.stderr ?? '').trim() || String(r.error?.message ?? (r.status == null ? 'timed out' : `exit ${r.status}`)),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* git's C-quoted diff path decoded - `"b\303\251"` a `+++ ` header line prints when core.quotePath
|
|
47
|
+
* covers the name. Octal escapes become \u00XX for JSON.parse (which answers \n, \t, \" and \\);
|
|
48
|
+
* a value not wrapped in quotes passes through unchanged.
|
|
49
|
+
*/
|
|
50
|
+
export const unquoteDiffPath = (value) =>
|
|
51
|
+
/^".*"$/.test(value)
|
|
52
|
+
? JSON.parse(value.replace(/\\([0-7]{3})/g, (_, octal) => `\\u00${Number.parseInt(octal, 8).toString(16).padStart(2, '0')}`))
|
|
53
|
+
: value;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// glob.mjs — the path-glob subset ESLint, SonarQube and the scoped-lint config share: `**` spans directories,
|
|
2
|
+
// `*` and `?` stay inside one segment, `{a,b}` alternates.
|
|
3
|
+
import { posixPath } from './path-key.mjs';
|
|
4
|
+
|
|
5
|
+
/** Every alternative a `{a,b}` pattern spells, braces expanded left to right. */
|
|
6
|
+
export function braceVariants(value) {
|
|
7
|
+
const match = /\{([^{}]+)\}/.exec(value);
|
|
8
|
+
return match ? match[1].split(',').flatMap((part) => braceVariants(`${value.slice(0, match.index)}${part}${value.slice(match.index + match[0].length)}`)) : [value];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The anchored RegExp of one brace-free glob, read as a posix path (backslashes and a leading './' folded). */
|
|
12
|
+
export function globExpression(value) {
|
|
13
|
+
const input = posixPath(value);
|
|
14
|
+
let source = '';
|
|
15
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
16
|
+
const c = input[i];
|
|
17
|
+
if (c === '*' && input[i + 1] === '*') { i += 1; if (input[i + 1] === '/') { i += 1; source += '(?:.*/)?'; } else source += '.*'; }
|
|
18
|
+
else if (c === '*') source += '[^/]*';
|
|
19
|
+
else if (c === '?') source += '[^/]';
|
|
20
|
+
else source += /[.+^${}()|[\]\\]/.test(c) ? `\\${c}` : c;
|
|
21
|
+
}
|
|
22
|
+
return new RegExp(`^${source}$`);
|
|
23
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { braceVariants, globExpression } from './glob.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a slot's `requires`, `allows` and `forbids` entries (knowledge/hfs/slots.yaml) say about a file, read through the
|
|
6
|
+
* resolver of scripts/lib/hfs-slots.mjs. The machine checks that judge "this folder holds only what its slot allows"
|
|
7
|
+
* (feature-shape, fe-slot-allows) and the front-end lint rules (through `hfs.allows(file)` of scripts/lib/hfs-view.mjs) read it here so no check keeps a path list.
|
|
8
|
+
*
|
|
9
|
+
* An entry is a name relative to the slot instance root: `<var>` is the instance's bound variable when the slot binds it
|
|
10
|
+
* (`<feature>`, `<capability>`) and one path segment of any text otherwise (`<action>`), `*` and `?` stay inside a segment,
|
|
11
|
+
* `{a,b}` alternates, a trailing `/` names a directory and everything below it.
|
|
12
|
+
*/
|
|
13
|
+
const VAR = /<([A-Za-z][A-Za-z0-9-]*)>/g;
|
|
14
|
+
|
|
15
|
+
function matchersOf(entries, bindings) {
|
|
16
|
+
return (entries ?? []).flatMap(entry => {
|
|
17
|
+
const directory = entry.endsWith('/');
|
|
18
|
+
const body = directory ? entry.slice(0, -1) : entry;
|
|
19
|
+
const filled = body.replace(VAR, (whole, name) => bindings[name] ?? '*');
|
|
20
|
+
return braceVariants(filled).map(variant => ({ entry, directory, expression: globExpression(directory ? `${variant}/**` : variant) }));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The path of `file` below the instance root of the slot that owns it. */
|
|
25
|
+
export function relativeToRoot(file, root) {
|
|
26
|
+
return root && file.startsWith(`${root}/`) ? file.slice(root.length + 1) : path.posix.basename(file);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* {slot, root, relative, allowed, entry?, forbiddenBy?} for a repository-relative file, or null when no enabled slot owns
|
|
31
|
+
* it or the slot names no `allows`. `allowed` is true when the relative path matches a `requires` or `allows` entry.
|
|
32
|
+
*/
|
|
33
|
+
export function allowsFile(resolver, file) {
|
|
34
|
+
const classified = resolver.classifyPath(file);
|
|
35
|
+
if (classified.status === 'no-slot' || classified.status === 'ambiguous' || !classified.slot) return null;
|
|
36
|
+
const slot = resolver.slot(classified.slot);
|
|
37
|
+
if (!slot?.allows?.length) return null;
|
|
38
|
+
const relative = relativeToRoot(classified.path, classified.root);
|
|
39
|
+
const hit = matchersOf([...(slot.requires ?? []), ...slot.allows], classified.bindings).find(matcher => matcher.expression.test(relative));
|
|
40
|
+
const forbidden = matchersOf(slot.forbids, classified.bindings).find(matcher => matcher.expression.test(relative) || matcher.expression.test(`${relative}/`));
|
|
41
|
+
return { slot: slot.id, root: classified.root, relative, allowed: Boolean(hit) && !forbidden, entry: hit?.entry, forbiddenBy: forbidden?.entry, allows: slot.allows };
|
|
42
|
+
}
|