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

postcss-bem-linter

Package Overview
Dependencies
Maintainers
3
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 3.2.0 to 3.3.0

5

CHANGELOG.md
### 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 @@

45

lib/get-selectors.js

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

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