Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-bem-linter

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-bem-linter - npm Package Compare versions

Comparing version 2.5.0 to 2.5.1

lib/get-selectors.js

4

CHANGELOG.md

@@ -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 @@

51

lib/validate-selectors.js

@@ -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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc