Skip to content

Commit aae6717

Browse files
authored
fix: sync rule type header comments automatically (#19276)
* fix: sync rule type header comments * replace string instead of regex * use `unicorn/prefer-string-slice` instead of `no-restricted-properties` * update only new and modified rule types on commit hook, update all rule types on release * apply review suggestions * run npm script in CI
1 parent 8a0a5a8 commit aae6717

13 files changed

Lines changed: 766 additions & 338 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ jobs:
6363
- name: Check Rule Examples
6464
run: node Makefile checkRuleExamples
6565

66+
- name: Check Rule Types
67+
run: npm run lint:rule-types
68+
6669
- name: Lint Files, Dependencies, & Exports
6770
run: npm run lint:unused
6871

Makefile.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,21 @@ function updateVersions(oldVersion, newVersion) {
323323
fs.writeFileSync(filePath, `${JSON.stringify(data, null, 4)}\n`);
324324
}
325325

326+
/**
327+
* Updates TSDoc header comments of all rule types.
328+
* @returns {void}
329+
*/
330+
function updateRuleTypeHeaders() {
331+
const { execFileSync } = require("node:child_process");
332+
333+
// We don't need the stack trace of execFileSync if the command fails.
334+
try {
335+
execFileSync(process.execPath, ["tools/update-rule-type-headers.js"], { stdio: "inherit" });
336+
} catch {
337+
exit(1);
338+
}
339+
}
340+
326341
/**
327342
* Updates the changelog, bumps the version number in package.json, creates a local git commit and tag,
328343
* and generates the site in an adjacent `website` folder.
@@ -356,8 +371,11 @@ function generateRelease({ prereleaseId, packageTag }) {
356371
updateVersions(oldVersion, releaseInfo.version);
357372
}
358373

359-
echo("Updating commit with docs data");
360-
exec("git add docs/ && git commit --amend --no-edit");
374+
echo("Updating rule type header comments");
375+
updateRuleTypeHeaders();
376+
377+
echo("Updating commit with docs data and rule types");
378+
exec("git add lib/types/rules/ docs/ && git commit --amend --no-edit");
361379
exec(`git tag -a -f v${releaseInfo.version} -m ${releaseInfo.version}`);
362380
}
363381

0 commit comments

Comments
 (0)