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

stylehacks

Package Overview
Dependencies
Maintainers
6
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 2.3.2 to 4.0.0-nightly.2020.1.9

dist/plugins/index.js

25

dist/dictionary/browsers.js

@@ -1,9 +0,18 @@

'use strict';
"use strict";
exports.__esModule = true;
var FF_2 = exports.FF_2 = 'firefox 2';
var IE_5_5 = exports.IE_5_5 = 'ie 5.5';
var IE_6 = exports.IE_6 = 'ie 6';
var IE_7 = exports.IE_7 = 'ie 7';
var IE_8 = exports.IE_8 = 'ie 8';
var OP_9 = exports.OP_9 = 'opera 9';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.OP_9 = exports.IE_8 = exports.IE_7 = exports.IE_6 = exports.IE_5_5 = exports.FF_2 = void 0;
const FF_2 = 'firefox 2';
exports.FF_2 = FF_2;
const IE_5_5 = 'ie 5.5';
exports.IE_5_5 = IE_5_5;
const IE_6 = 'ie 6';
exports.IE_6 = IE_6;
const IE_7 = 'ie 7';
exports.IE_7 = IE_7;
const IE_8 = 'ie 8';
exports.IE_8 = IE_8;
const OP_9 = 'opera 9';
exports.OP_9 = OP_9;

@@ -1,7 +0,14 @@

'use strict';
"use strict";
exports.__esModule = true;
var MEDIA_QUERY = exports.MEDIA_QUERY = 'media query';
var PROPERTY = exports.PROPERTY = 'property';
var SELECTOR = exports.SELECTOR = 'selector';
var VALUE = exports.VALUE = 'value';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.VALUE = exports.SELECTOR = exports.PROPERTY = exports.MEDIA_QUERY = void 0;
const MEDIA_QUERY = 'media query';
exports.MEDIA_QUERY = MEDIA_QUERY;
const PROPERTY = 'property';
exports.PROPERTY = PROPERTY;
const SELECTOR = 'selector';
exports.SELECTOR = SELECTOR;
const VALUE = 'value';
exports.VALUE = VALUE;

@@ -1,6 +0,12 @@

'use strict';
"use strict";
exports.__esModule = true;
var ATRULE = exports.ATRULE = 'atrule';
var DECL = exports.DECL = 'decl';
var RULE = exports.RULE = 'rule';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RULE = exports.DECL = exports.ATRULE = void 0;
const ATRULE = 'atrule';
exports.ATRULE = ATRULE;
const DECL = 'decl';
exports.DECL = DECL;
const RULE = 'rule';
exports.RULE = RULE;

@@ -1,5 +0,10 @@

'use strict';
"use strict";
exports.__esModule = true;
var BODY = exports.BODY = 'body';
var HTML = exports.HTML = 'html';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.HTML = exports.BODY = void 0;
const BODY = 'body';
exports.BODY = BODY;
const HTML = 'html';
exports.HTML = HTML;
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exists;
function exists(selector, index, value) {
var node = selector.at(index);
return node && node.value === value;
const node = selector.at(index);
return node && node.value && node.value.toLowerCase() === value;
}
module.exports = exports["default"];
module.exports = exports.default;

@@ -1,128 +0,63 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcss = require('postcss');
var _postcss = _interopRequireDefault(require("postcss"));
var _postcss2 = _interopRequireDefault(_postcss);
var _browserslist = _interopRequireDefault(require("browserslist"));
var _postcssReporter = require('postcss-reporter');
var _plugins = _interopRequireDefault(require("./plugins"));
var _postcssReporter2 = _interopRequireDefault(_postcssReporter);
var _browserslist = require('browserslist');
var _browserslist2 = _interopRequireDefault(_browserslist);
var _formatter = require('./formatter');
var _formatter2 = _interopRequireDefault(_formatter);
var _bodyEmpty = require('./plugins/bodyEmpty');
var _bodyEmpty2 = _interopRequireDefault(_bodyEmpty);
var _htmlCombinatorCommentBody = require('./plugins/htmlCombinatorCommentBody');
var _htmlCombinatorCommentBody2 = _interopRequireDefault(_htmlCombinatorCommentBody);
var _htmlFirstChild = require('./plugins/htmlFirstChild');
var _htmlFirstChild2 = _interopRequireDefault(_htmlFirstChild);
var _important = require('./plugins/important');
var _important2 = _interopRequireDefault(_important);
var _leadingStar = require('./plugins/leadingStar');
var _leadingStar2 = _interopRequireDefault(_leadingStar);
var _leadingUnderscore = require('./plugins/leadingUnderscore');
var _leadingUnderscore2 = _interopRequireDefault(_leadingUnderscore);
var _mediaSlash = require('./plugins/mediaSlash0');
var _mediaSlash2 = _interopRequireDefault(_mediaSlash);
var _mediaSlash3 = require('./plugins/mediaSlash9');
var _mediaSlash4 = _interopRequireDefault(_mediaSlash3);
var _slash = require('./plugins/slash9');
var _slash2 = _interopRequireDefault(_slash);
var _starHtml = require('./plugins/starHtml');
var _starHtml2 = _interopRequireDefault(_starHtml);
var _trailingSlashComma = require('./plugins/trailingSlashComma');
var _trailingSlashComma2 = _interopRequireDefault(_trailingSlashComma);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var plugins = [_bodyEmpty2.default, _htmlCombinatorCommentBody2.default, _htmlFirstChild2.default, _important2.default, _leadingStar2.default, _leadingUnderscore2.default, _mediaSlash2.default, _mediaSlash4.default, _slash2.default, _starHtml2.default, _trailingSlashComma2.default];
const stylehacks = _postcss.default.plugin('stylehacks', (opts = {}) => {
return (css, result) => {
const resultOpts = result.opts || {};
const browsers = (0, _browserslist.default)(null, {
stats: resultOpts.stats,
path: __dirname,
env: resultOpts.env
});
// plugins
const processors = _plugins.default.reduce((list, Plugin) => {
const hack = new Plugin(result);
const applied = browsers.some(browser => {
return hack.targets.some(target => browser === target);
});
if (applied) {
return list;
}
var stylehacks = _postcss2.default.plugin('stylehacks', function () {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return [...list, hack];
}, []);
var b = opts.browsers;
var browsers = b instanceof Array ? b : (0, _browserslist2.default)(b);
css.walk(node => {
processors.forEach(proc => {
if (!~proc.nodeTypes.indexOf(node.type)) {
return;
}
return function (css, result) {
var processors = plugins.reduce(function (list, Plugin) {
var hack = new Plugin(result);
var applied = browsers.some(function (browser) {
return hack.targets.some(function (target) {
return browser === target;
});
});
if (applied) {
return list;
}
return [].concat(list, [hack]);
}, []);
css.walk(function (node) {
processors.forEach(function (proc) {
if (!~proc.nodeTypes.indexOf(node.type)) {
return;
}
if (opts.lint) {
return proc.detectAndWarn(node);
}
return proc.detectAndResolve(node);
});
});
};
});
if (opts.lint) {
return proc.detectAndWarn(node);
}
stylehacks.detect = function (node) {
var hacked = plugins.some(function (Plugin) {
var hack = new Plugin();
return hack.any(node);
return proc.detectAndResolve(node);
});
});
};
});
return hacked;
stylehacks.detect = node => {
return _plugins.default.some(Plugin => {
const hack = new Plugin();
return hack.any(node);
});
};
stylehacks.process = function (css) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
opts.reporter = {};
opts.reporter.formatter = _formatter2.default;
opts.map = opts.map || (opts.sourcemap ? true : null);
var processor = (0, _postcss2.default)([stylehacks(opts)]);
if (opts.lint && !opts.silent) {
processor.use((0, _postcssReporter2.default)(opts.reporter));
}
return processor.process(css, opts);
};
exports.default = stylehacks;
module.exports = exports['default'];
var _default = stylehacks;
exports.default = _default;
module.exports = exports.default;

@@ -1,14 +0,20 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isMixin;
function isMixin(node) {
var selector = node.selector;
// If the selector ends with a ':' it is likely a part of a custom mixin.
const {
selector
} = node; // If the selector ends with a ':' it is likely a part of a custom mixin.
if (!selector || selector[selector.length - 1] === ':') {
return true;
}
return false;
if (!selector || selector[selector.length - 1] === ':') {
return true;
}
return false;
}
module.exports = exports['default'];
module.exports = exports.default;
"use strict";
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = plugin;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function plugin(targets, nodeTypes, detect) {
var Plugin = function () {
function Plugin(result) {
_classCallCheck(this, Plugin);
class Plugin {
constructor(result) {
this.nodes = [];
this.result = result;
this.targets = targets;
this.nodeTypes = nodeTypes;
}
this.nodes = [];
this.result = result;
this.targets = targets;
this.nodeTypes = nodeTypes;
}
push(node, metadata) {
node._stylehacks = Object.assign({}, metadata, {
message: `Bad ${metadata.identifier}: ${metadata.hack}`,
browsers: this.targets
});
this.nodes.push(node);
}
Plugin.prototype.push = function push(node, metadata) {
node._stylehacks = _extends({}, metadata, {
message: "Bad " + metadata.identifier + ": " + metadata.hack,
browsers: this.targets
});
this.nodes.push(node);
};
any(node) {
if (~this.nodeTypes.indexOf(node.type)) {
detect.apply(this, arguments);
return !!node._stylehacks;
}
Plugin.prototype.any = function any(node) {
if (~this.nodeTypes.indexOf(node.type)) {
detect.apply(this, arguments);
return !!node._stylehacks;
}
return false;
};
return false;
}
Plugin.prototype.detectAndResolve = function detectAndResolve() {
this.nodes = [];
detectAndResolve(...args) {
this.nodes = [];
detect.apply(this, args);
return this.resolve();
}
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
detectAndWarn(...args) {
this.nodes = [];
detect.apply(this, args);
return this.warn();
}
detect.apply(this, args);
return this.resolve();
};
resolve() {
return this.nodes.forEach(node => node.remove());
}
Plugin.prototype.detectAndWarn = function detectAndWarn() {
this.nodes = [];
warn() {
return this.nodes.forEach(node => {
const {
message,
browsers,
identifier,
hack
} = node._stylehacks;
return node.warn(this.result, message, {
browsers,
identifier,
hack
});
});
}
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
}
detect.apply(this, args);
return this.warn();
};
return Plugin;
}
Plugin.prototype.resolve = function resolve() {
return this.nodes.forEach(function (node) {
return node.remove();
});
};
Plugin.prototype.warn = function warn() {
var _this = this;
return this.nodes.forEach(function (node) {
var _node$_stylehacks = node._stylehacks,
message = _node$_stylehacks.message,
browsers = _node$_stylehacks.browsers,
identifier = _node$_stylehacks.identifier,
hack = _node$_stylehacks.hack;
return node.warn(_this.result, message, { browsers: browsers, identifier: identifier, hack: hack });
});
};
return Plugin;
}();
return Plugin;
}
module.exports = exports["default"];
module.exports = exports.default;

@@ -1,50 +0,48 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssSelectorParser = require('postcss-selector-parser');
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser);
var _exists = _interopRequireDefault(require("../exists"));
var _exists = require('../exists');
var _isMixin = _interopRequireDefault(require("../isMixin"));
var _exists2 = _interopRequireDefault(_exists);
var _plugin = _interopRequireDefault(require("../plugin"));
var _isMixin = require('../isMixin');
var _browsers = require("../dictionary/browsers");
var _isMixin2 = _interopRequireDefault(_isMixin);
var _identifiers = require("../dictionary/identifiers");
var _plugin = require('../plugin');
var _postcss = require("../dictionary/postcss");
var _plugin2 = _interopRequireDefault(_plugin);
var _tags = require("../dictionary/tags");
var _browsers = require('../dictionary/browsers');
var _identifiers = require('../dictionary/identifiers');
var _postcss = require('../dictionary/postcss');
var _tags = require('../dictionary/tags');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function analyse(ctx, rule) {
return function (selectors) {
selectors.each(function (selector) {
if ((0, _exists2.default)(selector, 0, _tags.BODY) && (0, _exists2.default)(selector, 1, ':empty') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
}
return selectors => {
selectors.each(selector => {
if ((0, _exists.default)(selector, 0, _tags.BODY) && (0, _exists.default)(selector, 1, ':empty') && (0, _exists.default)(selector, 2, ' ') && selector.at(3)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
};
}
});
};
}
exports.default = (0, _plugin2.default)([_browsers.FF_2], [_postcss.RULE], function (rule) {
if ((0, _isMixin2.default)(rule)) {
return;
}
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector);
var _default = (0, _plugin.default)([_browsers.FF_2], [_postcss.RULE], function (rule) {
if ((0, _isMixin.default)(rule)) {
return;
}
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.selector);
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,52 +0,50 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssSelectorParser = require('postcss-selector-parser');
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser);
var _exists = _interopRequireDefault(require("../exists"));
var _exists = require('../exists');
var _isMixin = _interopRequireDefault(require("../isMixin"));
var _exists2 = _interopRequireDefault(_exists);
var _plugin = _interopRequireDefault(require("../plugin"));
var _isMixin = require('../isMixin');
var _browsers = require("../dictionary/browsers");
var _isMixin2 = _interopRequireDefault(_isMixin);
var _identifiers = require("../dictionary/identifiers");
var _plugin = require('../plugin');
var _postcss = require("../dictionary/postcss");
var _plugin2 = _interopRequireDefault(_plugin);
var _tags = require("../dictionary/tags");
var _browsers = require('../dictionary/browsers');
var _identifiers = require('../dictionary/identifiers');
var _postcss = require('../dictionary/postcss');
var _tags = require('../dictionary/tags');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function analyse(ctx, rule) {
return function (selectors) {
selectors.each(function (selector) {
if ((0, _exists2.default)(selector, 0, _tags.HTML) && ((0, _exists2.default)(selector, 1, '>') || (0, _exists2.default)(selector, 1, '~')) && selector.at(2) && selector.at(2).type === 'comment' && (0, _exists2.default)(selector, 3, ' ') && (0, _exists2.default)(selector, 4, _tags.BODY) && (0, _exists2.default)(selector, 5, ' ') && selector.at(6)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
}
return selectors => {
selectors.each(selector => {
if ((0, _exists.default)(selector, 0, _tags.HTML) && ((0, _exists.default)(selector, 1, '>') || (0, _exists.default)(selector, 1, '~')) && selector.at(2) && selector.at(2).type === 'comment' && (0, _exists.default)(selector, 3, ' ') && (0, _exists.default)(selector, 4, _tags.BODY) && (0, _exists.default)(selector, 5, ' ') && selector.at(6)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
};
}
});
};
}
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) {
if ((0, _isMixin2.default)(rule)) {
return;
}
if (rule.raws.selector && rule.raws.selector.raw) {
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.raws.selector.raw);
}
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) {
if ((0, _isMixin.default)(rule)) {
return;
}
if (rule.raws.selector && rule.raws.selector.raw) {
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.raws.selector.raw);
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,50 +0,48 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssSelectorParser = require('postcss-selector-parser');
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser);
var _exists = _interopRequireDefault(require("../exists"));
var _exists = require('../exists');
var _isMixin = _interopRequireDefault(require("../isMixin"));
var _exists2 = _interopRequireDefault(_exists);
var _plugin = _interopRequireDefault(require("../plugin"));
var _isMixin = require('../isMixin');
var _browsers = require("../dictionary/browsers");
var _isMixin2 = _interopRequireDefault(_isMixin);
var _identifiers = require("../dictionary/identifiers");
var _plugin = require('../plugin');
var _postcss = require("../dictionary/postcss");
var _plugin2 = _interopRequireDefault(_plugin);
var _tags = require("../dictionary/tags");
var _browsers = require('../dictionary/browsers');
var _identifiers = require('../dictionary/identifiers');
var _postcss = require('../dictionary/postcss');
var _tags = require('../dictionary/tags');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function analyse(ctx, rule) {
return function (selectors) {
selectors.each(function (selector) {
if ((0, _exists2.default)(selector, 0, _tags.HTML) && (0, _exists2.default)(selector, 1, ':first-child') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
}
return selectors => {
selectors.each(selector => {
if ((0, _exists.default)(selector, 0, _tags.HTML) && (0, _exists.default)(selector, 1, ':first-child') && (0, _exists.default)(selector, 2, ' ') && selector.at(3)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
};
}
});
};
}
exports.default = (0, _plugin2.default)([_browsers.OP_9], [_postcss.RULE], function (rule) {
if ((0, _isMixin2.default)(rule)) {
return;
}
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector);
var _default = (0, _plugin.default)([_browsers.OP_9], [_postcss.RULE], function (rule) {
if ((0, _isMixin.default)(rule)) {
return;
}
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.selector);
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,25 +0,29 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _plugin = require('../plugin');
var _plugin = _interopRequireDefault(require("../plugin"));
var _plugin2 = _interopRequireDefault(_plugin);
var _browsers = require("../dictionary/browsers");
var _browsers = require('../dictionary/browsers');
var _postcss = require("../dictionary/postcss");
var _postcss = require('../dictionary/postcss');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.DECL], function (decl) {
var match = decl.value.match(/!\w/);
if (match) {
var hack = decl.value.substr(match.index, decl.value.length - 1);
this.push(decl, {
identifier: '!important',
hack: hack
});
}
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.DECL], function (decl) {
const match = decl.value.match(/!\w/);
if (match) {
const hack = decl.value.substr(match.index, decl.value.length - 1);
this.push(decl, {
identifier: '!important',
hack
});
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,61 +0,67 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _plugin = require('../plugin');
var _plugin = _interopRequireDefault(require("../plugin"));
var _plugin2 = _interopRequireDefault(_plugin);
var _browsers = require("../dictionary/browsers");
var _browsers = require('../dictionary/browsers');
var _identifiers = require("../dictionary/identifiers");
var _identifiers = require('../dictionary/identifiers');
var _postcss = require("../dictionary/postcss");
var _postcss = require('../dictionary/postcss');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var hacks = '!_$_&_*_)_=_%_+_,_._/_`_]_#_~_?_:_|'.split('_');
const hacks = '!_$_&_*_)_=_%_+_,_._/_`_]_#_~_?_:_|'.split('_');
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE, _postcss.DECL], function (node) {
var _this = this;
if (node.type === _postcss.DECL) {
// some values are not picked up by before, so ensure they are
// at the beginning of the value
hacks.some(function (hack) {
if (!node.prop.indexOf(hack)) {
_this.push(node, {
identifier: _identifiers.PROPERTY,
hack: node.prop
});
return true;
}
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE, _postcss.DECL], function (node) {
if (node.type === _postcss.DECL) {
// some values are not picked up by before, so ensure they are
// at the beginning of the value
hacks.some(hack => {
if (!node.prop.indexOf(hack)) {
this.push(node, {
identifier: _identifiers.PROPERTY,
hack: node.prop
});
var before = node.raws.before;
return true;
}
});
let {
before
} = node.raws;
if (!before) {
return;
}
hacks.some(function (hack) {
if (~before.indexOf(hack)) {
_this.push(node, {
identifier: _identifiers.PROPERTY,
hack: '' + before.trim() + node.prop
});
return true;
}
if (!before) {
return;
}
hacks.some(hack => {
if (~before.indexOf(hack)) {
this.push(node, {
identifier: _identifiers.PROPERTY,
hack: `${before.trim()}${node.prop}`
});
} else {
// test for the @property: value; hack
var name = node.name;
return true;
}
});
} else {
// test for the @property: value; hack
let {
name
} = node;
let len = name.length - 1;
var len = name.length - 1;
if (name.lastIndexOf(':') === len) {
this.push(node, {
identifier: _identifiers.PROPERTY,
hack: '@' + name.substr(0, len)
});
}
if (name.lastIndexOf(':') === len) {
this.push(node, {
identifier: _identifiers.PROPERTY,
hack: `@${name.substr(0, len)}`
});
}
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,30 +0,41 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _plugin = require('../plugin');
var _postcss = _interopRequireDefault(require("postcss"));
var _plugin2 = _interopRequireDefault(_plugin);
var _plugin = _interopRequireDefault(require("../plugin"));
var _browsers = require('../dictionary/browsers');
var _browsers = require("../dictionary/browsers");
var _identifiers = require('../dictionary/identifiers');
var _identifiers = require("../dictionary/identifiers");
var _postcss = require('../dictionary/postcss');
var _postcss2 = require("../dictionary/postcss");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _plugin2.default)([_browsers.IE_6], [_postcss.DECL], function (decl) {
var before = decl.raws.before;
var _default = (0, _plugin.default)([_browsers.IE_6], [_postcss2.DECL], function (decl) {
const {
before
} = decl.raws;
if (!before) {
return;
}
if (~before.indexOf('_') || ~before.indexOf('-')) {
this.push(decl, {
identifier: _identifiers.PROPERTY,
hack: '' + before.trim() + decl.prop
});
}
if (before && ~before.indexOf('_')) {
this.push(decl, {
identifier: _identifiers.PROPERTY,
hack: `${before.trim()}${decl.prop}`
});
}
if (decl.prop[0] === '-' && decl.prop[1] !== '-' && _postcss.default.vendor.prefix(decl.prop) === '') {
this.push(decl, {
identifier: _identifiers.PROPERTY,
hack: decl.prop
});
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,26 +0,30 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _plugin = require('../plugin');
var _plugin = _interopRequireDefault(require("../plugin"));
var _plugin2 = _interopRequireDefault(_plugin);
var _browsers = require("../dictionary/browsers");
var _browsers = require('../dictionary/browsers');
var _identifiers = require("../dictionary/identifiers");
var _identifiers = require('../dictionary/identifiers');
var _postcss = require("../dictionary/postcss");
var _postcss = require('../dictionary/postcss');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _plugin2.default)([_browsers.IE_8], [_postcss.ATRULE], function (rule) {
var params = rule.params.trim();
if (params === '\\0screen') {
this.push(rule, {
identifier: _identifiers.MEDIA_QUERY,
hack: params
});
}
var _default = (0, _plugin.default)([_browsers.IE_8], [_postcss.ATRULE], function (rule) {
const params = rule.params.trim();
if (params.toLowerCase() === '\\0screen') {
this.push(rule, {
identifier: _identifiers.MEDIA_QUERY,
hack: params
});
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,26 +0,30 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _plugin = require('../plugin');
var _plugin = _interopRequireDefault(require("../plugin"));
var _plugin2 = _interopRequireDefault(_plugin);
var _browsers = require("../dictionary/browsers");
var _browsers = require('../dictionary/browsers');
var _identifiers = require("../dictionary/identifiers");
var _identifiers = require('../dictionary/identifiers');
var _postcss = require("../dictionary/postcss");
var _postcss = require('../dictionary/postcss');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE], function (rule) {
var params = rule.params.trim();
if (params === 'screen\\9') {
this.push(rule, {
identifier: _identifiers.MEDIA_QUERY,
hack: params
});
}
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE], function (rule) {
const params = rule.params.trim();
if (params.toLowerCase() === 'screen\\9') {
this.push(rule, {
identifier: _identifiers.MEDIA_QUERY,
hack: params
});
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,26 +0,30 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _plugin = require('../plugin');
var _plugin = _interopRequireDefault(require("../plugin"));
var _plugin2 = _interopRequireDefault(_plugin);
var _browsers = require("../dictionary/browsers");
var _browsers = require('../dictionary/browsers');
var _identifiers = require("../dictionary/identifiers");
var _identifiers = require('../dictionary/identifiers');
var _postcss = require("../dictionary/postcss");
var _postcss = require('../dictionary/postcss');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _plugin2.default)([_browsers.IE_6, _browsers.IE_7, _browsers.IE_8], [_postcss.DECL], function (decl) {
var v = decl.value;
if (v && v.length > 2 && v.indexOf('\\9') === v.length - 2) {
this.push(decl, {
identifier: _identifiers.VALUE,
hack: v
});
}
var _default = (0, _plugin.default)([_browsers.IE_6, _browsers.IE_7, _browsers.IE_8], [_postcss.DECL], function (decl) {
let v = decl.value;
if (v && v.length > 2 && v.indexOf('\\9') === v.length - 2) {
this.push(decl, {
identifier: _identifiers.VALUE,
hack: v
});
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,50 +0,48 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssSelectorParser = require('postcss-selector-parser');
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser);
var _exists = _interopRequireDefault(require("../exists"));
var _exists = require('../exists');
var _isMixin = _interopRequireDefault(require("../isMixin"));
var _exists2 = _interopRequireDefault(_exists);
var _plugin = _interopRequireDefault(require("../plugin"));
var _isMixin = require('../isMixin');
var _browsers = require("../dictionary/browsers");
var _isMixin2 = _interopRequireDefault(_isMixin);
var _identifiers = require("../dictionary/identifiers");
var _plugin = require('../plugin');
var _postcss = require("../dictionary/postcss");
var _plugin2 = _interopRequireDefault(_plugin);
var _tags = require("../dictionary/tags");
var _browsers = require('../dictionary/browsers');
var _identifiers = require('../dictionary/identifiers');
var _postcss = require('../dictionary/postcss');
var _tags = require('../dictionary/tags');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function analyse(ctx, rule) {
return function (selectors) {
selectors.each(function (selector) {
if ((0, _exists2.default)(selector, 0, '*') && (0, _exists2.default)(selector, 1, ' ') && (0, _exists2.default)(selector, 2, _tags.HTML) && (0, _exists2.default)(selector, 3, ' ') && selector.at(4)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
}
return selectors => {
selectors.each(selector => {
if ((0, _exists.default)(selector, 0, '*') && (0, _exists.default)(selector, 1, ' ') && (0, _exists.default)(selector, 2, _tags.HTML) && (0, _exists.default)(selector, 3, ' ') && selector.at(4)) {
ctx.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector.toString()
});
};
}
});
};
}
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6], [_postcss.RULE], function (rule) {
if ((0, _isMixin2.default)(rule)) {
return;
}
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector);
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6], [_postcss.RULE], function (rule) {
if ((0, _isMixin.default)(rule)) {
return;
}
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.selector);
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;

@@ -1,35 +0,39 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _plugin = require('../plugin');
var _plugin = _interopRequireDefault(require("../plugin"));
var _plugin2 = _interopRequireDefault(_plugin);
var _isMixin = _interopRequireDefault(require("../isMixin"));
var _isMixin = require('../isMixin');
var _browsers = require("../dictionary/browsers");
var _isMixin2 = _interopRequireDefault(_isMixin);
var _identifiers = require("../dictionary/identifiers");
var _browsers = require('../dictionary/browsers');
var _postcss = require("../dictionary/postcss");
var _identifiers = require('../dictionary/identifiers');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _postcss = require('../dictionary/postcss');
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) {
if ((0, _isMixin.default)(rule)) {
return;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const {
selector
} = rule;
const trim = selector.trim();
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) {
if ((0, _isMixin2.default)(rule)) {
return;
}
var selector = rule.selector;
if (trim.lastIndexOf(',') === selector.length - 1 || trim.lastIndexOf('\\') === selector.length - 1) {
this.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector
});
}
});
var trim = selector.trim();
if (trim.lastIndexOf(',') === selector.length - 1 || trim.lastIndexOf('\\') === selector.length - 1) {
this.push(rule, {
identifier: _identifiers.SELECTOR,
hack: selector
});
}
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;
{
"name": "stylehacks",
"version": "2.3.2",
"version": "4.0.0-nightly.2020.1.9",
"description": "Detect/remove browser hacks from CSS files.",
"main": "dist/index.js",
"bin": {
"stylehacks": "dist/cli.js"
},
"files": [
"LICENSE-MIT",
"dist",
"usage.txt"
"dist"
],
"scripts": {
"pretest": "eslint src",
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"report": "nyc report --reporter=html",
"test": "nyc ava src/__tests__",
"test-012": "nyc ava src/__tests__"
"prebuild": "",
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
"prepublish": ""
},

@@ -32,19 +26,3 @@ "keywords": [

"license": "MIT",
"devDependencies": {
"ava": "^0.17.0",
"babel-cli": "^6.5.1",
"babel-core": "^6.5.2",
"babel-plugin-add-module-exports": "^0.2.0",
"babel-preset-es2015": "^6.5.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"del-cli": "^0.2.0",
"eslint": "^3.0.0",
"eslint-config-cssnano": "^3.0.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.0.1",
"nyc": "^10.0.0"
},
"homepage": "https://github.com/ben-eb/stylehacks",
"homepage": "https://github.com/cssnano/cssnano",
"author": {

@@ -55,29 +33,14 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/stylehacks",
"repository": "cssnano/cssnano",
"dependencies": {
"browserslist": "^1.1.3",
"chalk": "^1.1.1",
"log-symbols": "^1.0.2",
"minimist": "^1.2.0",
"plur": "^2.1.2",
"postcss": "^5.0.18",
"postcss-reporter": "^1.3.3",
"postcss-selector-parser": "^2.0.0",
"read-file-stdin": "^0.2.1",
"text-table": "^0.2.0",
"write-file-stdout": "0.0.2"
"browserslist": "^4.6.0",
"postcss": "^7.0.16",
"postcss-selector-parser": "^3.1.1"
},
"eslintConfig": {
"extends": "cssnano"
"bugs": {
"url": "https://github.com/cssnano/cssnano/issues"
},
"ava": {
"require": "babel-register"
},
"nyc": {
"exclude": [
"dist",
"node_modules",
"src/__tests__"
]
"engines": {
"node": ">=10.13.0"
}
}
}

@@ -1,2 +0,2 @@

# 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]
# stylehacks

@@ -59,11 +59,2 @@ > Detect/remove browser hacks from CSS files.

##### browsers
Type: `string|array`
Default: [browserslist defaults](https://github.com/ai/browserslist)
Specify the browsers that you wish to support. The string will be passed
directly to browserslist and parsed, however if an array is passed instead then
stylehacks will use it instead of parsing the browsers itself.
##### lint

@@ -75,20 +66,5 @@

If lint mode is enabled, stylehacks will not remove hacks from the CSS; instead,
it will warn that hacks were found. When using stylehacks as a PostCSS plugin,
you are expected to handle these messages yourself.
it will add warnings to `Result#messages`.
##### silent
Type: `boolean`
Default: `false`
Used in combination with the lint option; disables all logging. When using the
CLI, the process will exit with 0 or 1 as usual.
##### sourcemap
Type: `boolean`
Default: `false`
Generate a sourcemap with the transformed CSS.
### `postcss([ stylehacks(opts) ])`

@@ -100,11 +76,3 @@

### CLI
stylehacks also ships with a CLI app. To see the available options, just run:
```sh
$ stylehacks --help
```
## Related

@@ -129,6 +97,2 @@

[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