mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-31 19:11:53 +08:00
Chore: update ESLint config
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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('^', '')
|
||||
|
||||
Reference in New Issue
Block a user