postcss-bem-linter
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -0,1 +1,5 @@ | ||
=== 2.5.1 (May 1, 2016) | ||
* Add support for nested selectors in utility stylesheets. | ||
=== 2.5.0 (April 27, 2016) | ||
@@ -2,0 +6,0 @@ |
@@ -5,53 +5,4 @@ var listSequences = require('./list-sequences'); | ||
var toInterpoloatedRegexp = require('./to-interpolated-regexp'); | ||
var resolveNestedSelector = require('postcss-resolve-nested-selector'); | ||
var getSelectors = require('./get-selectors'); | ||
function isTopLevel(node) { | ||
return node.type === 'root'; | ||
} | ||
function isNestedRule(node) { | ||
return /(?:at)?rule/.test(node.parent.type) | ||
} | ||
function hasNoDeclarations(node) { | ||
return node.nodes.length && node.every(function(child) { | ||
return child.type !== 'decl'; | ||
}); | ||
} | ||
function getComponentRootRule(node) { | ||
while (!isTopLevel(node.parent)) { | ||
node = node.parent; | ||
} | ||
return node; | ||
} | ||
function unWrapSelectors(parent, rule) { | ||
var selectors = []; | ||
parent.walkRules(function(node) { | ||
// Only unwrap as far as the current rule being linted | ||
if (node.selector !== rule.selector) {return;} | ||
node.selectors.forEach(function(selector) { | ||
selectors = selectors.concat(resolveNestedSelector(selector, node)); | ||
}); | ||
}); | ||
return selectors; | ||
} | ||
function getSelectors(rule) { | ||
// Skip validation on rules with no declarations | ||
// as these don't exist after rules have been unwrapped | ||
if (hasNoDeclarations(rule)) { | ||
return []; | ||
} | ||
if (isNestedRule(rule)) { | ||
var componentRootRule = getComponentRootRule(rule); | ||
var nestedSelectors = unWrapSelectors(componentRootRule, rule); | ||
return nestedSelectors; | ||
} | ||
return rule.selectors; | ||
} | ||
/** | ||
@@ -58,0 +9,0 @@ * @param {Object} config |
var listSequences = require('./list-sequences'); | ||
var shouldIgnoreRule = require('./should-ignore-rule'); | ||
var shouldIgnoreSelector = require('./should-ignore-selector'); | ||
var getSelectors = require('./get-selectors'); | ||
@@ -14,4 +15,5 @@ /** | ||
if (shouldIgnoreRule(config.rule)) return; | ||
var selectors = getSelectors(config.rule) | ||
config.rule.selectors.forEach(function(selector) { | ||
selectors.forEach(function(selector) { | ||
var allSequences = listSequences(selector); | ||
@@ -18,0 +20,0 @@ var sequence; |
{ | ||
"name": "postcss-bem-linter", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "A BEM linter for postcss", | ||
@@ -15,4 +15,3 @@ "files": [ | ||
"eslint": "1.7.3", | ||
"mocha": "2.3.3", | ||
"rewire": "^2.5.1" | ||
"mocha": "2.3.3" | ||
}, | ||
@@ -19,0 +18,0 @@ "scripts": { |
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
34230
2
18
440