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

stylehacks

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylehacks - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

dist/exists.js

5

CHANGELOG.md

@@ -0,3 +1,8 @@

# 2.0.0
* Added `body:empty` & `html:first-child` hacks.
* Upgraded to PostCSS 5.
# 1.0.0
* Initial release.

4

dist/formatter.js

@@ -30,3 +30,5 @@ 'use strict';

var logFrom = function logFrom(fromValue) {
if (!fromValue.indexOf('<')) return fromValue;
if (!fromValue.indexOf('<')) {
return fromValue;
}
return _path2['default'].relative(process.cwd(), fromValue);

@@ -33,0 +35,0 @@ };

@@ -27,2 +27,10 @@ 'use strict';

var _pluginsBodyEmpty = require('./plugins/bodyEmpty');
var _pluginsBodyEmpty2 = _interopRequireDefault(_pluginsBodyEmpty);
var _pluginsHtmlFirstChild = require('./plugins/htmlFirstChild');
var _pluginsHtmlFirstChild2 = _interopRequireDefault(_pluginsHtmlFirstChild);
var _pluginsImportant = require('./plugins/important');

@@ -56,6 +64,6 @@

var plugins = [_pluginsImportant2['default'], _pluginsLeadingStar2['default'], _pluginsLeadingUnderscore2['default'], _pluginsMediaSlash02['default'], _pluginsMediaSlash92['default'], _pluginsStarHtml2['default'], _pluginsTrailingSlashComma2['default']];
var plugins = [_pluginsBodyEmpty2['default'], _pluginsHtmlFirstChild2['default'], _pluginsImportant2['default'], _pluginsLeadingStar2['default'], _pluginsLeadingUnderscore2['default'], _pluginsMediaSlash02['default'], _pluginsMediaSlash92['default'], _pluginsStarHtml2['default'], _pluginsTrailingSlashComma2['default']];
var stylehacks = _postcss2['default'].plugin('stylehacks', function () {
var opts = arguments[0] === undefined ? {} : arguments[0];
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

@@ -85,3 +93,3 @@ var b = opts.browsers;

stylehacks.process = function (css) {
var opts = arguments[1] === undefined ? {} : arguments[1];
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -88,0 +96,0 @@ opts.reporter = {};

@@ -55,3 +55,3 @@ 'use strict';

return this.nodes.forEach(function (node) {
return node.removeSelf();
return node.remove();
});

@@ -58,0 +58,0 @@ }

@@ -19,3 +19,3 @@ 'use strict';

this.css.eachDecl(function (decl) {
this.css.walkDecls(function (decl) {
var match = decl.value.match(/!\w/);

@@ -22,0 +22,0 @@ if (match) {

@@ -19,4 +19,5 @@ 'use strict';

this.css.eachDecl(function (decl) {
if (!decl.before) {
this.css.walkDecls(function (decl) {
var before = decl.raws.before;
if (!before) {
return;

@@ -26,4 +27,4 @@ }

var hasBefore = hacks.some(function (hack) {
if (~decl.before.indexOf(hack)) {
_this.push(decl, 'Bad property: ' + decl.before.trim() + decl.prop);
if (~before.indexOf(hack)) {
_this.push(decl, 'Bad property: ' + before.trim() + decl.prop);
return true;

@@ -43,3 +44,3 @@ }

});
this.css.eachAtRule(function (rule) {
this.css.walkAtRules(function (rule) {
// test for the @property: value; hack

@@ -46,0 +47,0 @@ if (rule.name.lastIndexOf(':') === rule.name.length - 1) {

@@ -19,8 +19,9 @@ 'use strict';

this.css.eachDecl(function (decl) {
if (!decl.before) {
this.css.walkDecls(function (decl) {
var before = decl.raws.before;
if (!before) {
return;
}
if (~decl.before.indexOf('_') || ~decl.before.indexOf('-')) {
_this.push(decl, 'Bad property: ' + decl.before.trim() + decl.prop);
if (~before.indexOf('_') || ~before.indexOf('-')) {
_this.push(decl, 'Bad property: ' + before.trim() + decl.prop);
}

@@ -27,0 +28,0 @@ });

@@ -19,3 +19,3 @@ 'use strict';

this.css.eachAtRule('media', function (rule) {
this.css.walkAtRules('media', function (rule) {
var params = rule.params.trim();

@@ -22,0 +22,0 @@ if (params === '\\0screen') {

@@ -19,3 +19,3 @@ 'use strict';

this.css.eachAtRule('media', function (rule) {
this.css.walkAtRules('media', function (rule) {
var params = rule.params.trim();

@@ -22,0 +22,0 @@ if (params === 'screen\\9') {

@@ -9,2 +9,6 @@ 'use strict';

var _exists = require('../exists');
var _exists2 = _interopRequireDefault(_exists);
var _plugin = require('../plugin');

@@ -21,11 +25,6 @@

function exists(selector, index, value) {
var node = selector.at(index);
return node && node.value === value;
}
function analyse(ctx, rule) {
return function (selectors) {
selectors.each(function (selector) {
if (exists(selector, 0, '*') && exists(selector, 1, ' ') && exists(selector, 2, 'html') && exists(selector, 3, ' ') && selector.at(4)) {
if ((0, _exists2['default'])(selector, 0, '*') && (0, _exists2['default'])(selector, 1, ' ') && (0, _exists2['default'])(selector, 2, 'html') && (0, _exists2['default'])(selector, 3, ' ') && selector.at(4)) {
ctx.push(rule, 'Bad selector: ' + selector);

@@ -40,3 +39,3 @@ }

this.css.eachRule(function (rule) {
this.css.walkRules(function (rule) {
if (rule.selector) {

@@ -43,0 +42,0 @@ (0, _postcssSelectorParser2['default'])(analyse(_this, rule)).process(rule.selector);

@@ -19,3 +19,3 @@ 'use strict';

this.css.eachRule(function (rule) {
this.css.walkRules(function (rule) {
if (rule.selector) {

@@ -22,0 +22,0 @@ var sel = rule.selector;

{
"name": "stylehacks",
"version": "1.0.0",
"version": "2.0.0",
"description": "Detect/remove browser hacks from CSS files.",

@@ -17,3 +17,3 @@ "main": "dist/index.js",

"test-unformatted": "babel-tape-runner \"src/**/__tests__/*.js\"",
"test": "npm run test-unformatted | faucet"
"test": "npm run test-unformatted | tap-spec"
},

@@ -32,6 +32,6 @@ "keywords": [

"devDependencies": {
"babel": "^5.6.14",
"babel-tape-runner": "^1.1.0",
"faucet": "0.0.1",
"tape": "^4.0.0"
"babel": "^5.8.23",
"babel-tape-runner": "^1.2.0",
"tap-spec": "^4.1.0",
"tape": "^4.2.0"
},

@@ -46,10 +46,10 @@ "homepage": "https://github.com/ben-eb/stylehacks",

"dependencies": {
"browserslist": "^0.5.0",
"chalk": "^1.1.0",
"browserslist": "^1.0.0",
"chalk": "^1.1.1",
"log-symbols": "^1.0.2",
"minimist": "^1.1.1",
"minimist": "^1.2.0",
"plur": "^2.0.0",
"postcss": "^4.1.14",
"postcss-reporter": "^0.1.0",
"postcss-selector-parser": "^1.1.2",
"postcss": "^5.0.4",
"postcss-reporter": "^1.1.0",
"postcss-selector-parser": "^1.2.0",
"read-file-stdin": "^0.2.0",

@@ -56,0 +56,0 @@ "text-table": "^0.2.0",

@@ -88,2 +88,9 @@ # stylehacks [![Build Status](https://travis-ci.org/ben-eb/stylehacks.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/stylehacks.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/stylehacks.svg)][deps]

## Related
stylehacks works well with your existing PostCSS setup:
* [stylelint] - Comprehensive & modern CSS linter, to ensure that your code
style rules are respected.
## Contributing

@@ -98,5 +105,6 @@

[ci]: https://travis-ci.org/ben-eb/stylehacks
[deps]: https://gemnasium.com/ben-eb/stylehacks
[npm]: http://badge.fury.io/js/stylehacks
[postcss]: https://github.com/postcss/postcss
[ci]: https://travis-ci.org/ben-eb/stylehacks
[deps]: https://gemnasium.com/ben-eb/stylehacks
[npm]: http://badge.fury.io/js/stylehacks
[postcss]: https://github.com/postcss/postcss
[stylelint]: https://github.com/stylelint/stylelint
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