diff --git a/eslint.config.js b/eslint.config.js
index 2538d3e4..aae7129b 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -33,16 +33,12 @@ export default tseslint.config(
],
// unicorn rules:
- 'require-unicode-regexp': 'error',
'unicorn/expiring-todo-comments': 'off',
'unicorn/import-style': 'off',
'unicorn/no-anonymous-default-export': 'off',
'unicorn/no-array-reduce': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/no-useless-undefined': 'off', // We use a lot of `return undefined` to satisfy the `consistent-return` rule.
- 'unicorn/prefer-at': 'off',
- 'unicorn/prefer-string-raw': 'off',
- 'unicorn/prefer-string-replace-all': 'off',
'unicorn/prevent-abbreviations': 'off',
// typescript-eslint rules:
@@ -112,6 +108,7 @@ export default tseslint.config(
radix: 'error',
'require-atomic-updates': 'error',
'require-await': 'error',
+ 'require-unicode-regexp': 'error',
'spaced-comment': ['error', 'always', { markers: ['*', '!'] }],
'sort-vars': 'error',
yoda: 'error',
diff --git a/lib/markdown.ts b/lib/markdown.ts
index 92ae0d35..bffba98e 100644
--- a/lib/markdown.ts
+++ b/lib/markdown.ts
@@ -93,8 +93,8 @@ export function expectContentOrFail(
// in case escaping is needed where the content is referenced.
const hasContent =
contents.includes(content) ||
- contents.includes(content.replace(/"/gu, '\\"')) ||
- contents.includes(content.replace(/'/gu, "\\'"));
+ contents.includes(content.replaceAll('"', String.raw`\"`)) ||
+ contents.includes(content.replaceAll("'", String.raw`\'`));
if (hasContent !== expected) {
console.error(
`${docName} should ${
diff --git a/lib/rule-link.ts b/lib/rule-link.ts
index 5bbff61e..f08bbe9f 100644
--- a/lib/rule-link.ts
+++ b/lib/rule-link.ts
@@ -14,7 +14,7 @@ export function replaceRulePlaceholder(
if (typeof pathOrUrl === 'function') {
return pathOrUrl(ruleName);
}
- return pathOrUrl.replace(/\{name\}/gu, ruleName);
+ return pathOrUrl.replaceAll('{name}', ruleName);
}
/**
diff --git a/lib/rule-list.ts b/lib/rule-list.ts
index 4a0d09c0..78a567a0 100644
--- a/lib/rule-list.ts
+++ b/lib/rule-list.ts
@@ -365,8 +365,11 @@ function getRulesAndHeadersForSplit(
// Turn ruleListSplit into a title.
// E.g. meta.docs.requiresTypeChecking to "Requires Type Checking".
const ruleListSplitParts = ruleListSplitItem.split('.');
- const ruleListSplitFinalPart =
- ruleListSplitParts[ruleListSplitParts.length - 1];
+ const ruleListSplitFinalPart = ruleListSplitParts.at(-1);
+ /* istanbul ignore next -- this shouldn't happen */
+ if (!ruleListSplitFinalPart) {
+ throw new Error(`Invalid ruleListSplit value "${ruleListSplitItem}".`);
+ }
const ruleListSplitTitle = noCase(ruleListSplitFinalPart, {
transform: (str) => capitalizeOnlyFirstLetter(str),
});
diff --git a/lib/string.ts b/lib/string.ts
index a2d43bc5..e8210267 100644
--- a/lib/string.ts
+++ b/lib/string.ts
@@ -22,7 +22,9 @@ export function capitalizeOnlyFirstLetter(str: string) {
}
function sanitizeMarkdownTableCell(text: string): string {
- return text.replace(/\|/gu, '\\|').replace(new RegExp(EOL, 'gu'), '
');
+ return text
+ .replaceAll('|', String.raw`\|`)
+ .replaceAll(new RegExp(EOL, 'gu'), '
');
}
export function sanitizeMarkdownTable(
diff --git a/test/lib/generate/option-postprocess-test.ts b/test/lib/generate/option-postprocess-test.ts
index 82ee92a6..63201181 100644
--- a/test/lib/generate/option-postprocess-test.ts
+++ b/test/lib/generate/option-postprocess-test.ts
@@ -49,7 +49,7 @@ describe('generate (postprocess option)', function () {
[
content,
'',
- `Located at ${relative('.', path).replace(/\\/gu, '/')}`, // Always use forward slashes in the path so the snapshot is right even when testing on Windows.
+ `Located at ${relative('.', path).replaceAll('\\', '/')}`, // Always use forward slashes in the path so the snapshot is right even when testing on Windows.
].join('\n'),
});
expect(readFileSync('README.md', 'utf8')).toMatchSnapshot();