chore(#452): add ESLint 9 flat-config harness with three custom AST rules (#460)

Install eslint@9 + typescript-eslint@8 + globals@16 + eslint-plugin-n@17 +
eslint-plugin-no-only-tests@3 + typescript as devDependencies.

eslint.config.mjs (flat config):
- Global ignores: node_modules, dist, .worktrees, .claude, coverage, the
  12 generated get-shit-done/bin/lib/*.cjs files
- Block for get-shit-done/bin/**/*.cjs + scripts/**/*.cjs: js.recommended +
  eslint-plugin-n + local plugin; generic quality rules (no-var, prefer-const,
  no-unused-vars, no-empty, n/no-process-exit)
- Block for tests/**/*.test.cjs: no-only-tests (error), local timing rules,
  no-restricted-syntax timing bans

eslint-rules/ local plugin (three AST rules, all at warn pending cleanup):
- no-source-grep: flag readFileSync on source .cjs/.js/.ts + text methods
- no-magic-sleep-in-tests: flag Atomics.wait and await-new-Promise(setTimeout)
- no-elapsed-assertion: flag assert*() on timing props (elapsed/duration/took/ms)

tsconfig.lint.json: allowJs + checkJs + noEmit for future type-aware passes.

tests/eslint-rules.test.cjs: 15 RuleTester unit tests (all pass, 0 fail).

package.json: add lint/lint:fix scripts; remove lint:tests (subsumed by ESLint
local/no-source-grep). Rules that produced pre-existing errors downgraded to
warn: no-useless-escape, no-unsafe-finally, no-regex-spaces, no-control-regex,
no-irregular-whitespace. ESLint exits 0 (warnings ok).

.github/workflows/test.yml lint-tests job: add npm ci + ESLint step; remove
"Lint — no source-grep tests" step (now covered by ESLint); bump timeout 3→5
min. .gitignore: add node_modules/.cache/eslint/ entry.

eslint --fix auto-cleaned: no-regex-spaces in tests, prefer-const in state.cjs,
redundant eslint-disable-next-line comments.

Co-authored-by: CI Rebase Check <ci@gsd-redux>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-29 10:54:49 -04:00
committed by GitHub
parent ed1c20061b
commit 33afb4f6eb
20 changed files with 2260 additions and 35 deletions

View File

@@ -121,7 +121,7 @@ function scanQuickTasks(planDir) {
}
let status = 'missing';
let description = '';
const description = '';
if (summaryPath && fs.existsSync(summaryPath)) {
let safeSum;

View File

@@ -53,7 +53,7 @@ function extractFrontmatter(content) {
// Stack to track nested objects: [{obj, key, indent}]
// obj = object to write to, key = current key collecting array items, indent = indentation level
let stack = [{ obj: frontmatter, key: null, indent: -1 }];
const stack = [{ obj: frontmatter, key: null, indent: -1 }];
for (const line of lines) {
// Skip empty lines

View File

@@ -985,7 +985,7 @@ function cmdInitMilestoneOp(cwd, raw) {
// `phases clear` between milestones, on-disk dirs will be a subset of the
// roadmap until each phase is materialized; reading from disk causes
// `all_phases_complete: true` to fire prematurely.
let roadmapPhaseNumbers = [];
const roadmapPhaseNumbers = [];
try {
const roadmapPath = path.join(planningDir(cwd), 'ROADMAP.md');
const roadmapRaw = fs.readFileSync(roadmapPath, 'utf-8');

View File

@@ -256,7 +256,7 @@ function applyBudget({ sections, budget, options = {} }) {
const budgetUnderPressure = baseTokens > effectiveBudget;
// Available for content (reserve note slot when under pressure)
let contentBudget = budgetUnderPressure
const contentBudget = budgetUnderPressure
? effectiveBudget - NOTE_RESERVE_TOKENS
: effectiveBudget;

View File

@@ -529,7 +529,7 @@ function cmdRoadmapAnnotateDependencies(cwd, phaseNum, raw) {
// Patch ROADMAP.md
let updated = false;
withPlanningLock(cwd, () => {
let content = fs.readFileSync(roadmapPath, 'utf-8');
const content = fs.readFileSync(roadmapPath, 'utf-8');
// Find the phase section.
// #3537: padding-tolerant fragment so the caller's resolved padded id

View File

@@ -32,7 +32,7 @@ function loadInstallExports() {
const savedTestMode = process.env.GSD_TEST_MODE;
if (savedTestMode === undefined) process.env.GSD_TEST_MODE = '1';
try {
// eslint-disable-next-line global-require -- lazy import to avoid running installer at module load
return require('../../../bin/install.js');
} finally {
if (savedTestMode === undefined) delete process.env.GSD_TEST_MODE;

View File

@@ -945,7 +945,7 @@ function stripFrontmatter(content) {
// Handles CRLF line endings and multiple stacked blocks (corruption recovery).
// Greedy: keeps stripping ---...--- blocks separated by optional whitespace.
let result = content;
// eslint-disable-next-line no-constant-condition
while (true) {
const stripped = result.replace(/^\s*---\r?\n[\s\S]*?\r?\n---\s*/, '');
if (stripped === result) break;
@@ -1001,7 +1001,7 @@ function acquireStateLock(statePath) {
const startedAt = Date.now();
const sleepBuffer = new Int32Array(new SharedArrayBuffer(4)); // hoisted; value stays 0, pure Atomics.wait timeout target
// eslint-disable-next-line no-constant-condition
while (true) {
try {
const fd = fs.openSync(lockPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY);
@@ -1391,7 +1391,7 @@ function cmdStatePlannedPhase(cwd, phaseNumber, planCount, raw) {
// Update Total Plans in Phase
if (planCount !== null && planCount !== undefined) {
let result = stateReplaceField(content, 'Total Plans in Phase', String(planCount));
const result = stateReplaceField(content, 'Total Plans in Phase', String(planCount));
if (result) { content = result; updated.push('Total Plans in Phase'); }
}
@@ -1403,7 +1403,7 @@ function cmdStatePlannedPhase(cwd, phaseNumber, planCount, raw) {
// Update Last Activity Description
{
let result = stateReplaceField(content, 'Last Activity Description', `Phase ${phaseNumber} planning complete — ${planCount || '?'} plans ready`);
const result = stateReplaceField(content, 'Last Activity Description', `Phase ${phaseNumber} planning complete — ${planCount || '?'} plans ready`);
if (result) { content = result; updated.push('Last Activity Description'); }
}