Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jul 15, 2024
1 parent 0fe07a4 commit 40bfb90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function resolveOptions(options: Options): OptionsResolved {
include: options.include,
exclude: options.exclude,
sourceMap: options.sourceMap ?? true,
delimiters: options.delimiters || ['\\b', '\\b(?!\\.)'],
delimiters: options.delimiters || [String.raw`\b`, String.raw`\b(?!\.)`],
preventAssignment: options.preventAssignment ?? false,
objectGuards: options.objectGuards ?? false,
values: getReplacements(),
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ const pluign: UnpluginInstance<Options | undefined, false> = createUnplugin<
const escapedKeys = stringValues
.map(({ find }) => find)
.sort(longest)
// eslint-disable-next-line unicorn/no-array-callback-reference
.map(escape)
const lookahead = preventAssignment ? '(?!\\s*(=[^=]|:[^:]))' : ''
const lookahead = preventAssignment ? String.raw`(?!\s*(=[^=]|:[^:]))` : ''
const pattern = new RegExp(
`${delimiters[0]}(${escapedKeys.join('|')})${delimiters[1]}${lookahead}`,
'g',
Expand All @@ -138,7 +137,7 @@ export default pluign

function escape(str: string) {
// eslint-disable-next-line unicorn/prefer-string-replace-all
return str.replace(/[$()*+./?[\\\]^{|}-]/g, '\\$&')
return str.replace(/[$()*+./?[\\\]^{|}-]/g, String.raw`\$&`)
}

function ensureFunction(
Expand Down

0 comments on commit 40bfb90

Please sign in to comment.