mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-25 20:02:51 +01:00
Rewrite logical expressions for ESLint (#3801)
This commit is contained in:
parent
3ca5e6817d
commit
6ef74fc21b
@ -19,8 +19,7 @@
|
|||||||
"ObjectExpression": "off",
|
"ObjectExpression": "off",
|
||||||
"ignoreComments": true,
|
"ignoreComments": true,
|
||||||
"ignoredNodes": [
|
"ignoredNodes": [
|
||||||
"AssignmentExpression:has(Literal)",
|
"AssignmentExpression:has(Literal)"
|
||||||
"LogicalExpression"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -2437,22 +2437,7 @@ const NetOptionsIterator = class {
|
|||||||
descriptor = netOptionTokenDescriptors.get(token);
|
descriptor = netOptionTokenDescriptors.get(token);
|
||||||
}
|
}
|
||||||
// Validate option according to context
|
// Validate option according to context
|
||||||
if (
|
if ( !this.optionIsValidInContext(descriptor, ltok !== lopt, assigned) ) {
|
||||||
descriptor === undefined ||
|
|
||||||
ltok !== lopt &&
|
|
||||||
hasNoBits(descriptor, OPTCanNegate) ||
|
|
||||||
this.exception &&
|
|
||||||
hasBits(descriptor, OPTBlockOnly) ||
|
|
||||||
this.exception === false &&
|
|
||||||
hasBits(descriptor, OPTAllowOnly) ||
|
|
||||||
assigned &&
|
|
||||||
hasNoBits(descriptor, OPTMayAssign | OPTMustAssign) ||
|
|
||||||
assigned === false &&
|
|
||||||
hasBits(descriptor, OPTMustAssign) && (
|
|
||||||
this.exception === false ||
|
|
||||||
hasNoBits(descriptor, OPTAllowMayAssign)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
descriptor = OPTTokenInvalid;
|
descriptor = OPTTokenInvalid;
|
||||||
}
|
}
|
||||||
// Keep track of which options are present: any given option can
|
// Keep track of which options are present: any given option can
|
||||||
@ -2665,6 +2650,30 @@ const NetOptionsIterator = class {
|
|||||||
this.readPtr = i + 6;
|
this.readPtr = i + 6;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
optionIsValidInContext(descriptor, negated, assigned) {
|
||||||
|
if ( descriptor === undefined ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( negated && hasNoBits(descriptor, OPTCanNegate) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( this.exception && hasBits(descriptor, OPTBlockOnly) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( this.exception === false && hasBits(descriptor, OPTAllowOnly) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( assigned && hasNoBits(descriptor, OPTMayAssign | OPTMustAssign) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ( assigned === false && hasBits(descriptor, OPTMustAssign) ) {
|
||||||
|
if ( this.exception === false || hasNoBits(descriptor, OPTAllowMayAssign) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -3268,14 +3268,13 @@ const FilterParser = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isJustOrigin() {
|
isJustOrigin() {
|
||||||
return this.optionUnitBits === this.DOMAIN_BIT &&
|
if ( this.optionUnitBits !== this.DOMAIN_BIT ) { return false; }
|
||||||
this.isRegex === false && (
|
if ( this.isRegex ) { return false; }
|
||||||
this.pattern === '*' || (
|
if ( this.domainOpt.includes('~') ) { return false; }
|
||||||
this.anchor === 0b010 &&
|
if ( this.pattern === '*' ) { return true; }
|
||||||
/^(?:http[s*]?:(?:\/\/)?)$/.test(this.pattern)
|
if ( this.anchor !== 0b010 ) { return false; }
|
||||||
)
|
if ( /^(?:http[s*]?:(?:\/\/)?)$/.test(this.pattern) ) { return true; }
|
||||||
) &&
|
return false;
|
||||||
this.domainOpt.indexOf('~') === -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
domainIsEntity(s) {
|
domainIsEntity(s) {
|
||||||
|
Loading…
Reference in New Issue
Block a user