From 08c70a519285d3f2a22d87098616e1312d278e52 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 7 Dec 2017 08:09:22 +0300 Subject: [PATCH] csslint: only suppress validation errors caused by USO-vars --- vendor-overwrites/csslint/WARNING.txt | 18 --------- vendor-overwrites/csslint/csslint-worker.js | 44 ++++++++++++++------- 2 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 vendor-overwrites/csslint/WARNING.txt diff --git a/vendor-overwrites/csslint/WARNING.txt b/vendor-overwrites/csslint/WARNING.txt deleted file mode 100644 index 22cfbf96..00000000 --- a/vendor-overwrites/csslint/WARNING.txt +++ /dev/null @@ -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 diff --git a/vendor-overwrites/csslint/csslint-worker.js b/vendor-overwrites/csslint/csslint-worker.js index ec6cef5b..d73479f0 100644 --- a/vendor-overwrites/csslint/csslint-worker.js +++ b/vendor-overwrites/csslint/csslint-worker.js @@ -2627,9 +2627,12 @@ Parser.prototype = function() { if (value === null) { 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); } @@ -2731,6 +2734,13 @@ Parser.prototype = function() { } } + if (value === null) { + const usoVar = this._isUsoVar(); + if (usoVar) { + ([line, col, value] = usoVar); + } + } + /*if (value === null) { return null; //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. * @param {Object} token The token that was found. @@ -3181,17 +3206,6 @@ Parser.prototype = function() { * @private */ _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); }, @@ -10979,6 +10993,8 @@ CSSLint.addFormatter({ } }); +parserlib.css.Tokens[parserlib.css.Tokens.COMMENT].hide = false; + self.onmessage = ({data: {action = 'run', code, config}}) => { switch (action) { @@ -10997,7 +11013,7 @@ self.onmessage = ({data: {action = 'run', code, config}}) => { // the functions are non-tranferable and we need only an id m.rule = {id: m.rule.id}; return m; - })); + }).filter(m => !m.message.includes('/*[[') && !m.message.includes(']]*/'))); return; case 'parse':