* feat(#2982): extend no-source-grep lint to catch var-binding readFileSync.includes() The base lint (scripts/lint-no-source-grep.cjs) only catches readFileSync(...).<text-method>() chained directly. The much more common var-binding form escapes it: const src = fs.readFileSync(p, 'utf8'); // 50 lines later if (src.includes('foo')) {} // ← still grep, lint missed it Scan of the test suite found ~141 files using this pattern. Implementation built TDD per #2982 with structured-IR assertions: scripts/lint-no-source-grep-extras.cjs - detectVarBindingViolations(src) — pure detector, two passes: pass 1 collects vars bound from readFileSync, pass 2 finds any <var>.<includes|startsWith|endsWith|match|search>( on those vars. - detectWrappedAssertOkMatch(src) — flags assert.ok(<expr>.match(...)) which escapes the assert.match rule. - VIOLATION enum exposes stable codes for tests to assert on. scripts/lint-no-source-grep.cjs - Wires the new detectors into the existing per-file check; one additional violation row per file with the first 3 sample tokens. tests/bug-2982-lint-var-binding.test.cjs - 13 tests, all assertions on typed VIOLATION enum / structured records. Covers all 5 text-match methods, multi-var, no-bind, string literal (must NOT trigger), wrapped assert.ok(.match), and assert.match (must NOT double-flag). Migration backlog (#2974 expanded scope): - 42 files annotated `// allow-test-rule: source-text-is-the-product` (legitimate — they read .md/.json/.yml files whose deployed text IS the product) - 3 files annotated `// allow-test-rule: pending-migration-to-typed-ir [#2974]` (read .cjs/.js source — clear migration debt) - 95 files annotated `pending-migration-to-typed-ir [#2974]` with `Per-file review may reclassify as source-text-is-the-product during migration` (mixed — manual review under #2974) After this lands the lint reports 0 violations on main; new violations in PRs surface immediately. Closes #2982 Refs #2974 * test(#2982): fix truncated test name per CR The label ended with a bare '(' from a copy-paste mishap. Now reads 'does NOT flag .matchAll(...) — matchAll is not match, so assert.ok(.matchAll(...)) is not flagged'. * chore(#2982): add changeset fragment for PR #2985 * chore(#2982): add changeset fragment for PR #2985
64 lines
3.3 KiB
JavaScript
64 lines
3.3 KiB
JavaScript
// allow-test-rule: pending-migration-to-typed-ir [#2974]
|
|
// Tracked in #2974 for migration to typed-IR assertions per CONTRIBUTING.md
|
|
// "Prohibited: Raw Text Matching on Test Outputs". Per-file review may
|
|
// reclassify some entries as source-text-is-the-product during migration.
|
|
|
|
const { test, describe, beforeEach, afterEach } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// #2790: analyze-dependencies.md was deleted (dead skill). The workflow still
|
|
// exists for direct invocation and is tested below.
|
|
describe('analyze-dependencies command', () => {
|
|
test('analyze-dependencies command file was consolidated away (deleted in #2790)', () => {
|
|
// The standalone /gsd-analyze-dependencies command was removed as a dead skill in #2790.
|
|
// The underlying workflow (workflows/analyze-dependencies.md) remains functional.
|
|
const deleted = path.join(__dirname, '..', 'commands', 'gsd', 'analyze-dependencies.md');
|
|
assert.ok(!fs.existsSync(deleted), 'analyze-dependencies.md should have been deleted in #2790');
|
|
});
|
|
|
|
// Legacy placeholder: was previously a separate test; now just passes trivially.
|
|
test('workflow file is sufficient without a standalone command file', () => {
|
|
const p = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'analyze-dependencies.md');
|
|
assert.ok(fs.existsSync(p), 'workflows/analyze-dependencies.md should still exist');
|
|
});
|
|
|
|
test('workflow file exists', () => {
|
|
const p = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'analyze-dependencies.md');
|
|
assert.ok(fs.existsSync(p), 'workflows/analyze-dependencies.md should exist');
|
|
});
|
|
|
|
test('workflow describes dependency analysis approach', () => {
|
|
const p = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'analyze-dependencies.md');
|
|
const content = fs.readFileSync(p, 'utf-8');
|
|
assert.ok(content.includes('ROADMAP') || content.includes('phase'),
|
|
'workflow should reference ROADMAP.md/phases');
|
|
assert.ok(
|
|
content.includes('depends') || content.includes('Depends') || content.includes('dependency'),
|
|
'workflow should reference dependency detection'
|
|
);
|
|
});
|
|
|
|
test('workflow mentions file overlap detection', () => {
|
|
const p = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'analyze-dependencies.md');
|
|
const content = fs.readFileSync(p, 'utf-8');
|
|
assert.ok(
|
|
content.includes('file') && (content.includes('overlap') || content.includes('conflict')),
|
|
'workflow should mention file overlap/conflict detection'
|
|
);
|
|
});
|
|
|
|
test('docs/COMMANDS.md does not document the consolidated-away /gsd-analyze-dependencies entry', () => {
|
|
// #2790 deleted the standalone command file. COMMANDS.md must no longer advertise it.
|
|
// The underlying capability lives in workflows/analyze-dependencies.md and is invoked
|
|
// from consolidated entry points (see gsd-phase / gsd-progress workflow chains).
|
|
const p = path.join(__dirname, '..', 'docs', 'COMMANDS.md');
|
|
if (!fs.existsSync(p)) return;
|
|
const content = fs.readFileSync(p, 'utf-8');
|
|
// Look only for the section header form so we tolerate workflow-internal references.
|
|
assert.ok(!/^### `\/gsd-analyze-dependencies`/m.test(content),
|
|
'COMMANDS.md should not document the removed /gsd-analyze-dependencies command');
|
|
});
|
|
});
|