diff --git a/lib/__tests__/syntaxes.test.js b/lib/__tests__/syntaxes.test.js index 9e8288201a..396df78ddb 100644 --- a/lib/__tests__/syntaxes.test.js +++ b/lib/__tests__/syntaxes.test.js @@ -1,6 +1,6 @@ 'use strict'; -const syntaxes = require('../syntaxes/index'); +const syntaxes = require('../syntaxes'); const inputs = Object.keys(syntaxes).map((name) => [ name, diff --git a/lib/assignDisabledRanges.js b/lib/assignDisabledRanges.js index 71f81af761..c0ab00a5e1 100644 --- a/lib/assignDisabledRanges.js +++ b/lib/assignDisabledRanges.js @@ -116,6 +116,7 @@ module.exports = function (root, result) { current = next; lastLine = currentLine; } + checkComment(fullComment); }); diff --git a/lib/getPostcssResult.js b/lib/getPostcssResult.js index a38476b8b0..24524aac64 100644 --- a/lib/getPostcssResult.js +++ b/lib/getPostcssResult.js @@ -120,7 +120,7 @@ function getCustomSyntax(customSyntax) { if (typeof customSyntax === 'string') { try { resolved = require(customSyntax); - } catch (error) { + } catch { throw new Error( `Cannot resolve custom syntax module ${customSyntax}. Check that module ${customSyntax} is available and spelled correctly.`, ); @@ -144,7 +144,7 @@ function getCustomSyntax(customSyntax) { if (typeof customSyntax.parse === 'function') { resolved = { ...customSyntax }; } else { - throw new Error( + throw new TypeError( `An object provided to the "customSyntax" option must have a "parse" property. Ensure the "parse" property exists and its value is a function.`, ); } diff --git a/lib/lintSource.js b/lib/lintSource.js index f5bc8f3df4..ce2bd8705d 100644 --- a/lib/lintSource.js +++ b/lib/lintSource.js @@ -42,17 +42,12 @@ module.exports = function lintSource(stylelint, options = {}) { return getIsIgnored.then((isIgnored) => { if (isIgnored) { /** @type {PostcssResult} */ - let postcssResult; - if (options.existingPostcssResult) { - postcssResult = Object.assign(options.existingPostcssResult, { - stylelint: createEmptyStylelintPostcssResult(), - }); - } else { - postcssResult = createEmptyPostcssResult(inputFilePath); - } - - return postcssResult; + return options.existingPostcssResult + ? Object.assign(options.existingPostcssResult, { + stylelint: createEmptyStylelintPostcssResult(), + }) + : createEmptyPostcssResult(inputFilePath); } const configSearchPath = stylelint._options.configFile || inputFilePath; diff --git a/lib/reference/keywordSets.js b/lib/reference/keywordSets.js index 52f4a718d5..25ce2e8274 100644 --- a/lib/reference/keywordSets.js +++ b/lib/reference/keywordSets.js @@ -670,8 +670,8 @@ keywordSets.nonStandardHtmlTags = new Set([ */ function uniteSets(...args) { return new Set( - Array.from(args).reduce((/** @type {string[]} */ result, set) => { - return result.concat(Array.from(set)); + [...args].reduce((/** @type {string[]} */ result, set) => { + return result.concat([...set]); }, []), ); } diff --git a/lib/rules/alpha-value-notation/index.js b/lib/rules/alpha-value-notation/index.js index 426422a56e..7112654525 100644 --- a/lib/rules/alpha-value-notation/index.js +++ b/lib/rules/alpha-value-notation/index.js @@ -18,8 +18,8 @@ const messages = ruleMessages(ruleName, { expected: (unfixed, fixed) => `Expected "${unfixed}" to be "${fixed}"`, }); -const ALPHA_PROPS = ['opacity', 'shape-image-threshold']; -const ALPHA_FUNCS = ['hsl', 'hsla', 'hwb', 'lab', 'lch', 'rgb', 'rgba']; +const ALPHA_PROPS = new Set(['opacity', 'shape-image-threshold']); +const ALPHA_FUNCS = new Set(['hsl', 'hsla', 'hwb', 'lab', 'lch', 'rgb', 'rgba']); function rule(primary, options, context) { return (root, result) => { @@ -48,12 +48,12 @@ function rule(primary, options, context) { parsedValue.walk((node) => { let alpha; - if (ALPHA_PROPS.includes(decl.prop.toLowerCase())) { + if (ALPHA_PROPS.has(decl.prop.toLowerCase())) { alpha = findAlphaInValue(node); } else { if (node.type !== 'function') return; - if (!ALPHA_FUNCS.includes(node.value.toLowerCase())) return; + if (!ALPHA_FUNCS.has(node.value.toLowerCase())) return; alpha = findAlphaInFunction(node); } diff --git a/lib/rules/block-opening-brace-newline-after/index.js b/lib/rules/block-opening-brace-newline-after/index.js index 80a5bee78f..c53e4ef927 100644 --- a/lib/rules/block-opening-brace-newline-after/index.js +++ b/lib/rules/block-opening-brace-newline-after/index.js @@ -115,6 +115,7 @@ function rule(expectation, options, context) { fixTarget = fixTarget.next(); } + nodeToCheck.raws.before = ''; return; diff --git a/lib/rules/color-function-notation/index.js b/lib/rules/color-function-notation/index.js index c8910a10b3..f6b881104c 100644 --- a/lib/rules/color-function-notation/index.js +++ b/lib/rules/color-function-notation/index.js @@ -15,8 +15,8 @@ const messages = ruleMessages(ruleName, { expected: (primary) => `Expected ${primary} color-function notation`, }); -const LEGACY_FUNCS = ['rgba', 'hsla']; -const LEGACY_NOTATION_FUNCS = ['rgb', 'rgba', 'hsl', 'hsla']; +const LEGACY_FUNCS = new Set(['rgba', 'hsla']); +const LEGACY_NOTATION_FUNCS = new Set(['rgb', 'rgba', 'hsl', 'hsla']); function rule(primary, secondary, context) { return (root, result) => { @@ -36,7 +36,7 @@ function rule(primary, secondary, context) { if (type !== 'function') return; - if (!LEGACY_NOTATION_FUNCS.includes(value.toLowerCase())) return; + if (!LEGACY_NOTATION_FUNCS.has(value.toLowerCase())) return; if (primary === 'modern' && !hasCommas(node)) return; @@ -64,7 +64,7 @@ function rule(primary, secondary, context) { }); // Remove trailing 'a' from legacy function name - if (LEGACY_FUNCS.includes(node.value.toLowerCase())) { + if (LEGACY_FUNCS.has(node.value.toLowerCase())) { node.value = node.value.slice(0, -1); } diff --git a/lib/rules/color-named/generateColorFuncs.js b/lib/rules/color-named/generateColorFuncs.js index 51a3501820..ae8ae0e7d0 100644 --- a/lib/rules/color-named/generateColorFuncs.js +++ b/lib/rules/color-named/generateColorFuncs.js @@ -13,7 +13,7 @@ function lin_sRGB(RGB) { return val / 12.92; } - return Math.pow((val + 0.055) / 1.055, 2.4); + return ((val + 0.055) / 1.055) ** 2.4; }); } @@ -102,11 +102,7 @@ function rgb2hsl(r, g, b) { l = (M + m) / 2; - if (d === 0) { - s = 0; - } else { - s = d / (1 - Math.abs(2 * l - 1)); - } + s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1)); s *= 100; l *= 100; @@ -152,7 +148,7 @@ function generateColorFuncs(hexString) { const rgb = [0, 0, 0]; for (let i = 0; i < 3; i += 1) { - rgb[i] = parseInt(hexString.substr(2 * i + 1, 2), 16); + rgb[i] = Number.parseInt(hexString.substr(2 * i + 1, 2), 16); } const hsl = rgb2hsl(rgb[0], rgb[1], rgb[2]); diff --git a/lib/rules/color-named/index.js b/lib/rules/color-named/index.js index 1a850714c7..2cc49f7dfd 100644 --- a/lib/rules/color-named/index.js +++ b/lib/rules/color-named/index.js @@ -25,7 +25,7 @@ const messages = ruleMessages(ruleName, { }); // Todo tested on case insensivity -const NODE_TYPES = ['word', 'function']; +const NODE_TYPES = new Set(['word', 'function']); function rule(expectation, options) { return (root, result) => { @@ -90,7 +90,7 @@ function rule(expectation, options) { } // Return early if neither a word nor a function - if (!NODE_TYPES.includes(type)) { + if (!NODE_TYPES.has(type)) { return; } diff --git a/lib/rules/font-weight-notation/index.js b/lib/rules/font-weight-notation/index.js index de257cd780..09db3b1c27 100644 --- a/lib/rules/font-weight-notation/index.js +++ b/lib/rules/font-weight-notation/index.js @@ -23,7 +23,7 @@ const messages = ruleMessages(ruleName, { const INHERIT_KEYWORD = 'inherit'; const INITIAL_KEYWORD = 'initial'; const NORMAL_KEYWORD = 'normal'; -const WEIGHTS_WITH_KEYWORD_EQUIVALENTS = ['400', '700']; +const WEIGHTS_WITH_KEYWORD_EQUIVALENTS = new Set(['400', '700']); function rule(expectation, options) { return (root, result) => { @@ -121,7 +121,7 @@ function rule(expectation, options) { if (expectation === 'named-where-possible') { if (isNumbery(weightValue)) { - if (WEIGHTS_WITH_KEYWORD_EQUIVALENTS.includes(weightValue)) { + if (WEIGHTS_WITH_KEYWORD_EQUIVALENTS.has(weightValue)) { complain(messages.expected('named')); } diff --git a/lib/rules/function-whitespace-after/index.js b/lib/rules/function-whitespace-after/index.js index aff9b0bfbd..bff0590afa 100644 --- a/lib/rules/function-whitespace-after/index.js +++ b/lib/rules/function-whitespace-after/index.js @@ -116,6 +116,7 @@ function rule(expectation, options, context) { while (whitespaceEndIndex < value.length && isWhitespace(value[whitespaceEndIndex])) { whitespaceEndIndex++; } + fixed += value.slice(lastIndex, index); lastIndex = whitespaceEndIndex; }; diff --git a/lib/rules/hue-degree-notation/index.js b/lib/rules/hue-degree-notation/index.js index 481acee405..69c6d28f24 100644 --- a/lib/rules/hue-degree-notation/index.js +++ b/lib/rules/hue-degree-notation/index.js @@ -18,7 +18,7 @@ const messages = ruleMessages(ruleName, { const HUE_FIRST_ARG_FUNCS = ['hsl', 'hsla', 'hwb']; const HUE_THIRD_ARG_FUNCS = ['lch']; -const HUE_FUNCS = [...HUE_FIRST_ARG_FUNCS, ...HUE_THIRD_ARG_FUNCS]; +const HUE_FUNCS = new Set([...HUE_FIRST_ARG_FUNCS, ...HUE_THIRD_ARG_FUNCS]); function rule(primary, secondary, context) { return (root, result) => { @@ -36,7 +36,7 @@ function rule(primary, secondary, context) { parsedValue.walk((node) => { if (node.type !== 'function') return; - if (!HUE_FUNCS.includes(node.value.toLowerCase())) return; + if (!HUE_FUNCS.has(node.value.toLowerCase())) return; const hue = findHue(node); diff --git a/lib/rules/indentation/index.js b/lib/rules/indentation/index.js index 041637b2b8..51a41c7265 100644 --- a/lib/rules/indentation/index.js +++ b/lib/rules/indentation/index.js @@ -573,22 +573,14 @@ function inferRootIndentLevel(root, baseIndentLevel, indentSize) { if (document) { const nextRoot = document.nodes[document.nodes.indexOf(root) + 1]; - if (nextRoot) { - afterEnd = nextRoot.raws.beforeStart; - } else { - afterEnd = document.raws.afterEnd; - } + afterEnd = nextRoot ? nextRoot.raws.beforeStart : document.raws.afterEnd; } else { // Nested root node in css-in-js lang const parent = root.parent; const nextRoot = parent.nodes[parent.nodes.indexOf(root) + 1]; - if (nextRoot) { - afterEnd = nextRoot.raws.beforeStart; - } else { - afterEnd = root.raws.afterEnd; - } + afterEnd = nextRoot ? nextRoot.raws.beforeStart : root.raws.afterEnd; } } else { afterEnd = after; diff --git a/lib/rules/length-zero-no-unit/index.js b/lib/rules/length-zero-no-unit/index.js index 99b78b5c6f..77f08d3616 100644 --- a/lib/rules/length-zero-no-unit/index.js +++ b/lib/rules/length-zero-no-unit/index.js @@ -147,7 +147,7 @@ function rule(actual, secondary, context) { // Only pay attention if the value parses to 0 // and units with lengths if ( - parseFloat(valueWithZero) !== 0 || + Number.parseFloat(valueWithZero) !== 0 || !keywordSets.lengthUnits.has(parsedValue.unit.toLowerCase()) ) { return; diff --git a/lib/rules/max-empty-lines/index.js b/lib/rules/max-empty-lines/index.js index 85386641a0..e1dae75d97 100644 --- a/lib/rules/max-empty-lines/index.js +++ b/lib/rules/max-empty-lines/index.js @@ -163,29 +163,21 @@ function rule(max, options, context) { const emptyLFLines = '\n'.repeat(repeatTimes); const emptyCRLFLines = '\r\n'.repeat(repeatTimes); - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - let result; - - if (/(\r\n)+/g.test(str)) { - result = str.replace(/(\r\n)+/g, ($1) => { - if ($1.length / 2 > repeatTimes) { - return emptyCRLFLines; - } - - return $1; - }); - } else { - result = str.replace(/(\n)+/g, ($1) => { - if ($1.length > repeatTimes) { - return emptyLFLines; - } - - return $1; - }); - } - - return result; + return /(\r\n)+/g.test(str) + ? str.replace(/(\r\n)+/g, ($1) => { + if ($1.length / 2 > repeatTimes) { + return emptyCRLFLines; + } + + return $1; + }) + : str.replace(/(\n)+/g, ($1) => { + if ($1.length > repeatTimes) { + return emptyLFLines; + } + + return $1; + }); } }; } diff --git a/lib/rules/media-query-list-comma-newline-after/index.js b/lib/rules/media-query-list-comma-newline-after/index.js index 390731e733..7a1bc8a614 100644 --- a/lib/rules/media-query-list-comma-newline-after/index.js +++ b/lib/rules/media-query-list-comma-newline-after/index.js @@ -65,11 +65,9 @@ function rule(expectation, options, context) { const afterComma = params.slice(index + 1); if (expectation.startsWith('always')) { - if (/^\s*\r?\n/.test(afterComma)) { - params = beforeComma + afterComma.replace(/^[^\S\r\n]*/, ''); - } else { - params = beforeComma + context.newline + afterComma; - } + params = /^\s*\r?\n/.test(afterComma) + ? beforeComma + afterComma.replace(/^[^\S\r\n]*/, '') + : beforeComma + context.newline + afterComma; } else if (expectation.startsWith('never')) { params = beforeComma + afterComma.replace(/^\s*/, ''); } diff --git a/lib/rules/no-duplicate-selectors/index.js b/lib/rules/no-duplicate-selectors/index.js index 0611e90f9c..b6656c86c1 100644 --- a/lib/rules/no-duplicate-selectors/index.js +++ b/lib/rules/no-duplicate-selectors/index.js @@ -74,7 +74,7 @@ function rule(actual, options) { let previousDuplicatePosition; // When `disallowInList` is true, we must parse `sortedSelectorList` into // list items. - let selectorListParsed = []; + const selectorListParsed = []; if (shouldDisallowDuplicateInList) { parseSelector(sortedSelectorList, result, rule, (selectors) => { @@ -131,7 +131,7 @@ function rule(actual, options) { }); if (shouldDisallowDuplicateInList) { - for (let selector of selectorListParsed) { + for (const selector of selectorListParsed) { // [selectorLine] will not really be accurate for multi-line // selectors, such as "bar" in "foo,\nbar {}". contextSelectorSet.set(selector, selectorLine); diff --git a/lib/rules/number-max-precision/index.js b/lib/rules/number-max-precision/index.js index 09e053caa6..311d107538 100644 --- a/lib/rules/number-max-precision/index.js +++ b/lib/rules/number-max-precision/index.js @@ -89,7 +89,7 @@ function rule(precision, options) { ruleName, node, index: getIndex(node) + valueNode.sourceIndex + match.index, - message: messages.expected(parseFloat(match[0]), precision), + message: messages.expected(Number.parseFloat(match[0]), precision), }); }); } diff --git a/lib/rules/selector-attribute-brackets-space-inside/index.js b/lib/rules/selector-attribute-brackets-space-inside/index.js index 168ff5f3ec..53bf1b4064 100644 --- a/lib/rules/selector-attribute-brackets-space-inside/index.js +++ b/lib/rules/selector-attribute-brackets-space-inside/index.js @@ -151,11 +151,7 @@ function rule(expectation, options, context) { let key; if (attributeNode.operator) { - if (attributeNode.insensitive) { - key = 'insensitive'; - } else { - key = 'value'; - } + key = attributeNode.insensitive ? 'insensitive' : 'value'; } else { key = 'attribute'; } diff --git a/lib/rules/selector-max-specificity/index.js b/lib/rules/selector-max-specificity/index.js index 1fad08bbd4..a441d05f5a 100755 --- a/lib/rules/selector-max-specificity/index.js +++ b/lib/rules/selector-max-specificity/index.js @@ -176,7 +176,7 @@ function rule(max, options) { }); } }); - } catch (e) { + } catch { result.warn('Cannot parse selector', { node: rule, stylelintType: 'parseError', diff --git a/lib/rules/selector-pseudo-element-colon-notation/index.js b/lib/rules/selector-pseudo-element-colon-notation/index.js index 6b0043a922..65234b85e7 100644 --- a/lib/rules/selector-pseudo-element-colon-notation/index.js +++ b/lib/rules/selector-pseudo-element-colon-notation/index.js @@ -43,7 +43,7 @@ function rule(expectation, options, context) { const fixPositions = []; // match only level 1 and 2 pseudo elements - const pseudoElementsWithColons = Array.from(keywordSets.levelOneAndTwoPseudoElements).map( + const pseudoElementsWithColons = [...keywordSets.levelOneAndTwoPseudoElements].map( (x) => `:${x}`, ); diff --git a/lib/rules/time-min-milliseconds/index.js b/lib/rules/time-min-milliseconds/index.js index 0e36002d66..7e0fa84f53 100644 --- a/lib/rules/time-min-milliseconds/index.js +++ b/lib/rules/time-min-milliseconds/index.js @@ -19,7 +19,7 @@ const messages = ruleMessages(ruleName, { expected: (time) => `Expected a minimum of ${time} milliseconds`, }); -const DELAY_PROPERTIES = ['animation-delay', 'transition-delay']; +const DELAY_PROPERTIES = new Set(['animation-delay', 'transition-delay']); function rule(minimum, options) { return (root, result) => { @@ -98,7 +98,7 @@ function rule(minimum, options) { } function isIgnoredProperty(propertyName) { - if (optionsMatches(options, 'ignore', 'delay') && DELAY_PROPERTIES.includes(propertyName)) { + if (optionsMatches(options, 'ignore', 'delay') && DELAY_PROPERTIES.has(propertyName)) { return true; } diff --git a/lib/testUtils/mergeTestDescriptions.js b/lib/testUtils/mergeTestDescriptions.js index 4b227909c6..97a4039c23 100644 --- a/lib/testUtils/mergeTestDescriptions.js +++ b/lib/testUtils/mergeTestDescriptions.js @@ -5,7 +5,7 @@ const _ = require('lodash'); module.exports = function (...args) { const mergeWithArgs = [{}]; - Array.from(args).forEach((arg) => mergeWithArgs.push(arg)); + [...args].forEach((arg) => mergeWithArgs.push(arg)); mergeWithArgs.push(mergeCustomizer); return _.mergeWith(...mergeWithArgs); diff --git a/lib/utils/filterFilePaths.js b/lib/utils/filterFilePaths.js index 4e25f05107..2055a558b1 100644 --- a/lib/utils/filterFilePaths.js +++ b/lib/utils/filterFilePaths.js @@ -10,10 +10,10 @@ const { isPathValid } = require('ignore').default; module.exports = function filterFilePaths(ignorer, filePaths) { const validForIgnore = filePaths.filter(isPathValid); // Paths which starts with `..` are not valid for `ignore`, e. g. `../style.css` - const notValidForIgnore = filePaths.filter((p) => !validForIgnore.includes(p)); + const notValidForIgnore = new Set(filePaths.filter((p) => !validForIgnore.includes(p))); - const filteredByIgnore = ignorer.filter(validForIgnore); + const filteredByIgnore = new Set(ignorer.filter(validForIgnore)); // Preserving files order, while removing paths which were filtered by `ignore` - return filePaths.filter((p) => notValidForIgnore.includes(p) || filteredByIgnore.includes(p)); + return filePaths.filter((p) => notValidForIgnore.has(p) || filteredByIgnore.has(p)); }; diff --git a/lib/utils/getCacheFile.js b/lib/utils/getCacheFile.js index 314201390a..08d91a3696 100644 --- a/lib/utils/getCacheFile.js +++ b/lib/utils/getCacheFile.js @@ -38,7 +38,7 @@ module.exports = function getCacheFile(cacheFile, cwd) { try { fileStats = fs.lstatSync(resolvedCacheFile); - } catch (ex) { + } catch { fileStats = null; } diff --git a/lib/utils/getSchemeFromUrl.js b/lib/utils/getSchemeFromUrl.js index cc6e8b2501..d62b8da0d4 100644 --- a/lib/utils/getSchemeFromUrl.js +++ b/lib/utils/getSchemeFromUrl.js @@ -14,7 +14,7 @@ module.exports = function (urlString) { try { protocol = new URL(urlString).protocol; - } catch (err) { + } catch { return null; } diff --git a/lib/utils/isCounterIncrementCustomIdentValue.js b/lib/utils/isCounterIncrementCustomIdentValue.js index daf2a59fb5..3d670f1841 100644 --- a/lib/utils/isCounterIncrementCustomIdentValue.js +++ b/lib/utils/isCounterIncrementCustomIdentValue.js @@ -12,7 +12,7 @@ module.exports = function (value) { if ( keywordSets.counterIncrementKeywords.has(valueLowerCase) || - Number.isFinite(parseInt(valueLowerCase)) + Number.isFinite(Number.parseInt(valueLowerCase)) ) { return false; } diff --git a/lib/utils/isCounterResetCustomIdentValue.js b/lib/utils/isCounterResetCustomIdentValue.js index 65dabae2f6..9c4789707d 100644 --- a/lib/utils/isCounterResetCustomIdentValue.js +++ b/lib/utils/isCounterResetCustomIdentValue.js @@ -12,7 +12,7 @@ module.exports = function (value) { if ( keywordSets.counterResetKeywords.has(valueLowerCase) || - Number.isFinite(parseInt(valueLowerCase)) + Number.isFinite(Number.parseInt(valueLowerCase)) ) { return false; } diff --git a/lib/utils/isStandardSyntaxCombinator.js b/lib/utils/isStandardSyntaxCombinator.js index 2eba3d9677..76e1d4215c 100644 --- a/lib/utils/isStandardSyntaxCombinator.js +++ b/lib/utils/isStandardSyntaxCombinator.js @@ -19,7 +19,7 @@ module.exports = function (node) { // ignore the combinators that are the first or last node in their container if (node.parent !== undefined && node.parent !== null) { - let parent = node.parent; + const parent = node.parent; if (node === parent.first) { return false; diff --git a/lib/utils/isStandardSyntaxValue.js b/lib/utils/isStandardSyntaxValue.js index 5f8b430301..b2bb651a24 100644 --- a/lib/utils/isStandardSyntaxValue.js +++ b/lib/utils/isStandardSyntaxValue.js @@ -39,7 +39,7 @@ module.exports = function (value) { // WebExtension replacement keyword used by Chrome/Firefox // more information: https://developer.chrome.com/extensions/i18n // and https://github.com/stylelint/stylelint/issues/4707 - if (/__MSG_[^\s]+__/.test(value)) { + if (/__MSG_\S+__/.test(value)) { return false; } diff --git a/lib/utils/parseSelector.js b/lib/utils/parseSelector.js index 75ebb9bf44..a9c4bd1d1a 100644 --- a/lib/utils/parseSelector.js +++ b/lib/utils/parseSelector.js @@ -12,7 +12,7 @@ module.exports = function parseSelector(selector, result, node, cb) { try { // @ts-ignore TODO TYPES wrong postcss-selector-parser types return selectorParser(cb).processSync(selector); - } catch (e) { + } catch { result.warn('Cannot parse selector', { node, stylelintType: 'parseError' }); } }; diff --git a/lib/utils/transformSelector.js b/lib/utils/transformSelector.js index 2217dc7716..70bca0acaf 100644 --- a/lib/utils/transformSelector.js +++ b/lib/utils/transformSelector.js @@ -11,7 +11,7 @@ module.exports = function (result, node, cb) { try { // @ts-ignore TODO TYPES wrong postcss-selector-parser definitions return selectorParser(cb).processSync(node, { updateSelector: true }); - } catch (e) { + } catch { result.warn('Cannot parse selector', { node, stylelintType: 'parseError' }); } }; diff --git a/lib/utils/validateOptions.js b/lib/utils/validateOptions.js index be701baaea..4525329d43 100644 --- a/lib/utils/validateOptions.js +++ b/lib/utils/validateOptions.js @@ -2,7 +2,7 @@ const _ = require('lodash'); -const ignoredOptions = ['severity', 'message', 'reportDisables']; +const ignoredOptions = new Set(['severity', 'message', 'reportDisables']); /** @typedef {{possible: any, actual: any, optional: boolean}} Options */ @@ -125,7 +125,7 @@ function validate(opts, ruleName, complain) { } Object.keys(actual).forEach((optionName) => { - if (ignoredOptions.includes(optionName)) { + if (ignoredOptions.has(optionName)) { return; } diff --git a/lib/utils/vendor.js b/lib/utils/vendor.js index b56b180c0d..06f61ad4d1 100644 --- a/lib/utils/vendor.js +++ b/lib/utils/vendor.js @@ -20,7 +20,7 @@ module.exports = { * vendor.prefix('tab-size') //=> '' */ prefix(prop) { - let match = prop.match(/^(-\w+-)/); + const match = prop.match(/^(-\w+-)/); if (match) { return match[0];