diff --git a/js/csslint/parserlib.js b/js/csslint/parserlib.js index 3c1fdb17..47848ce5 100644 --- a/js/csslint/parserlib.js +++ b/js/csslint/parserlib.js @@ -33,8 +33,13 @@ self.parserlib = (() => { // Global keywords that can be set for any property are conveniently listed in `all` prop: // https://drafts.csswg.org/css-cascade/#all-shorthand const GlobalKeywords = ['initial', 'inherit', 'revert', 'unset']; - const isGlobalKeyword = RegExp.prototype.test.bind( - new RegExp(`^(${GlobalKeywords.join('|')})$`, 'i')); + const rxGlobalKeyword = new RegExp(`^(${GlobalKeywords.join('|')})$`, 'i'); + /** @param {string} [ex] |-separated exceptions + * @param {RegExp} [re] custom regexp check + * @param {function} [alt] alternative check */ + const customIdentChecker = (ex, re, alt) => + (re = new RegExp(`^(?!(default|${ex ? ex + '|' : ''}${GlobalKeywords.join('|')})$)${re ? re.source : ''}`, 'i')) && + (p => p.tokenType === Tokens.IDENT && re.test(p.value) || (!alt || alt(p))); // eslint-disable-line no-use-before-define const Properties = { 'accent-color': 'auto | ', @@ -56,7 +61,7 @@ self.parserlib = (() => { 'animation-duration': '