You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

postcss-bad-selectors

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-bad-selectors

Checks selectors according to the CSS standards of 2create.

1.0.3
latest
Source
npmnpm
Version published
Weekly downloads
1
-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

postcss-bad-selectors Build Status npm version

PostCSS plugin that slaps you, if you write wrong selectors.

Install

npm install postcss-bad-selectors

Example

var path    = require('path');
var postcss = require('postcss');
var bad     = require('postcss-bad-selectors');

postcss([bad(getToken)])
	.process(css, { from: './css/_module.logo.css' })
	.catch(function(err) {
		console.log(err); // Wrong selector error
	})


function getToken(file) {
	var file        = path.basename(file);
	var prefixRegex = /^_module/gi;
	var token       = null;

	if (prefixRegex.test(file)) {
		token = file.replace(prefixRegex, '');
		token = path.basename(token, '.css');
	}

	return token; // 'Valid CSS selector e.g. _module.logo.css => .logo'
}

Note: getToken can return String or RegExp.

Input

.logo {}
.wrapper .logo-blue {}

Output

postcss-bad-selectors: /Users/john/Server/project/css/_module.logo.css:8:2: Wrong selector
@media (max-width: 767px) {
	.logo,
 ^
	.wrapper .logo-blue {}

Contributing

Pull requests are welcome.

License

MIT © 2createStudio

Keywords

css

FAQs

Package last updated on 22 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts