postcss-bem-linter
Advanced tools
Comparing version 3.2.0 to 3.3.0
### HEAD | ||
### 3.3.0 (March 25, 2019) | ||
* Allow lint rule that contains `@media` [#140](https://github.com/postcss/postcss-bem-linter/pull/140) | ||
* Fix duplicate warnings [#141](https://github.com/postcss/postcss-bem-linter/pull/141) | ||
### 3.2.0 (January 07, 2019) | ||
@@ -4,0 +9,0 @@ |
@@ -17,26 +17,25 @@ 'use strict'; | ||
function hasOnlyExtends(node) { | ||
return ( | ||
hasChildNodes(node) && | ||
node.every(child => child.type === 'atrule' && child.name === 'extend') | ||
); | ||
} | ||
function hasOnlyAllowedAtRules(node) { | ||
let containsAllowed = false; | ||
let containsNotAllowed = false; | ||
function getComponentRootRule(node) { | ||
while (node.root() !== node.parent) { | ||
node = node.parent; | ||
if (hasChildNodes(node)) { | ||
node.each(child => { | ||
if ( | ||
child.type === 'atrule' && | ||
(child.name === 'extend' || child.name === 'media') | ||
) { | ||
containsAllowed = true; | ||
} else if (child.type !== 'comment') { | ||
containsNotAllowed = true; | ||
} | ||
}); | ||
} | ||
return node; | ||
return containsAllowed && !containsNotAllowed; | ||
} | ||
function unWrapSelectors(parent, rule) { | ||
function unWrapSelectors(rule) { | ||
let selectors = []; | ||
parent.walkRules(node => { | ||
// Only unwrap as far as the current rule being linted | ||
if (node.selector !== rule.selector) { | ||
return; | ||
} | ||
node.selectors.forEach(selector => { | ||
selectors = selectors.concat(resolveNestedSelector(selector, node)); | ||
}); | ||
rule.selectors.forEach(selector => { | ||
selectors = selectors.concat(resolveNestedSelector(selector, rule)); | ||
}); | ||
@@ -48,4 +47,4 @@ return selectors; | ||
// Skip validation on rules with no declarations | ||
// as these don't exist after rules have been unwrapped (unless the selector contains only a @extend) | ||
if (hasNoDeclarations(rule) && !hasOnlyExtends(rule)) { | ||
// as these don't exist after rules have been unwrapped (unless the selector contains only a @extend or @media) | ||
if (hasNoDeclarations(rule) && !hasOnlyAllowedAtRules(rule)) { | ||
return []; | ||
@@ -55,5 +54,3 @@ } | ||
if (isNestedRule(rule)) { | ||
const componentRootRule = getComponentRootRule(rule); | ||
const nestedSelectors = unWrapSelectors(componentRootRule, rule); | ||
return nestedSelectors; | ||
return unWrapSelectors(rule); | ||
} | ||
@@ -60,0 +57,0 @@ |
{ | ||
"name": "postcss-bem-linter", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "A BEM linter for postcss", | ||
@@ -11,3 +11,3 @@ "files": [ | ||
"minimatch": "^3.0.3", | ||
"postcss": "^6.0.6", | ||
"postcss": "^7.0.14", | ||
"postcss-resolve-nested-selector": "^0.1.1" | ||
@@ -23,3 +23,3 @@ }, | ||
"eslint-plugin-react": "^7.1.0", | ||
"jest": "^22.4.3", | ||
"jest": "^24.5.0", | ||
"prettier": "^1.11.1" | ||
@@ -26,0 +26,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41676
583
+ Addedpicocolors@0.2.1(transitive)
+ Addedpostcss@7.0.39(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedpostcss@6.0.23(transitive)
- Removedsupports-color@5.5.0(transitive)
Updatedpostcss@^7.0.14