csslint: only suppress validation errors caused by USO-vars
This commit is contained in:
parent
e4e8f04c95
commit
08c70a5192
|
@ -1,18 +0,0 @@
|
||||||
1. Until https://github.com/CSSLint/parser-lib/issues/229 is fixed, manually replace:
|
|
||||||
|
|
||||||
while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
|
|
||||||
|
|
||||||
in "_function: function()" with
|
|
||||||
|
|
||||||
while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN && lt !== Tokens.EOF) {
|
|
||||||
|
|
||||||
2. Apply our hacks unless supported natively
|
|
||||||
(use git history for the file as this warning may be obsolete):
|
|
||||||
|
|
||||||
* 449a27cc Add CSSLint position sticky rule
|
|
||||||
* d49e44dd CSS variables
|
|
||||||
* 2e86c958 fire startdocument on {
|
|
||||||
* bc63ecca support "i" in attribute selector
|
|
||||||
* 2468784e fix crashing on unclosed calc() at eof
|
|
||||||
* 3287b79f Support :any(), :-webkit-any(), :-moz-any()
|
|
||||||
* 4684016a Support @supports inside @-moz-document
|
|
|
@ -2627,9 +2627,12 @@ Parser.prototype = function() {
|
||||||
|
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
values.push(value);
|
|
||||||
}
|
}
|
||||||
|
const last = values[values.length - 1];
|
||||||
|
if (last && last.line === value.line && last.col === value.col && last.text === value.text) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
values.push(value);
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2731,6 +2734,13 @@ Parser.prototype = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value === null) {
|
||||||
|
const usoVar = this._isUsoVar();
|
||||||
|
if (usoVar) {
|
||||||
|
([line, col, value] = usoVar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*if (value === null) {
|
/*if (value === null) {
|
||||||
return null;
|
return null;
|
||||||
//throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + ".");
|
//throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + ".");
|
||||||
|
@ -3173,6 +3183,21 @@ Parser.prototype = function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
_isUsoVar() {
|
||||||
|
const tokenStream = this._tokenStream;
|
||||||
|
for (let i = tokenStream._ltIndex - 1; i >= 0; i--) {
|
||||||
|
const {type, value, startLine, startCol} = tokenStream._lt[i];
|
||||||
|
if (type === tokenStream._tokenData.S) {
|
||||||
|
// NOP
|
||||||
|
} else if (type === tokenStream._tokenData.COMMENT &&
|
||||||
|
value[2] === '[' && value[3] === '[' && value.endsWith(']]*/')) {
|
||||||
|
return [startLine, startCol, value];
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an error when an unexpected token is found.
|
* Throws an error when an unexpected token is found.
|
||||||
* @param {Object} token The token that was found.
|
* @param {Object} token The token that was found.
|
||||||
|
@ -3181,17 +3206,6 @@ Parser.prototype = function() {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_unexpectedToken: function(token) {
|
_unexpectedToken: function(token) {
|
||||||
for (let i = tokenStream._ltIndex - 1; i >= 0; i--) {
|
|
||||||
const {type, value} = tokenStream._lt[i];
|
|
||||||
if (type === tokenStream._tokenData.S) {
|
|
||||||
// NOP
|
|
||||||
} else if (type === tokenStream._tokenData.COMMENT &&
|
|
||||||
value[2] === '[' && value[3] === '[' && value.endsWith(']]*/')) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
|
throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -10979,6 +10993,8 @@ CSSLint.addFormatter({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
parserlib.css.Tokens[parserlib.css.Tokens.COMMENT].hide = false;
|
||||||
|
|
||||||
self.onmessage = ({data: {action = 'run', code, config}}) => {
|
self.onmessage = ({data: {action = 'run', code, config}}) => {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
||||||
|
@ -10997,7 +11013,7 @@ self.onmessage = ({data: {action = 'run', code, config}}) => {
|
||||||
// the functions are non-tranferable and we need only an id
|
// the functions are non-tranferable and we need only an id
|
||||||
m.rule = {id: m.rule.id};
|
m.rule = {id: m.rule.id};
|
||||||
return m;
|
return m;
|
||||||
}));
|
}).filter(m => !m.message.includes('/*[[') && !m.message.includes(']]*/')));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'parse':
|
case 'parse':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user