mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Enable the unicorn/prefer-string-replace-all
ESLint plugin rule
Note that the `replaceAll` method still requires that a *global* regular expression is used, however by using this method it's immediately obvious when looking at the code that all occurrences will be replaced; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#parameters Please find additional details at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-replace-all.md
This commit is contained in:
parent
5f64621d46
commit
1fc09f0235
26 changed files with 58 additions and 56 deletions
10
external/builder/builder.js
vendored
10
external/builder/builder.js
vendored
|
@ -41,7 +41,7 @@ function preprocess(inFilename, outFilename, defines) {
|
|||
}
|
||||
|
||||
function expandCssImports(content, baseUrl) {
|
||||
return content.replace(
|
||||
return content.replaceAll(
|
||||
/^\s*@import\s+url\(([^)]+)\);\s*$/gm,
|
||||
function (all, url) {
|
||||
const file = path.join(path.dirname(baseUrl), url);
|
||||
|
@ -121,7 +121,7 @@ function preprocess(inFilename, outFilename, defines) {
|
|||
}
|
||||
}
|
||||
function expand(line) {
|
||||
line = line.replace(/__[\w]+__/g, function (variable) {
|
||||
line = line.replaceAll(/__[\w]+__/g, function (variable) {
|
||||
variable = variable.substring(2, variable.length - 2);
|
||||
if (variable in defines) {
|
||||
return defines[variable];
|
||||
|
@ -210,9 +210,9 @@ function preprocess(inFilename, outFilename, defines) {
|
|||
) {
|
||||
writeLine(
|
||||
line
|
||||
.replace(/^\/\/|^<!--/g, " ")
|
||||
.replace(/(^\s*)\/\*/g, "$1 ")
|
||||
.replace(/\*\/$|-->$/g, "")
|
||||
.replaceAll(/^\/\/|^<!--/g, " ")
|
||||
.replaceAll(/(^\s*)\/\*/g, "$1 ")
|
||||
.replaceAll(/\*\/$|-->$/g, "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue