* chore(#3059): close the ESLint glob-coverage escape and guard it 62 tracked source files matched no `files:` glob in eslint.config.mjs, so ESLint skipped them entirely while `eslint .` still exited 0 — including all 26 files under hooks/, the enforcement machinery itself. Covers 56 of them (eslint-rules/, hooks/, bin/lib/, pi/, examples/, vscode/, the plugin shims, root *.mjs) and allowlists the 6 deliberate must-not-compile brand-typing fixtures with a recorded reason each. hooks/** is covered with n/no-process-exit deliberately off: a hook's whole contract is its exit code, several exits are load-bearing stdin-timeout guards where nothing else terminates the process, and ADR-0012/0174 scope the no-process-exit convention to the Command Routing Hub. bin/lib/ui-safety-gate.cjs is dual-mode, so it keeps the rule live and takes two targeted disables in its require.main===module tail instead. Adds scripts/lint-eslint-glob-coverage.cjs + a node:test drift guard so the class cannot regrow: allowlist entries require a non-empty reason, the list ratchets down only (a stale entry fails), and a tracked-count floor means a broken `git ls-files` fails rather than reporting clean. Closes #3059 * chore(#3059): apply review findings — correct the changeset count, add parser properties Isolated adversarial review, confirmed by rebuilding a byte-for-byte replica of the pre-change eslint.config.mjs: the changeset claimed 44 previously- unlinted files. The real figure is 56 (56 covered + 6 allowlisted = 62). That was user-facing CHANGELOG text and was wrong; corrected, along with three consequential figures in the design record. CLAUDE.md requires a fast-check property test for parsers and budget limits, and listTrackedSourceFiles is a parser. The standards review called this "satisfied in spirit"; it is not. Adds three properties driving the real exported parser through an injected execFile: extension totality/soundness including a trailing terminator, backslash-normalization totality, and CRLF/LF equivalence — the invariant the repo's recurring CRLF defect class breaks. Also de-duplicates the anchor rows onto one shared resolver, kept deliberately independent of the guard's own resolveFileCoverage so an anchor still fails if that resolution regresses, and records in the guard's header why the bin/install.js family is NOT allowlisted: it resolves to 2 rules under ADR-1703, so an entry would trip the allowlist_stale ratchet. * fix(#3059): make the coverage guard's git call container-safe The remote runner reported the guard degrading to `git_failed` on both Node lanes: fatal: detected dubious ownership in repository at '/work' The runner executes in a container where the repo is owned by a different UID, so git refuses to operate on it. The guard's degraded-verdict path worked exactly as designed — it reported the failure instead of throwing or falsely reporting clean — but a guard that cannot run in CI is not a gate. `git ls-files` is now invoked as `git -c safe.directory=* ls-files`. `-c` scopes the override to the single invocation and mutates no config file, and the wildcard is appropriate because this command only enumerates tracked paths in the repository it is already executing inside. Adds a regression test that captures the argv through the injected execFile seam and asserts `-c safe.directory=*` precedes `ls-files`, so the container case is pinned behaviorally rather than by reading the script's source. * chore(#3059): backfill changeset PR number pr:0 placeholder replaced with the real number now that #3277 exists. --------- Co-authored-by: sim <sim@local>
113 lines
3.5 KiB
JavaScript
113 lines
3.5 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* require-userprofile-with-home
|
|
*
|
|
* Flag test files that assign `process.env.HOME` without also referencing
|
|
* `USERPROFILE` anywhere in the file.
|
|
*
|
|
* ## What this enforces (G6)
|
|
*
|
|
* Program-level: collect assignments to `process.env.HOME`
|
|
* (`process.env.HOME = …` / `process.env['HOME'] = …`); track whether
|
|
* `USERPROFILE` appears anywhere in the file (any reference). At
|
|
* `Program:exit`, if HOME is assigned and `USERPROFILE` never appears, report
|
|
* each HOME assignment.
|
|
*
|
|
* Message: Windows uses `USERPROFILE`, not `HOME` — set
|
|
* `process.env.USERPROFILE` alongside.
|
|
*
|
|
* DEFECT category: DEFECT.WINDOWS-TEST-PORTABILITY
|
|
*/
|
|
|
|
/** @type {import('eslint').Rule.RuleModule} */
|
|
const rule = {
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
description:
|
|
'Require process.env.USERPROFILE to be set alongside process.env.HOME (Windows portability)',
|
|
category: 'Portability',
|
|
},
|
|
schema: [],
|
|
messages: {
|
|
missingUserProfile:
|
|
'Assigning process.env.HOME without process.env.USERPROFILE is not portable ' +
|
|
'(DEFECT.WINDOWS-TEST-PORTABILITY): Windows uses USERPROFILE as the home ' +
|
|
'directory environment variable, not HOME. Set process.env.USERPROFILE ' +
|
|
'alongside process.env.HOME.',
|
|
},
|
|
},
|
|
|
|
create(context) {
|
|
/** Collected HOME assignment nodes */
|
|
const homeAssignments = [];
|
|
|
|
/** Whether a real process.env.USERPROFILE = … assignment exists in the file */
|
|
let userProfileAssigned = false;
|
|
|
|
/**
|
|
* Returns true if node is an assignment to process.env[key] or
|
|
* process.env.key for the given key name.
|
|
*
|
|
* Recognized shapes (as the left-hand side of AssignmentExpression):
|
|
* process.env.KEY — MemberExpression(MemberExpression, Identifier)
|
|
* process.env['KEY'] — MemberExpression(MemberExpression, Literal, computed=true)
|
|
*
|
|
* @param {import('eslint').Rule.Node} lhs — left side of AssignmentExpression
|
|
* @param {string} key — the env var name to check
|
|
* @returns {boolean}
|
|
*/
|
|
function isProcessEnvAssignment(lhs, key) {
|
|
if (!lhs || lhs.type !== 'MemberExpression') return false;
|
|
const obj = lhs.object;
|
|
if (!obj || obj.type !== 'MemberExpression') return false;
|
|
|
|
// obj must be process.env
|
|
if (
|
|
obj.computed ||
|
|
obj.object.type !== 'Identifier' ||
|
|
obj.object.name !== 'process' ||
|
|
obj.property.type !== 'Identifier' ||
|
|
obj.property.name !== 'env'
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
// Property must be key (identifier or string literal)
|
|
if (!lhs.computed) {
|
|
return lhs.property.type === 'Identifier' && lhs.property.name === key;
|
|
} else {
|
|
return (
|
|
lhs.property.type === 'Literal' && lhs.property.value === key
|
|
);
|
|
}
|
|
}
|
|
|
|
return {
|
|
AssignmentExpression(node) {
|
|
if (isProcessEnvAssignment(node.left, 'HOME')) {
|
|
homeAssignments.push(node);
|
|
}
|
|
// Track actual USERPROFILE assignments (not mere text/comment mentions)
|
|
if (isProcessEnvAssignment(node.left, 'USERPROFILE')) {
|
|
userProfileAssigned = true;
|
|
}
|
|
},
|
|
|
|
'Program:exit'() {
|
|
if (homeAssignments.length === 0) return;
|
|
|
|
// Only suppress if USERPROFILE is actually ASSIGNED (not just mentioned in a comment)
|
|
if (userProfileAssigned) return;
|
|
|
|
for (const node of homeAssignments) {
|
|
context.report({ node, messageId: 'missingUserProfile' });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|
|
|
|
module.exports = rule;
|