Skip to content

Commit bc31a4b

Browse files
committed
Enable the unicorn/prefer-starts-ends-with ESLint plugin rule
This complements the existing `mozilla/use-includes-instead-of-indexOf` plugin rule, by also disallowing unnecessary regular expressions when comparing strings. Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-starts-ends-with.md for additional information.
1 parent f6ffc2b commit bc31a4b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"no-unsanitized/method": "error",
3939
"no-unsanitized/property": "error",
4040
"unicorn/no-array-instanceof": "error",
41+
"unicorn/prefer-starts-ends-with": "error",
4142

4243
// Possible errors
4344
"for-direction": "error",

src/display/network_utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function extractFilenameFromHeader(getResponseHeader) {
7878
}
7979

8080
function createResponseStatusError(status, url) {
81-
if (status === 404 || (status === 0 && /^file:/.test(url))) {
81+
if (status === 404 || (status === 0 && url.startsWith("file:"))) {
8282
return new MissingPDFException('Missing PDF "' + url + '".');
8383
}
8484
return new UnexpectedResponseException(

0 commit comments

Comments
 (0)