Files
SyncIt21 2c76673f70 Updates Biome & Prettier with linting applied (#96394)
## About The Pull Request
- Update Biome to 2.4.16
- Update prettier to 3.8.3
- Apply biome linting rules to a bunch of files
- Convert some files from common-js to es module

## Changelog
N/A
2026-06-10 09:08:43 +12:00

50 lines
1.1 KiB
JavaScript

import fs from 'node:fs';
const REGEX_COMMENT = /<!--.+?-->/g;
// Make sure we only remove default comments
const comments = [];
for (const match of fs
.readFileSync('.github/PULL_REQUEST_TEMPLATE.md', { encoding: 'utf8' })
.matchAll(REGEX_COMMENT)) {
comments.push(match[0]);
}
function escapeRegex(string) {
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
}
export async function removeGuideComments({ github, context }) {
const originalBody = (
await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
})
).data.body;
if (!originalBody) {
console.log('PR body is empty, skipping...');
return;
}
let newBody = originalBody;
for (const comment of comments) {
newBody = newBody.replace(
new RegExp(`^\\s*${escapeRegex(comment)}\\s*`, 'gm'),
'\n',
);
}
if (newBody !== originalBody) {
await github.rest.pulls.update({
pull_number: context.payload.pull_request.number,
repo: context.repo.repo,
owner: context.repo.owner,
body: newBody,
});
}
}