mirror of https://github.com/gorhill/uBlock.git
Fix ESLint indentation warnings (#3800)
* Fix ESLint indentation warnings * Undo code reformatting within parentheses * Add exception for logical expressions * Update array expression rule * Disable rule for reProceduralOperator assignment * Fix indentation in static-filtering-parser.js
This commit is contained in:
parent
6b85b7f2b1
commit
3ca5e6817d
|
@ -9,7 +9,21 @@
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"indent": [ "warn", 4 ],
|
"indent": [
|
||||||
|
"warn",
|
||||||
|
4,
|
||||||
|
{
|
||||||
|
"ArrayExpression": "first",
|
||||||
|
"CallExpression": { "arguments": "first" },
|
||||||
|
"MemberExpression": "off",
|
||||||
|
"ObjectExpression": "off",
|
||||||
|
"ignoreComments": true,
|
||||||
|
"ignoredNodes": [
|
||||||
|
"AssignmentExpression:has(Literal)",
|
||||||
|
"LogicalExpression"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"getter-return": "off",
|
"getter-return": "off",
|
||||||
"no-control-regex": "off",
|
"no-control-regex": "off",
|
||||||
"no-empty": [ "error", { "allowEmptyCatch": true } ],
|
"no-empty": [ "error", { "allowEmptyCatch": true } ],
|
||||||
|
|
|
@ -166,7 +166,7 @@ function reset() {
|
||||||
// module.exports. Once all included files are written like ES modules, using
|
// module.exports. Once all included files are written like ES modules, using
|
||||||
// export statements, this should no longer be necessary.
|
// export statements, this should no longer be necessary.
|
||||||
if (typeof module !== 'undefined' && typeof exports !== 'undefined') {
|
if (typeof module !== 'undefined' && typeof exports !== 'undefined') {
|
||||||
module.exports = exports;
|
module.exports = exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
|
@ -1312,7 +1312,7 @@ Parser.prototype.SelectorCompiler = class {
|
||||||
this.rePseudoElement = /:(?::?after|:?before|:-?[a-z][a-z-]*[a-z])$/;
|
this.rePseudoElement = /:(?::?after|:?before|:-?[a-z][a-z-]*[a-z])$/;
|
||||||
this.reProceduralOperator = new RegExp([
|
this.reProceduralOperator = new RegExp([
|
||||||
'^(?:',
|
'^(?:',
|
||||||
Array.from(parser.proceduralOperatorTokens.keys()).join('|'),
|
Array.from(parser.proceduralOperatorTokens.keys()).join('|'),
|
||||||
')\\('
|
')\\('
|
||||||
].join(''));
|
].join(''));
|
||||||
this.reEatBackslashes = /\\([()])/g;
|
this.reEatBackslashes = /\\([()])/g;
|
||||||
|
@ -2183,30 +2183,30 @@ Parser.prototype.OPTNotSupported = OPTNotSupported;
|
||||||
|
|
||||||
const netOptionTokenDescriptors = new Map([
|
const netOptionTokenDescriptors = new Map([
|
||||||
[ '1p', OPTToken1p | OPTCanNegate ],
|
[ '1p', OPTToken1p | OPTCanNegate ],
|
||||||
[ 'first-party', OPTToken1p | OPTCanNegate ],
|
/* synonym */ [ 'first-party', OPTToken1p | OPTCanNegate ],
|
||||||
[ 'strict1p', OPTToken1pStrict ],
|
[ 'strict1p', OPTToken1pStrict ],
|
||||||
[ '3p', OPTToken3p | OPTCanNegate ],
|
[ '3p', OPTToken3p | OPTCanNegate ],
|
||||||
[ 'third-party', OPTToken3p | OPTCanNegate ],
|
/* synonym */ [ 'third-party', OPTToken3p | OPTCanNegate ],
|
||||||
[ 'strict3p', OPTToken3pStrict ],
|
[ 'strict3p', OPTToken3pStrict ],
|
||||||
[ 'all', OPTTokenAll | OPTNetworkType | OPTNonCspableType ],
|
[ 'all', OPTTokenAll | OPTNetworkType | OPTNonCspableType ],
|
||||||
[ 'badfilter', OPTTokenBadfilter ],
|
[ 'badfilter', OPTTokenBadfilter ],
|
||||||
[ 'cname', OPTTokenCname | OPTAllowOnly | OPTModifierType ],
|
[ 'cname', OPTTokenCname | OPTAllowOnly | OPTModifierType ],
|
||||||
[ 'csp', OPTTokenCsp | OPTMustAssign | OPTAllowMayAssign | OPTModifierType ],
|
[ 'csp', OPTTokenCsp | OPTMustAssign | OPTAllowMayAssign | OPTModifierType ],
|
||||||
[ 'css', OPTTokenCss | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'css', OPTTokenCss | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'stylesheet', OPTTokenCss | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
/* synonym */ [ 'stylesheet', OPTTokenCss | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'denyallow', OPTTokenDenyAllow | OPTMustAssign | OPTDomainList | OPTNeedDomainOpt | OPTNonCspableType ],
|
[ 'denyallow', OPTTokenDenyAllow | OPTMustAssign | OPTDomainList | OPTNeedDomainOpt | OPTNonCspableType ],
|
||||||
[ 'doc', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
[ 'doc', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
||||||
[ 'document', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
/* synonym */ [ 'document', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
||||||
[ 'domain', OPTTokenDomain | OPTMustAssign | OPTDomainList ],
|
[ 'domain', OPTTokenDomain | OPTMustAssign | OPTDomainList ],
|
||||||
[ 'ehide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'ehide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'elemhide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
/* synonym */ [ 'elemhide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'empty', OPTTokenEmpty | OPTBlockOnly | OPTModifierType ],
|
[ 'empty', OPTTokenEmpty | OPTBlockOnly | OPTModifierType ],
|
||||||
[ 'frame', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
[ 'frame', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
||||||
[ 'subdocument', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
/* synonym */ [ 'subdocument', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
||||||
[ 'font', OPTTokenFont | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType ],
|
[ 'font', OPTTokenFont | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType ],
|
||||||
[ 'genericblock', OPTTokenGenericblock | OPTNotSupported ],
|
[ 'genericblock', OPTTokenGenericblock | OPTNotSupported ],
|
||||||
[ 'ghide', OPTTokenGhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'ghide', OPTTokenGhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'generichide', OPTTokenGhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
/* synonym */ [ 'generichide', OPTTokenGhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'header', OPTTokenHeader | OPTMustAssign | OPTAllowMayAssign | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'header', OPTTokenHeader | OPTMustAssign | OPTAllowMayAssign | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'image', OPTTokenImage | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'image', OPTTokenImage | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'important', OPTTokenImportant | OPTBlockOnly ],
|
[ 'important', OPTTokenImportant | OPTBlockOnly ],
|
||||||
|
@ -2217,22 +2217,22 @@ const netOptionTokenDescriptors = new Map([
|
||||||
[ 'mp4', OPTTokenMp4 | OPTNetworkType | OPTBlockOnly | OPTModifierType ],
|
[ 'mp4', OPTTokenMp4 | OPTNetworkType | OPTBlockOnly | OPTModifierType ],
|
||||||
[ '_', OPTTokenNoop ],
|
[ '_', OPTTokenNoop ],
|
||||||
[ 'object', OPTTokenObject | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'object', OPTTokenObject | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'object-subrequest', OPTTokenObject | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
/* synonym */ [ 'object-subrequest', OPTTokenObject | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'other', OPTTokenOther | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'other', OPTTokenOther | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'ping', OPTTokenPing | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'ping', OPTTokenPing | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'beacon', OPTTokenPing | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType | OPTNonRedirectableType ],
|
/* synonym */ [ 'beacon', OPTTokenPing | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'popunder', OPTTokenPopunder | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'popunder', OPTTokenPopunder | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'popup', OPTTokenPopup | OPTNonNetworkType | OPTCanNegate | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'popup', OPTTokenPopup | OPTNonNetworkType | OPTCanNegate | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'queryprune', OPTTokenQueryprune | OPTMayAssign | OPTModifierType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'queryprune', OPTTokenQueryprune | OPTMayAssign | OPTModifierType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'removeparam', OPTTokenQueryprune | OPTMayAssign | OPTModifierType | OPTNonCspableType | OPTNonRedirectableType ],
|
/* synonym */ [ 'removeparam', OPTTokenQueryprune | OPTMayAssign | OPTModifierType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'redirect', OPTTokenRedirect | OPTMustAssign | OPTAllowMayAssign | OPTModifierType ],
|
[ 'redirect', OPTTokenRedirect | OPTMustAssign | OPTAllowMayAssign | OPTModifierType ],
|
||||||
[ 'rewrite', OPTTokenRedirect | OPTMustAssign | OPTAllowMayAssign | OPTModifierType ],
|
/* synonym */ [ 'rewrite', OPTTokenRedirect | OPTMustAssign | OPTAllowMayAssign | OPTModifierType ],
|
||||||
[ 'redirect-rule', OPTTokenRedirectRule | OPTMustAssign | OPTAllowMayAssign | OPTModifierType | OPTNonCspableType ],
|
[ 'redirect-rule', OPTTokenRedirectRule | OPTMustAssign | OPTAllowMayAssign | OPTModifierType | OPTNonCspableType ],
|
||||||
[ 'script', OPTTokenScript | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'script', OPTTokenScript | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'shide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'shide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'specifichide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
/* synonym */ [ 'specifichide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'xhr', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'xhr', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'xmlhttprequest', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
/* synonym */ [ 'xmlhttprequest', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'webrtc', OPTTokenWebrtc | OPTNotSupported ],
|
[ 'webrtc', OPTTokenWebrtc | OPTNotSupported ],
|
||||||
[ 'websocket', OPTTokenWebsocket | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'websocket', OPTTokenWebsocket | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
]);
|
]);
|
||||||
|
@ -2242,30 +2242,30 @@ Parser.prototype.netOptionTokenDescriptors =
|
||||||
|
|
||||||
Parser.netOptionTokenIds = new Map([
|
Parser.netOptionTokenIds = new Map([
|
||||||
[ '1p', OPTToken1p ],
|
[ '1p', OPTToken1p ],
|
||||||
[ 'first-party', OPTToken1p ],
|
/* synonym */ [ 'first-party', OPTToken1p ],
|
||||||
[ 'strict1p', OPTToken1pStrict ],
|
[ 'strict1p', OPTToken1pStrict ],
|
||||||
[ '3p', OPTToken3p ],
|
[ '3p', OPTToken3p ],
|
||||||
[ 'third-party', OPTToken3p ],
|
/* synonym */ [ 'third-party', OPTToken3p ],
|
||||||
[ 'strict3p', OPTToken3pStrict ],
|
[ 'strict3p', OPTToken3pStrict ],
|
||||||
[ 'all', OPTTokenAll ],
|
[ 'all', OPTTokenAll ],
|
||||||
[ 'badfilter', OPTTokenBadfilter ],
|
[ 'badfilter', OPTTokenBadfilter ],
|
||||||
[ 'cname', OPTTokenCname ],
|
[ 'cname', OPTTokenCname ],
|
||||||
[ 'csp', OPTTokenCsp ],
|
[ 'csp', OPTTokenCsp ],
|
||||||
[ 'css', OPTTokenCss ],
|
[ 'css', OPTTokenCss ],
|
||||||
[ 'stylesheet', OPTTokenCss ],
|
/* synonym */ [ 'stylesheet', OPTTokenCss ],
|
||||||
[ 'denyallow', OPTTokenDenyAllow ],
|
[ 'denyallow', OPTTokenDenyAllow ],
|
||||||
[ 'doc', OPTTokenDoc ],
|
[ 'doc', OPTTokenDoc ],
|
||||||
[ 'document', OPTTokenDoc ],
|
/* synonym */ [ 'document', OPTTokenDoc ],
|
||||||
[ 'domain', OPTTokenDomain ],
|
[ 'domain', OPTTokenDomain ],
|
||||||
[ 'ehide', OPTTokenEhide ],
|
[ 'ehide', OPTTokenEhide ],
|
||||||
[ 'elemhide', OPTTokenEhide ],
|
/* synonym */ [ 'elemhide', OPTTokenEhide ],
|
||||||
[ 'empty', OPTTokenEmpty ],
|
[ 'empty', OPTTokenEmpty ],
|
||||||
[ 'frame', OPTTokenFrame ],
|
[ 'frame', OPTTokenFrame ],
|
||||||
[ 'subdocument', OPTTokenFrame ],
|
/* synonym */ [ 'subdocument', OPTTokenFrame ],
|
||||||
[ 'font', OPTTokenFont ],
|
[ 'font', OPTTokenFont ],
|
||||||
[ 'genericblock', OPTTokenGenericblock ],
|
[ 'genericblock', OPTTokenGenericblock ],
|
||||||
[ 'ghide', OPTTokenGhide ],
|
[ 'ghide', OPTTokenGhide ],
|
||||||
[ 'generichide', OPTTokenGhide ],
|
/* synonym */ [ 'generichide', OPTTokenGhide ],
|
||||||
[ 'header', OPTTokenHeader ],
|
[ 'header', OPTTokenHeader ],
|
||||||
[ 'image', OPTTokenImage ],
|
[ 'image', OPTTokenImage ],
|
||||||
[ 'important', OPTTokenImportant ],
|
[ 'important', OPTTokenImportant ],
|
||||||
|
@ -2276,22 +2276,22 @@ Parser.netOptionTokenIds = new Map([
|
||||||
[ 'mp4', OPTTokenMp4 ],
|
[ 'mp4', OPTTokenMp4 ],
|
||||||
[ '_', OPTTokenNoop ],
|
[ '_', OPTTokenNoop ],
|
||||||
[ 'object', OPTTokenObject ],
|
[ 'object', OPTTokenObject ],
|
||||||
[ 'object-subrequest', OPTTokenObject ],
|
/* synonym */ [ 'object-subrequest', OPTTokenObject ],
|
||||||
[ 'other', OPTTokenOther ],
|
[ 'other', OPTTokenOther ],
|
||||||
[ 'ping', OPTTokenPing ],
|
[ 'ping', OPTTokenPing ],
|
||||||
[ 'beacon', OPTTokenPing ],
|
/* synonym */ [ 'beacon', OPTTokenPing ],
|
||||||
[ 'popunder', OPTTokenPopunder ],
|
[ 'popunder', OPTTokenPopunder ],
|
||||||
[ 'popup', OPTTokenPopup ],
|
[ 'popup', OPTTokenPopup ],
|
||||||
[ 'queryprune', OPTTokenQueryprune ],
|
[ 'queryprune', OPTTokenQueryprune ],
|
||||||
[ 'removeparam', OPTTokenQueryprune ],
|
/* synonym */ [ 'removeparam', OPTTokenQueryprune ],
|
||||||
[ 'redirect', OPTTokenRedirect ],
|
[ 'redirect', OPTTokenRedirect ],
|
||||||
[ 'rewrite', OPTTokenRedirect ],
|
/* synonym */ [ 'rewrite', OPTTokenRedirect ],
|
||||||
[ 'redirect-rule', OPTTokenRedirectRule ],
|
[ 'redirect-rule', OPTTokenRedirectRule ],
|
||||||
[ 'script', OPTTokenScript ],
|
[ 'script', OPTTokenScript ],
|
||||||
[ 'shide', OPTTokenShide ],
|
[ 'shide', OPTTokenShide ],
|
||||||
[ 'specifichide', OPTTokenShide ],
|
/* synonym */ [ 'specifichide', OPTTokenShide ],
|
||||||
[ 'xhr', OPTTokenXhr ],
|
[ 'xhr', OPTTokenXhr ],
|
||||||
[ 'xmlhttprequest', OPTTokenXhr ],
|
/* synonym */ [ 'xmlhttprequest', OPTTokenXhr ],
|
||||||
[ 'webrtc', OPTTokenWebrtc ],
|
[ 'webrtc', OPTTokenWebrtc ],
|
||||||
[ 'websocket', OPTTokenWebsocket ],
|
[ 'websocket', OPTTokenWebsocket ],
|
||||||
]);
|
]);
|
||||||
|
@ -2806,81 +2806,81 @@ Parser.regexUtils = Parser.prototype.regexUtils = (( ) => {
|
||||||
|
|
||||||
const toTokenizableStr = node => {
|
const toTokenizableStr = node => {
|
||||||
switch ( node.type ) {
|
switch ( node.type ) {
|
||||||
case 1: /* T_SEQUENCE, 'Sequence' */ {
|
case 1: /* T_SEQUENCE, 'Sequence' */ {
|
||||||
let s = '';
|
let s = '';
|
||||||
for ( let i = 0; i < node.val.length; i++ ) {
|
for ( let i = 0; i < node.val.length; i++ ) {
|
||||||
s += toTokenizableStr(node.val[i]);
|
s += toTokenizableStr(node.val[i]);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
case 2: /* T_ALTERNATION, 'Alternation' */
|
||||||
|
case 8: /* T_CHARGROUP, 'CharacterGroup' */ {
|
||||||
|
let firstChar = 0;
|
||||||
|
let lastChar = 0;
|
||||||
|
for ( let i = 0; i < node.val.length; i++ ) {
|
||||||
|
const s = toTokenizableStr(node.val[i]);
|
||||||
|
if ( firstChar === 0 && firstCharCodeClass(s) === 1 ) {
|
||||||
|
firstChar = 1;
|
||||||
}
|
}
|
||||||
return s;
|
if ( lastChar === 0 && lastCharCodeClass(s) === 1 ) {
|
||||||
}
|
lastChar = 1;
|
||||||
case 2: /* T_ALTERNATION, 'Alternation' */
|
|
||||||
case 8: /* T_CHARGROUP, 'CharacterGroup' */ {
|
|
||||||
let firstChar = 0;
|
|
||||||
let lastChar = 0;
|
|
||||||
for ( let i = 0; i < node.val.length; i++ ) {
|
|
||||||
const s = toTokenizableStr(node.val[i]);
|
|
||||||
if ( firstChar === 0 && firstCharCodeClass(s) === 1 ) {
|
|
||||||
firstChar = 1;
|
|
||||||
}
|
|
||||||
if ( lastChar === 0 && lastCharCodeClass(s) === 1 ) {
|
|
||||||
lastChar = 1;
|
|
||||||
}
|
|
||||||
if ( firstChar === 1 && lastChar === 1 ) { break; }
|
|
||||||
}
|
}
|
||||||
return String.fromCharCode(firstChar, lastChar);
|
if ( firstChar === 1 && lastChar === 1 ) { break; }
|
||||||
}
|
}
|
||||||
case 4: /* T_GROUP, 'Group' */ {
|
return String.fromCharCode(firstChar, lastChar);
|
||||||
if ( node.flags.NegativeLookAhead === 1 ) { return '\x01'; }
|
}
|
||||||
if ( node.flags.NegativeLookBehind === 1 ) { return '\x01'; }
|
case 4: /* T_GROUP, 'Group' */ {
|
||||||
return toTokenizableStr(node.val);
|
if ( node.flags.NegativeLookAhead === 1 ) { return '\x01'; }
|
||||||
}
|
if ( node.flags.NegativeLookBehind === 1 ) { return '\x01'; }
|
||||||
case 16: /* T_QUANTIFIER, 'Quantifier' */ {
|
return toTokenizableStr(node.val);
|
||||||
const s = toTokenizableStr(node.val);
|
}
|
||||||
const first = firstCharCodeClass(s);
|
case 16: /* T_QUANTIFIER, 'Quantifier' */ {
|
||||||
const last = lastCharCodeClass(s);
|
const s = toTokenizableStr(node.val);
|
||||||
if ( node.flags.min === 0 && first === 0 && last === 0 ) {
|
const first = firstCharCodeClass(s);
|
||||||
return '';
|
const last = lastCharCodeClass(s);
|
||||||
}
|
if ( node.flags.min === 0 && first === 0 && last === 0 ) {
|
||||||
return String.fromCharCode(first, last);
|
|
||||||
}
|
|
||||||
case 64: /* T_HEXCHAR, 'HexChar' */ {
|
|
||||||
return String.fromCharCode(parseInt(node.val.slice(1), 16));
|
|
||||||
}
|
|
||||||
case 128: /* T_SPECIAL, 'Special' */ {
|
|
||||||
const flags = node.flags;
|
|
||||||
if (
|
|
||||||
flags.EndCharGroup === 1 || // dangling `]`
|
|
||||||
flags.EndGroup === 1 || // dangling `)`
|
|
||||||
flags.EndRepeats === 1 // dangling `}`
|
|
||||||
) {
|
|
||||||
throw new Error('Unmatched bracket');
|
|
||||||
}
|
|
||||||
return flags.MatchEnd === 1 ||
|
|
||||||
flags.MatchStart === 1 ||
|
|
||||||
flags.MatchWordBoundary === 1
|
|
||||||
? '\x00'
|
|
||||||
: '\x01';
|
|
||||||
}
|
|
||||||
case 256: /* T_CHARS, 'Characters' */ {
|
|
||||||
for ( let i = 0; i < node.val.length; i++ ) {
|
|
||||||
if ( firstCharCodeClass(node.val[i]) === 1 ) {
|
|
||||||
return '\x01';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '\x00';
|
|
||||||
}
|
|
||||||
// Ranges are assumed to always involve token-related characters.
|
|
||||||
case 512: /* T_CHARRANGE, 'CharacterRange' */ {
|
|
||||||
return '\x01';
|
|
||||||
}
|
|
||||||
case 1024: /* T_STRING, 'String' */ {
|
|
||||||
return node.val;
|
|
||||||
}
|
|
||||||
case 2048: /* T_COMMENT, 'Comment' */ {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
default:
|
return String.fromCharCode(first, last);
|
||||||
break;
|
}
|
||||||
|
case 64: /* T_HEXCHAR, 'HexChar' */ {
|
||||||
|
return String.fromCharCode(parseInt(node.val.slice(1), 16));
|
||||||
|
}
|
||||||
|
case 128: /* T_SPECIAL, 'Special' */ {
|
||||||
|
const flags = node.flags;
|
||||||
|
if (
|
||||||
|
flags.EndCharGroup === 1 || // dangling `]`
|
||||||
|
flags.EndGroup === 1 || // dangling `)`
|
||||||
|
flags.EndRepeats === 1 // dangling `}`
|
||||||
|
) {
|
||||||
|
throw new Error('Unmatched bracket');
|
||||||
|
}
|
||||||
|
return flags.MatchEnd === 1 ||
|
||||||
|
flags.MatchStart === 1 ||
|
||||||
|
flags.MatchWordBoundary === 1
|
||||||
|
? '\x00'
|
||||||
|
: '\x01';
|
||||||
|
}
|
||||||
|
case 256: /* T_CHARS, 'Characters' */ {
|
||||||
|
for ( let i = 0; i < node.val.length; i++ ) {
|
||||||
|
if ( firstCharCodeClass(node.val[i]) === 1 ) {
|
||||||
|
return '\x01';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '\x00';
|
||||||
|
}
|
||||||
|
// Ranges are assumed to always involve token-related characters.
|
||||||
|
case 512: /* T_CHARRANGE, 'CharacterRange' */ {
|
||||||
|
return '\x01';
|
||||||
|
}
|
||||||
|
case 1024: /* T_STRING, 'String' */ {
|
||||||
|
return node.val;
|
||||||
|
}
|
||||||
|
case 2048: /* T_COMMENT, 'Comment' */ {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return '\x01';
|
return '\x01';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue