Skip to content

Commit 95bd52d

Browse files
committed
Fine tuning new linter code
1 parent cda3970 commit 95bd52d

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

src/css/codemirror.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
align-items: center;
192192
display: inline-flex;
193193
flex-grow: 0;
194-
font-size: 95%;
194+
font-size: var(--font-size-smaller);
195195
min-width: 6em;
196196
visibility: hidden;
197197
}
@@ -206,15 +206,17 @@
206206
}
207207

208208
.cm-linter-widget {
209+
align-items: center;
209210
display: none;
210211
flex-grow: 1;
211212
}
212213
.cm-linter-widget.hasErrors {
213-
display: initial;
214+
display: inline-flex;
214215
}
215216
.cm-linter-widget .cm-linter-widget-count {
216217
color: var(--accent-surface-1);
217218
fill: var(--accent-surface-1);
219+
font-size: var(--font-size-smaller);
218220
}
219221

220222
.cm-searching.cm-overlay {

src/js/codemirror/ubo-static-filtering.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,21 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {
729729
if ( astParser.isCosmeticFilter() && astParser.result.error ) {
730730
return `${error}: ${astParser.result.error}`;
731731
}
732-
if ( astParser.astError === sfp.AST_ERROR_BAD_REGEX ) {
732+
if ( astParser.astError === sfp.AST_ERROR_REGEX ) {
733733
return `${error}: Bad regular expression`;
734734
}
735-
if ( astParser.astError === sfp.AST_ERROR_BAD_PATTERN ) {
735+
if ( astParser.astError === sfp.AST_ERROR_PATTERN ) {
736736
return `${error}: Bad pattern`;
737737
}
738+
if ( astParser.astError === sfp.AST_ERROR_DOMAIN_NAME ) {
739+
return `${error}: Bad domain name`;
740+
}
741+
if ( astParser.astError === sfp.AST_ERROR_OPTION_DUPLICATE ) {
742+
return `${error}: Duplicate filter option`;
743+
}
744+
if ( astParser.astError === sfp.AST_ERROR_OPTION_UNKNOWN ) {
745+
return `${error}: Unsupported filter option`;
746+
}
738747
return error;
739748
};
740749

src/js/static-filtering-parser.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export const AST_FLAG_HAS_OPTIONS = 1 << iota++;
9292

9393
iota = 0;
9494
export const AST_ERROR_NONE = 1 << iota++;
95-
export const AST_ERROR_BAD_REGEX = 1 << iota++;
96-
export const AST_ERROR_BAD_PATTERN = 1 << iota++;
95+
export const AST_ERROR_REGEX = 1 << iota++;
96+
export const AST_ERROR_PATTERN = 1 << iota++;
97+
export const AST_ERROR_DOMAIN_NAME = 1 << iota++;
98+
export const AST_ERROR_OPTION_DUPLICATE = 1 << iota++;
99+
export const AST_ERROR_OPTION_UNKNOWN = 1 << iota++;
97100

98101
iota = 0;
99102
const NODE_RIGHT_INDEX = iota++;
@@ -1278,6 +1281,7 @@ export class AstFilterParser {
12781281
realBad = isNegated || hasValue;
12791282
break;
12801283
case NODE_TYPE_NET_OPTION_NAME_UNKNOWN:
1284+
this.astError = AST_ERROR_OPTION_UNKNOWN;
12811285
realBad = true;
12821286
break;
12831287
case NODE_TYPE_NET_OPTION_NAME_WEBRTC:
@@ -1481,7 +1485,7 @@ export class AstFilterParser {
14811485
}
14821486
} else {
14831487
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD;
1484-
this.astError = AST_ERROR_BAD_REGEX;
1488+
this.astError = AST_ERROR_REGEX;
14851489
this.addFlags(AST_FLAG_HAS_ERROR);
14861490
this.addNodeFlags(next, NODE_FLAG_ERROR);
14871491
}
@@ -1602,7 +1606,7 @@ export class AstFilterParser {
16021606
if ( normal === undefined ) {
16031607
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_BAD;
16041608
this.addFlags(AST_FLAG_HAS_ERROR);
1605-
this.astError = AST_ERROR_BAD_PATTERN;
1609+
this.astError = AST_ERROR_PATTERN;
16061610
this.addNodeFlags(next, NODE_FLAG_ERROR);
16071611
} else if ( normal === '' || pattern === '*' ) {
16081612
this.astTypeFlavor = AST_TYPE_NETWORK_PATTERN_ANY;
@@ -1813,6 +1817,7 @@ export class AstFilterParser {
18131817
if ( this.getBranchFromType(nodeOptionType) !== 0 ) {
18141818
this.addNodeFlags(parent, NODE_FLAG_ERROR);
18151819
this.addFlags(AST_FLAG_HAS_ERROR);
1820+
this.astError = AST_ERROR_OPTION_DUPLICATE;
18161821
} else {
18171822
this.addNodeToRegister(nodeOptionType, parent);
18181823
}
@@ -1956,6 +1961,7 @@ export class AstFilterParser {
19561961
} else {
19571962
this.addNodeFlags(parent, NODE_FLAG_ERROR);
19581963
this.addFlags(AST_FLAG_HAS_ERROR);
1964+
this.astError = AST_ERROR_DOMAIN_NAME;
19591965
}
19601966
}
19611967
if ( head === 0 ) {

0 commit comments

Comments
 (0)