Skip to content

Commit

Permalink
Merge pull request #12594 from Snuffleupagus/eslint-no-useless-escape
Browse files Browse the repository at this point in the history
Enable the ESLint `no-useless-escape` rule (PR 12551 follow-up)
  • Loading branch information
timvandermeij authored Nov 7, 2020
2 parents e3851a6 + 9602844 commit 797fedd
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"prefer-promise-reject-errors": "error",
"wrap-iife": ["error", "any"],
Expand Down
2 changes: 1 addition & 1 deletion external/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function preprocessCSS(mode, source, destination) {
}

function expandImports(content, baseUrl) {
return content.replace(/^\s*@import\s+url\(([^\)]+)\);\s*$/gm, function (
return content.replace(/^\s*@import\s+url\(([^)]+)\);\s*$/gm, function (
all,
url
) {
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function safeSpawnSync(command, parameters, options) {
options.shell = true;
// `options.shell = true` requires parameters to be quoted.
parameters = parameters.map(param => {
if (!/[\s`~!#$*(){\[|\\;'"<>?]/.test(param)) {
if (!/[\s`~!#$*(){[|\\;'"<>?]/.test(param)) {
return param;
}
return '"' + param.replace(/([$\\"`])/g, "\\$1") + '"';
Expand Down
2 changes: 1 addition & 1 deletion src/scripting_api/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Util extends PDFObject {
throw new TypeError("First argument of printf must be a string");
}

const pattern = /%(,[0-4])?([\+ 0#]+)?([0-9]+)?(\.[0-9]+)?(.)/g;
const pattern = /%(,[0-4])?([+ 0#]+)?([0-9]+)?(\.[0-9]+)?(.)/g;
const PLUS = 1;
const SPACE = 2;
const ZERO = 4;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ function escapeString(str) {
// replace "(", ")", "\n", "\r" and "\"
// by "\(", "\)", "\\n", "\\r" and "\\"
// in order to write it in a PDF file.
return str.replace(/([\(\)\\\n\r])/g, match => {
return str.replace(/([()\\\n\r])/g, match => {
if (match === "\n") {
return "\\n";
} else if (match === "\r") {
Expand Down
2 changes: 1 addition & 1 deletion test/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ WebServer.prototype = {

var range = req.headers.range;
if (range && !disableRangeRequests) {
var rangesMatches = /^bytes=(\d+)\-(\d+)?/.exec(range);
var rangesMatches = /^bytes=(\d+)-(\d+)?/.exec(range);
if (!rangesMatches) {
res.writeHead(501);
res.end("Bad range", "utf8");
Expand Down
2 changes: 1 addition & 1 deletion web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ const PDFViewerApplication = {
if (!producer.includes(generator)) {
return false;
}
generatorId = generator.replace(/[ .\-]/g, "_");
generatorId = generator.replace(/[ .-]/g, "_");
return true;
});
}
Expand Down
2 changes: 1 addition & 1 deletion web/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var FontInspector = (function FontInspectorClosure() {
name.textContent = fontName;
var download = document.createElement("a");
if (url) {
url = /url\(['"]?([^\)"']+)/.exec(url);
url = /url\(['"]?([^)"']+)/.exec(url);
download.href = url[1];
} else if (fontObj.data) {
download.href = URL.createObjectURL(
Expand Down
6 changes: 3 additions & 3 deletions web/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,10 @@ function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
);
return defaultFilename;
}
const reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
// SCHEME HOST 1.PATH 2.QUERY 3.REF
const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
// SCHEME HOST 1.PATH 2.QUERY 3.REF
// Pattern to get last matching NAME.pdf
const reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
const splitURI = reURI.exec(url);
let suggestedFilename =
reFilename.exec(splitURI[1]) ||
Expand Down

0 comments on commit 797fedd

Please sign in to comment.