diff --git a/lib/rules/selector-attribute-brackets-space-inside/__tests__/index.js b/lib/rules/selector-attribute-brackets-space-inside/__tests__/index.js index a60f42d2f4..20914812f1 100644 --- a/lib/rules/selector-attribute-brackets-space-inside/__tests__/index.js +++ b/lib/rules/selector-attribute-brackets-space-inside/__tests__/index.js @@ -106,6 +106,10 @@ testRule(rule, { code: 'html { --custom-property-set: {} }', description: 'custom property set in selector', }, + { + code: 'a[b=#{c}] { }', + description: 'ignore "invalid" selector (see #3130)', + }, ], reject: [ diff --git a/lib/rules/selector-attribute-operator-space-after/__tests__/index.js b/lib/rules/selector-attribute-operator-space-after/__tests__/index.js index aff25843ed..a7cf61334f 100644 --- a/lib/rules/selector-attribute-operator-space-after/__tests__/index.js +++ b/lib/rules/selector-attribute-operator-space-after/__tests__/index.js @@ -271,6 +271,10 @@ testRule(rule, { code: 'html { --custom-property-set: {} }', description: 'custom property set in selector', }, + { + code: 'a[b=#{c}] { }', + description: 'ignore "invalid" selector (see #3130)', + }, ], reject: [ diff --git a/lib/rules/selector-attribute-operator-space-before/__tests__/index.js b/lib/rules/selector-attribute-operator-space-before/__tests__/index.js index 463a52921f..ddd54c42a7 100644 --- a/lib/rules/selector-attribute-operator-space-before/__tests__/index.js +++ b/lib/rules/selector-attribute-operator-space-before/__tests__/index.js @@ -271,6 +271,10 @@ testRule(rule, { code: 'html { --custom-property-set: {} }', description: 'custom property set in selector', }, + { + code: 'a[b=#{c}] { }', + description: 'ignore "invalid" selector (see #3130)', + }, ], reject: [ diff --git a/lib/rules/selector-attribute-quotes/index.js b/lib/rules/selector-attribute-quotes/index.js index 9527112892..567426cc72 100644 --- a/lib/rules/selector-attribute-quotes/index.js +++ b/lib/rules/selector-attribute-quotes/index.js @@ -1,7 +1,6 @@ 'use strict'; const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); @@ -30,10 +29,6 @@ const rule = function(expectation) { return; } - if (!isStandardSyntaxSelector(rule.selector)) { - return; - } - if (!rule.selector.includes('[') || !rule.selector.includes('=')) { return; } diff --git a/lib/rules/selector-class-pattern/index.js b/lib/rules/selector-class-pattern/index.js index 3261fe4bcd..3a854bf489 100644 --- a/lib/rules/selector-class-pattern/index.js +++ b/lib/rules/selector-class-pattern/index.js @@ -50,10 +50,6 @@ const rule = function(pattern, options) { return; } - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (selectors.some((s) => isKeyframeSelector(s))) { return; } diff --git a/lib/rules/selector-combinator-space-after/__tests__/index.js b/lib/rules/selector-combinator-space-after/__tests__/index.js index e529674b98..b1a0cef123 100644 --- a/lib/rules/selector-combinator-space-after/__tests__/index.js +++ b/lib/rules/selector-combinator-space-after/__tests__/index.js @@ -149,6 +149,10 @@ testRule(rule, { code: '.a { &:first-child {} }', description: 'nesting and no combinators', }, + { + code: 'a[b=#{c}] { }', + description: 'ignore "invalid" selector (see #3130)', + }, ], reject: [ diff --git a/lib/rules/selector-combinator-space-before/__tests__/index.js b/lib/rules/selector-combinator-space-before/__tests__/index.js index 85e433ec96..39dbf2c198 100644 --- a/lib/rules/selector-combinator-space-before/__tests__/index.js +++ b/lib/rules/selector-combinator-space-before/__tests__/index.js @@ -137,6 +137,10 @@ testRule(rule, { code: 'html { --custom-property-set: {} }', description: 'custom property set in selector', }, + { + code: 'a[b=#{c}] { }', + description: 'ignore "invalid" selector (see #3130)', + }, { code: 'namespace|type#id > .foo {}', description: 'qualified ID with namespace', diff --git a/lib/rules/selector-descendant-combinator-no-non-space/__tests__/index.js b/lib/rules/selector-descendant-combinator-no-non-space/__tests__/index.js index 09cad3f31d..a02dc9466e 100644 --- a/lib/rules/selector-descendant-combinator-no-non-space/__tests__/index.js +++ b/lib/rules/selector-descendant-combinator-no-non-space/__tests__/index.js @@ -79,6 +79,10 @@ testRule(rule, { } `, }, + { + code: 'a[b=#{c}] { }', + description: 'ignore "invalid" selector (see #3130)', + }, ], reject: [ diff --git a/lib/rules/selector-id-pattern/index.js b/lib/rules/selector-id-pattern/index.js index 5b495277d1..578a924a15 100644 --- a/lib/rules/selector-id-pattern/index.js +++ b/lib/rules/selector-id-pattern/index.js @@ -2,7 +2,6 @@ const _ = require('lodash'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); @@ -35,10 +34,6 @@ const rule = function(pattern) { const selector = rule.selector; - if (!isStandardSyntaxSelector(selector)) { - return; - } - parseSelector(selector, result, rule, (fullSelector) => { fullSelector.walk((selectorNode) => { if (selectorNode.type !== 'id') { diff --git a/lib/rules/selector-max-attribute/index.js b/lib/rules/selector-max-attribute/index.js index 72e6cd0846..ab85ad276f 100644 --- a/lib/rules/selector-max-attribute/index.js +++ b/lib/rules/selector-max-attribute/index.js @@ -3,7 +3,6 @@ const _ = require('lodash'); const isLogicalCombination = require('../../utils/isLogicalCombination'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const optionsMatches = require('../../utils/optionsMatches'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); @@ -82,10 +81,6 @@ function rule(max, options) { return; } - if (!isStandardSyntaxSelector(ruleNode.selector)) { - return; - } - ruleNode.selectors.forEach((selector) => { resolvedNestedSelector(selector, ruleNode).forEach((resolvedSelector) => { parseSelector(resolvedSelector, result, ruleNode, (container) => diff --git a/lib/rules/selector-max-class/index.js b/lib/rules/selector-max-class/index.js index c4a51785fa..50e96b30b5 100644 --- a/lib/rules/selector-max-class/index.js +++ b/lib/rules/selector-max-class/index.js @@ -2,7 +2,6 @@ const isLogicalCombination = require('../../utils/isLogicalCombination'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); const resolvedNestedSelector = require('postcss-resolve-nested-selector'); @@ -57,10 +56,6 @@ function rule(max) { return; } - if (!isStandardSyntaxSelector(ruleNode.selector)) { - return; - } - ruleNode.selectors.forEach((selector) => { resolvedNestedSelector(selector, ruleNode).forEach((resolvedSelector) => { parseSelector(resolvedSelector, result, ruleNode, (container) => diff --git a/lib/rules/selector-max-combinators/index.js b/lib/rules/selector-max-combinators/index.js index e386521676..9b8839b93d 100644 --- a/lib/rules/selector-max-combinators/index.js +++ b/lib/rules/selector-max-combinators/index.js @@ -1,7 +1,6 @@ 'use strict'; const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); const resolvedNestedSelector = require('postcss-resolve-nested-selector'); @@ -58,10 +57,6 @@ function rule(max) { return; } - if (!isStandardSyntaxSelector(ruleNode.selector)) { - return; - } - ruleNode.selectors.forEach((selector) => { resolvedNestedSelector(selector, ruleNode).forEach((resolvedSelector) => { parseSelector(resolvedSelector, result, ruleNode, (container) => diff --git a/lib/rules/selector-max-compound-selectors/index.js b/lib/rules/selector-max-compound-selectors/index.js index 34f68bb91a..57e5b23138 100644 --- a/lib/rules/selector-max-compound-selectors/index.js +++ b/lib/rules/selector-max-compound-selectors/index.js @@ -2,7 +2,6 @@ const isLogicalCombination = require('../../utils/isLogicalCombination'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); const resolvedNestedSelector = require('postcss-resolve-nested-selector'); @@ -65,10 +64,6 @@ const rule = function(max) { return; } - if (!isStandardSyntaxSelector(rule.selector)) { - return; - } - // Using `rule.selectors` gets us each selector if there is a comma separated set rule.selectors.forEach((selector) => { resolvedNestedSelector(selector, rule).forEach((resolvedSelector) => { diff --git a/lib/rules/selector-max-id/index.js b/lib/rules/selector-max-id/index.js index 26a48c599f..3bd2858e55 100644 --- a/lib/rules/selector-max-id/index.js +++ b/lib/rules/selector-max-id/index.js @@ -2,7 +2,6 @@ const isLogicalCombination = require('../../utils/isLogicalCombination'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); const resolvedNestedSelector = require('postcss-resolve-nested-selector'); @@ -57,10 +56,6 @@ function rule(max) { return; } - if (!isStandardSyntaxSelector(ruleNode.selector)) { - return; - } - ruleNode.selectors.forEach((selector) => { resolvedNestedSelector(selector, ruleNode).forEach((resolvedSelector) => { parseSelector(resolvedSelector, result, ruleNode, (container) => diff --git a/lib/rules/selector-max-pseudo-class/index.js b/lib/rules/selector-max-pseudo-class/index.js index a2c787e289..43076ff293 100644 --- a/lib/rules/selector-max-pseudo-class/index.js +++ b/lib/rules/selector-max-pseudo-class/index.js @@ -2,7 +2,6 @@ const isLogicalCombination = require('../../utils/isLogicalCombination'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const keywordSets = require('../../reference/keywordSets'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); @@ -71,10 +70,6 @@ function rule(max) { return; } - if (!isStandardSyntaxSelector(ruleNode.selector)) { - return; - } - ruleNode.selectors.forEach((selector) => { resolvedNestedSelector(selector, ruleNode).forEach((resolvedSelector) => { parseSelector(resolvedSelector, result, rule, (selectorTree) => { diff --git a/lib/rules/selector-max-specificity/index.js b/lib/rules/selector-max-specificity/index.js index 57f9fdb2f0..cdda3409a8 100755 --- a/lib/rules/selector-max-specificity/index.js +++ b/lib/rules/selector-max-specificity/index.js @@ -145,10 +145,6 @@ const rule = function(max, options) { return; } - if (!isStandardSyntaxSelector(rule.selector)) { - return; - } - // Using rule.selectors gets us each selector in the eventuality we have a comma separated set rule.selectors.forEach((selector) => { resolvedNestedSelector(selector, rule).forEach((resolvedSelector) => { diff --git a/lib/rules/selector-max-type/index.js b/lib/rules/selector-max-type/index.js index 0a4665e89d..f0739bd4b4 100644 --- a/lib/rules/selector-max-type/index.js +++ b/lib/rules/selector-max-type/index.js @@ -94,17 +94,12 @@ function rule(max, options) { } root.walkRules((ruleNode) => { - const selector = ruleNode.selector; const selectors = ruleNode.selectors; if (!isStandardSyntaxRule(ruleNode)) { return; } - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (selectors.some((s) => isKeyframeSelector(s))) { return; } diff --git a/lib/rules/selector-max-universal/index.js b/lib/rules/selector-max-universal/index.js index bd2fa88db3..10de790923 100644 --- a/lib/rules/selector-max-universal/index.js +++ b/lib/rules/selector-max-universal/index.js @@ -1,7 +1,6 @@ 'use strict'; const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); const resolvedNestedSelector = require('postcss-resolve-nested-selector'); @@ -60,10 +59,6 @@ function rule(max) { return; } - if (!isStandardSyntaxSelector(ruleNode.selector)) { - return; - } - const selectors = []; selectorParser() diff --git a/lib/rules/selector-nested-pattern/index.js b/lib/rules/selector-nested-pattern/index.js index ec947c3415..e4bd777cde 100644 --- a/lib/rules/selector-nested-pattern/index.js +++ b/lib/rules/selector-nested-pattern/index.js @@ -2,7 +2,6 @@ const _ = require('lodash'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const report = require('../../utils/report'); const ruleMessages = require('../../utils/ruleMessages'); const validateOptions = require('../../utils/validateOptions'); @@ -37,10 +36,6 @@ const rule = function(pattern) { const selector = rule.selector; - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (normalizedPattern.test(selector)) { return; } diff --git a/lib/rules/selector-no-qualifying-type/index.js b/lib/rules/selector-no-qualifying-type/index.js index a7d275e7fa..39b0dcb627 100644 --- a/lib/rules/selector-no-qualifying-type/index.js +++ b/lib/rules/selector-no-qualifying-type/index.js @@ -72,11 +72,6 @@ const rule = function(enabled, options) { return; } - // Increasing performance - if (!isStandardSyntaxSelector(rule.selector)) { - return; - } - if (!isSelectorCharacters(rule.selector)) { return; } diff --git a/lib/rules/selector-no-vendor-prefix/index.js b/lib/rules/selector-no-vendor-prefix/index.js index db39b699e5..5ca49fe6e5 100644 --- a/lib/rules/selector-no-vendor-prefix/index.js +++ b/lib/rules/selector-no-vendor-prefix/index.js @@ -3,7 +3,6 @@ const _ = require('lodash'); const isAutoprefixable = require('../../utils/isAutoprefixable'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const optionsMatches = require('../../utils/optionsMatches'); const parseSelector = require('../../utils/parseSelector'); const report = require('../../utils/report'); @@ -42,10 +41,6 @@ const rule = function(actual, options) { const selector = rule.selector; - if (!isStandardSyntaxSelector(selector)) { - return; - } - parseSelector(selector, result, rule, (selectorTree) => { selectorTree.walkPseudos((pseudoNode) => { if (isAutoprefixable.selector(pseudoNode.value)) { diff --git a/lib/rules/selector-pseudo-class-blacklist/index.js b/lib/rules/selector-pseudo-class-blacklist/index.js index 890a8cb62a..e7abfe7466 100644 --- a/lib/rules/selector-pseudo-class-blacklist/index.js +++ b/lib/rules/selector-pseudo-class-blacklist/index.js @@ -2,7 +2,6 @@ const _ = require('lodash'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const matchesStringOrRegExp = require('../../utils/matchesStringOrRegExp'); const parseSelector = require('../../utils/parseSelector'); const postcss = require('postcss'); @@ -34,10 +33,6 @@ const rule = function(blacklist) { const selector = rule.selector; - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (!selector.includes(':')) { return; } diff --git a/lib/rules/selector-pseudo-class-parentheses-space-inside/__tests__/index.js b/lib/rules/selector-pseudo-class-parentheses-space-inside/__tests__/index.js index e95f2e3e66..834dd8034e 100644 --- a/lib/rules/selector-pseudo-class-parentheses-space-inside/__tests__/index.js +++ b/lib/rules/selector-pseudo-class-parentheses-space-inside/__tests__/index.js @@ -46,6 +46,10 @@ testRule(rule, { code: 'html { --custom-property-set: {} }', description: 'custom property set in selector', }, + { + code: 'a[b=#{c}] { }', + description: 'ignore "invalid" selector (see #3130)', + }, ], reject: [ diff --git a/lib/rules/selector-pseudo-class-whitelist/index.js b/lib/rules/selector-pseudo-class-whitelist/index.js index 65ff4425e4..d4d055eaca 100644 --- a/lib/rules/selector-pseudo-class-whitelist/index.js +++ b/lib/rules/selector-pseudo-class-whitelist/index.js @@ -2,7 +2,6 @@ const _ = require('lodash'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const matchesStringOrRegExp = require('../../utils/matchesStringOrRegExp'); const parseSelector = require('../../utils/parseSelector'); const postcss = require('postcss'); @@ -34,10 +33,6 @@ const rule = function(whitelist) { const selector = rule.selector; - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (!selector.includes(':')) { return; } diff --git a/lib/rules/selector-pseudo-element-blacklist/index.js b/lib/rules/selector-pseudo-element-blacklist/index.js index ced1f44a16..8c500ee98c 100644 --- a/lib/rules/selector-pseudo-element-blacklist/index.js +++ b/lib/rules/selector-pseudo-element-blacklist/index.js @@ -2,7 +2,6 @@ const _ = require('lodash'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const matchesStringOrRegExp = require('../../utils/matchesStringOrRegExp'); const parseSelector = require('../../utils/parseSelector'); const postcss = require('postcss'); @@ -34,10 +33,6 @@ const rule = function(blacklist) { const selector = rule.selector; - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (!selector.includes('::')) { return; } diff --git a/lib/rules/selector-pseudo-element-whitelist/index.js b/lib/rules/selector-pseudo-element-whitelist/index.js index a2df6b7dac..1456748eff 100644 --- a/lib/rules/selector-pseudo-element-whitelist/index.js +++ b/lib/rules/selector-pseudo-element-whitelist/index.js @@ -2,7 +2,6 @@ const _ = require('lodash'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const matchesStringOrRegExp = require('../../utils/matchesStringOrRegExp'); const parseSelector = require('../../utils/parseSelector'); const postcss = require('postcss'); @@ -34,10 +33,6 @@ const rule = function(whitelist) { const selector = rule.selector; - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (!selector.includes('::')) { return; } diff --git a/lib/rules/selector-type-case/index.js b/lib/rules/selector-type-case/index.js index cb8d149e4f..9d2433fa04 100644 --- a/lib/rules/selector-type-case/index.js +++ b/lib/rules/selector-type-case/index.js @@ -3,7 +3,6 @@ const _ = require('lodash'); const isKeyframeSelector = require('../../utils/isKeyframeSelector'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const isStandardSyntaxTypeSelector = require('../../utils/isStandardSyntaxTypeSelector'); const optionsMatches = require('../../utils/optionsMatches'); const parseSelector = require('../../utils/parseSelector'); @@ -48,10 +47,6 @@ const rule = function(expectation, options, context) { return; } - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (selectors.some((s) => isKeyframeSelector(s))) { return; } diff --git a/lib/rules/selector-type-no-unknown/index.js b/lib/rules/selector-type-no-unknown/index.js index daa5f8b9a6..af9f8f94b0 100644 --- a/lib/rules/selector-type-no-unknown/index.js +++ b/lib/rules/selector-type-no-unknown/index.js @@ -5,7 +5,6 @@ const htmlTags = require('html-tags'); const isCustomElement = require('../../utils/isCustomElement'); const isKeyframeSelector = require('../../utils/isKeyframeSelector'); const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule'); -const isStandardSyntaxSelector = require('../../utils/isStandardSyntaxSelector'); const isStandardSyntaxTypeSelector = require('../../utils/isStandardSyntaxTypeSelector'); const keywordSets = require('../../reference/keywordSets'); const mathMLTags = require('mathml-tag-names'); @@ -51,10 +50,6 @@ const rule = function(actual, options) { return; } - if (!isStandardSyntaxSelector(selector)) { - return; - } - if (selectors.some((s) => isKeyframeSelector(s))) { return; } diff --git a/lib/rules/string-quotes/__tests__/index.js b/lib/rules/string-quotes/__tests__/index.js index 05b418b81e..18a834ad0c 100644 --- a/lib/rules/string-quotes/__tests__/index.js +++ b/lib/rules/string-quotes/__tests__/index.js @@ -50,6 +50,10 @@ testRule(rule, { code: '@charset "utf-8"', description: 'ignore @charset rules', }, + { + code: 'a[b=#{c}][d="e"] { }', + description: 'ignore "invalid" selector (see #3130)', + }, ], reject: [ diff --git a/lib/utils/isStandardSyntaxRule.js b/lib/utils/isStandardSyntaxRule.js index 56716bfef4..7128c8083f 100644 --- a/lib/utils/isStandardSyntaxRule.js +++ b/lib/utils/isStandardSyntaxRule.js @@ -2,6 +2,7 @@ const _ = require('lodash'); const isCustomPropertySet = require('../utils/isCustomPropertySet'); +const isStandardSyntaxSelector = require('../utils/isStandardSyntaxSelector'); /** * Check whether a Node is a standard rule @@ -13,6 +14,10 @@ module.exports = function(rule) { // Get full selector const selector = _.get(rule, 'raws.selector.raw', rule.selector); + if (!isStandardSyntaxSelector(rule.selector)) { + return false; + } + // Custom property set (e.g. --custom-property-set: {}) if (isCustomPropertySet(rule)) { return false;