Chore: update ESLint config

This commit is contained in:
SukkaW
2023-09-28 22:59:19 +08:00
parent d69def0024
commit 3d2afa608c
21 changed files with 315 additions and 315 deletions

View File

@@ -14,7 +14,7 @@ const { createCachedGorhillGetDomain } = require('./lib/cached-tld-parse');
* @param {string} string
*/
const escapeRegExp = (string) => {
return string.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
return string.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&');
};
const buildInternalCDNDomains = task(__filename, async () => {

View File

@@ -181,10 +181,10 @@ function matchWithRegExpArray(input, regexps = []) {
}
function escapeRegExp(string = '') {
const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
const reRegExpChar = /[$()*+.?[\\\]^{|}]/g;
const reHasRegExpChar = RegExp(reRegExpChar.source);
return string && reHasRegExpChar.test(string)
? string.replace(reRegExpChar, '\\$&')
? string.replaceAll(reRegExpChar, '\\$&')
: string;
}

View File

@@ -229,7 +229,7 @@ async function processFilterRules(filterRulesUrl, fallbackUrls) {
};
}
const R_KNOWN_NOT_NETWORK_FILTER_PATTERN = /[#&%~=]/;
const R_KNOWN_NOT_NETWORK_FILTER_PATTERN = /[#%&=~]/;
const R_KNOWN_NOT_NETWORK_FILTER_PATTERN_2 = /(\$popup|\$removeparam|\$popunder)/;
/**
@@ -350,8 +350,6 @@ function parse($line, gorhill) {
return null;
}
/* eslint-disable no-nested-ternary -- speed */
const linedEndsWithCaret = lastChar === '^';
const lineEndsWithCaretVerticalBar = lastChar === '|' && line[len - 2] === '^';
@@ -425,9 +423,8 @@ function parse($line, gorhill) {
? -1
: lineEndsWithCaretOrCaretVerticalBar
? -2
: line.endsWith('$cname')
? -6
: 0;
// eslint-disable-next-line sukka/unicorn/no-nested-ternary -- speed
: (line.endsWith('$cname') ? -6 : 0);
const _domain = line
// .replace('||', '')
@@ -458,9 +455,7 @@ function parse($line, gorhill) {
1,
linedEndsWithCaret
? -1
: lineEndsWithCaretVerticalBar
? -2
: 0
: (lineEndsWithCaretVerticalBar ? -2 : 0)
) // remove prefix dot
.replace('^|', '')
.replaceAll('^', '')