1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 16:47:15 +02:00

Fine tuning new linter code

This commit is contained in:
Raymond Hill 2023-04-02 10:40:44 -04:00
parent cda39709b1
commit 95bd52d01f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 25 additions and 8 deletions

View File

@ -191,7 +191,7 @@
align-items: center; align-items: center;
display: inline-flex; display: inline-flex;
flex-grow: 0; flex-grow: 0;
font-size: 95%; font-size: var(--font-size-smaller);
min-width: 6em; min-width: 6em;
visibility: hidden; visibility: hidden;
} }
@ -206,15 +206,17 @@
} }
.cm-linter-widget { .cm-linter-widget {
align-items: center;
display: none; display: none;
flex-grow: 1; flex-grow: 1;
} }
.cm-linter-widget.hasErrors { .cm-linter-widget.hasErrors {
display: initial; display: inline-flex;
} }
.cm-linter-widget .cm-linter-widget-count { .cm-linter-widget .cm-linter-widget-count {
color: var(--accent-surface-1); color: var(--accent-surface-1);
fill: var(--accent-surface-1); fill: var(--accent-surface-1);
font-size: var(--font-size-smaller);
} }
.cm-searching.cm-overlay { .cm-searching.cm-overlay {

View File

@ -729,12 +729,21 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {
if ( astParser.isCosmeticFilter() && astParser.result.error ) { if ( astParser.isCosmeticFilter() && astParser.result.error ) {
return `${error}: ${astParser.result.error}`; return `${error}: ${astParser.result.error}`;
} }
if ( astParser.astError === sfp.AST_ERROR_BAD_REGEX ) { if ( astParser.astError === sfp.AST_ERROR_REGEX ) {
return `${error}: Bad regular expression`; return `${error}: Bad regular expression`;
} }
if ( astParser.astError === sfp.AST_ERROR_BAD_PATTERN ) { if ( astParser.astError === sfp.AST_ERROR_PATTERN ) {
return `${error}: Bad pattern`; return `${error}: Bad pattern`;
} }
if ( astParser.astError === sfp.AST_ERROR_DOMAIN_NAME ) {
return `${error}: Bad domain name`;
}
if ( astParser.astError === sfp.AST_ERROR_OPTION_DUPLICATE ) {
return `${error}: Duplicate filter option`;
}
if ( astParser.astError === sfp.AST_ERROR_OPTION_UNKNOWN ) {
return `${error}: Unsupported filter option`;
}
return error; return error;
}; };

View File

@ -92,8 +92,11 @@ export const AST_FLAG_HAS_OPTIONS = 1 << iota++;
iota = 0; iota = 0;
export const AST_ERROR_NONE = 1 << iota++; export const AST_ERROR_NONE = 1 << iota++;
export const AST_ERROR_BAD_REGEX = 1 << iota++; export const AST_ERROR_REGEX = 1 << iota++;
export const AST_ERROR_BAD_PATTERN = 1 << iota++; export const AST_ERROR_PATTERN = 1 << iota++;
export const AST_ERROR_DOMAIN_NAME = 1 << iota++;
export const AST_ERROR_OPTION_DUPLICATE = 1 << iota++;
export const AST_ERROR_OPTION_UNKNOWN = 1 << iota++;
iota = 0; iota = 0;
const NODE_RIGHT_INDEX = iota++; const NODE_RIGHT_INDEX = iota++;
@ -1278,6 +1281,7 @@ export class AstFilterParser {
realBad = isNegated || hasValue; realBad = isNegated || hasValue;
break; break;
case NODE_TYPE_NET_OPTION_NAME_UNKNOWN: case NODE_TYPE_NET_OPTION_NAME_UNKNOWN:
this.astError = AST_ERROR_OPTION_UNKNOWN;
realBad = true; realBad = true;
break; break;
case NODE_TYPE_NET_OPTION_NAME_WEBRTC: case NODE_TYPE_NET_OPTION_NAME_WEBRTC:
@ -1481,7 +1485,7 @@ export class AstFilterParser {
} }
} else { } else {
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD; this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD;
this.astError = AST_ERROR_BAD_REGEX; this.astError = AST_ERROR_REGEX;
this.addFlags(AST_FLAG_HAS_ERROR); this.addFlags(AST_FLAG_HAS_ERROR);
this.addNodeFlags(next, NODE_FLAG_ERROR); this.addNodeFlags(next, NODE_FLAG_ERROR);
} }
@ -1602,7 +1606,7 @@ export class AstFilterParser {
if ( normal === undefined ) { if ( normal === undefined ) {
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD; this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD;
this.addFlags(AST_FLAG_HAS_ERROR); this.addFlags(AST_FLAG_HAS_ERROR);
this.astError = AST_ERROR_BAD_PATTERN; this.astError = AST_ERROR_PATTERN;
this.addNodeFlags(next, NODE_FLAG_ERROR); this.addNodeFlags(next, NODE_FLAG_ERROR);
} else if ( normal === '' || pattern === '*' ) { } else if ( normal === '' || pattern === '*' ) {
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_ANY; this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_ANY;
@ -1813,6 +1817,7 @@ export class AstFilterParser {
if ( this.getBranchFromType(nodeOptionType) !== 0 ) { if ( this.getBranchFromType(nodeOptionType) !== 0 ) {
this.addNodeFlags(parent, NODE_FLAG_ERROR); this.addNodeFlags(parent, NODE_FLAG_ERROR);
this.addFlags(AST_FLAG_HAS_ERROR); this.addFlags(AST_FLAG_HAS_ERROR);
this.astError = AST_ERROR_OPTION_DUPLICATE;
} else { } else {
this.addNodeToRegister(nodeOptionType, parent); this.addNodeToRegister(nodeOptionType, parent);
} }
@ -1956,6 +1961,7 @@ export class AstFilterParser {
} else { } else {
this.addNodeFlags(parent, NODE_FLAG_ERROR); this.addNodeFlags(parent, NODE_FLAG_ERROR);
this.addFlags(AST_FLAG_HAS_ERROR); this.addFlags(AST_FLAG_HAS_ERROR);
this.astError = AST_ERROR_DOMAIN_NAME;
} }
} }
if ( head === 0 ) { if ( head === 0 ) {