Use String.raw and RegExp.exec, add prefer-regexp-exec oxlint rule
Replace escaped backslash in template literal with String.raw in auto-number.ts. Use RegExp#exec() instead of String#match() in bestiary-adapter.ts. Enable typescript/prefer-regexp-exec in oxlint for automated enforcement. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
"rules": {
|
||||
"typescript/no-unnecessary-type-assertion": "error",
|
||||
"typescript/no-deprecated": "warn",
|
||||
"typescript/prefer-regexp-exec": "error",
|
||||
"unicorn/prefer-string-replace-all": "error",
|
||||
"unicorn/prefer-string-raw": "error",
|
||||
"jest/expect-expect": [
|
||||
|
||||
@@ -170,7 +170,7 @@ function extractAc(ac: RawMonster["ac"]): {
|
||||
}
|
||||
if ("special" in first) {
|
||||
// Variable AC (e.g. spell summons) — parse leading number if possible
|
||||
const match = first.special.match(LEADING_DIGITS_REGEX);
|
||||
const match = LEADING_DIGITS_REGEX.exec(first.special);
|
||||
return {
|
||||
value: match ? Number(match[1]) : 0,
|
||||
source: first.special,
|
||||
|
||||
@@ -23,7 +23,9 @@ export function resolveCreatureName(
|
||||
if (name === baseName) {
|
||||
exactMatches.push(i);
|
||||
} else {
|
||||
const match = new RegExp(`^${escapeRegExp(baseName)} (\\d+)$`).exec(name);
|
||||
const match = new RegExp(
|
||||
String.raw`^${escapeRegExp(baseName)} (\d+)$`,
|
||||
).exec(name);
|
||||
// biome-ignore lint/nursery/noUnnecessaryConditions: RegExp.exec() returns null on no match — false positive
|
||||
if (match) {
|
||||
const num = Number.parseInt(match[1], 10);
|
||||
|
||||
Reference in New Issue
Block a user