stylehacks
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -0,1 +1,14 @@ | ||
# 2.3.0 | ||
* Each warning now contains more information about the hack; what identifier | ||
it targets, what the hack is, and the browsers that it affects. E.g: | ||
```js | ||
{ | ||
browsers: [ 'ie 6', 'ie 5.5' ], | ||
identifier: 'selector', | ||
hack: '* html h1' | ||
} | ||
``` | ||
# 2.2.0 | ||
@@ -2,0 +15,0 @@ |
@@ -1,8 +0,5 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports['default'] = exists; | ||
exports.__esModule = true; | ||
exports.default = exists; | ||
function exists(selector, index, value) { | ||
@@ -12,3 +9,2 @@ var node = selector.at(index); | ||
} | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _chalk = require('chalk'); | ||
@@ -29,2 +25,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var logFrom = function logFrom(fromValue) { | ||
@@ -34,11 +32,11 @@ if (!fromValue.indexOf('<')) { | ||
} | ||
return _path2['default'].relative(process.cwd(), fromValue); | ||
return _path2.default.relative(process.cwd(), fromValue); | ||
}; | ||
var hacksFound = function hacksFound(messages) { | ||
var num = messages.length + (0, _plur2['default'])(' hack', messages.length); | ||
return '\n\n ' + _logSymbols2['default'].error + ' ' + num + ' found.\n'; | ||
var num = messages.length + (0, _plur2.default)(' hack', messages.length); | ||
return '\n\n ' + _logSymbols2.default.error + ' ' + num + ' found.\n'; | ||
}; | ||
exports['default'] = function (input) { | ||
exports.default = function (input) { | ||
var messages = input.messages; | ||
@@ -48,8 +46,8 @@ var source = input.source; | ||
if (!messages.length) { | ||
return ' ' + _logSymbols2['default'].success + ' No hacks found.'; | ||
return ' ' + _logSymbols2.default.success + ' No hacks found.'; | ||
} | ||
return _chalk2['default'].underline(logFrom(source)) + '\n' + (0, _textTable2['default'])(messages.map(function (msg) { | ||
return _chalk2.default.underline(logFrom(source)) + '\n' + (0, _textTable2.default)(messages.map(function (msg) { | ||
var parts = msg.text.split(': '); | ||
return ['', _chalk2['default'].gray('line ' + msg.node.source.start.line), _chalk2['default'].gray('col ' + msg.node.source.start.column), parts[0], _chalk2['default'].red(parts[1])]; | ||
return ['', _chalk2.default.gray('line ' + msg.node.source.start.line), _chalk2.default.gray('col ' + msg.node.source.start.column), parts[0], _chalk2.default.red(parts[1])]; | ||
})) + hacksFound(messages); | ||
@@ -56,0 +54,0 @@ }; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _postcss = require('postcss'); | ||
@@ -25,55 +21,58 @@ | ||
// plugins | ||
var _bodyEmpty = require('./plugins/bodyEmpty'); | ||
var _pluginsBodyEmpty = require('./plugins/bodyEmpty'); | ||
var _bodyEmpty2 = _interopRequireDefault(_bodyEmpty); | ||
var _pluginsBodyEmpty2 = _interopRequireDefault(_pluginsBodyEmpty); | ||
var _htmlCombinatorCommentBody = require('./plugins/htmlCombinatorCommentBody'); | ||
var _pluginsHtmlCombinatorCommentBody = require('./plugins/htmlCombinatorCommentBody'); | ||
var _htmlCombinatorCommentBody2 = _interopRequireDefault(_htmlCombinatorCommentBody); | ||
var _pluginsHtmlCombinatorCommentBody2 = _interopRequireDefault(_pluginsHtmlCombinatorCommentBody); | ||
var _htmlFirstChild = require('./plugins/htmlFirstChild'); | ||
var _pluginsHtmlFirstChild = require('./plugins/htmlFirstChild'); | ||
var _htmlFirstChild2 = _interopRequireDefault(_htmlFirstChild); | ||
var _pluginsHtmlFirstChild2 = _interopRequireDefault(_pluginsHtmlFirstChild); | ||
var _important = require('./plugins/important'); | ||
var _pluginsImportant = require('./plugins/important'); | ||
var _important2 = _interopRequireDefault(_important); | ||
var _pluginsImportant2 = _interopRequireDefault(_pluginsImportant); | ||
var _leadingStar = require('./plugins/leadingStar'); | ||
var _pluginsLeadingStar = require('./plugins/leadingStar'); | ||
var _leadingStar2 = _interopRequireDefault(_leadingStar); | ||
var _pluginsLeadingStar2 = _interopRequireDefault(_pluginsLeadingStar); | ||
var _leadingUnderscore = require('./plugins/leadingUnderscore'); | ||
var _pluginsLeadingUnderscore = require('./plugins/leadingUnderscore'); | ||
var _leadingUnderscore2 = _interopRequireDefault(_leadingUnderscore); | ||
var _pluginsLeadingUnderscore2 = _interopRequireDefault(_pluginsLeadingUnderscore); | ||
var _mediaSlash = require('./plugins/mediaSlash0'); | ||
var _pluginsMediaSlash0 = require('./plugins/mediaSlash0'); | ||
var _mediaSlash2 = _interopRequireDefault(_mediaSlash); | ||
var _pluginsMediaSlash02 = _interopRequireDefault(_pluginsMediaSlash0); | ||
var _mediaSlash3 = require('./plugins/mediaSlash9'); | ||
var _pluginsMediaSlash9 = require('./plugins/mediaSlash9'); | ||
var _mediaSlash4 = _interopRequireDefault(_mediaSlash3); | ||
var _pluginsMediaSlash92 = _interopRequireDefault(_pluginsMediaSlash9); | ||
var _slash = require('./plugins/slash9'); | ||
var _pluginsSlash9 = require('./plugins/slash9'); | ||
var _slash2 = _interopRequireDefault(_slash); | ||
var _pluginsSlash92 = _interopRequireDefault(_pluginsSlash9); | ||
var _starHtml = require('./plugins/starHtml'); | ||
var _pluginsStarHtml = require('./plugins/starHtml'); | ||
var _starHtml2 = _interopRequireDefault(_starHtml); | ||
var _pluginsStarHtml2 = _interopRequireDefault(_pluginsStarHtml); | ||
var _trailingSlashComma = require('./plugins/trailingSlashComma'); | ||
var _pluginsTrailingSlashComma = require('./plugins/trailingSlashComma'); | ||
var _trailingSlashComma2 = _interopRequireDefault(_trailingSlashComma); | ||
var _pluginsTrailingSlashComma2 = _interopRequireDefault(_pluginsTrailingSlashComma); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var plugins = [_pluginsBodyEmpty2['default'], _pluginsHtmlCombinatorCommentBody2['default'], _pluginsHtmlFirstChild2['default'], _pluginsImportant2['default'], _pluginsLeadingStar2['default'], _pluginsLeadingUnderscore2['default'], _pluginsMediaSlash02['default'], _pluginsMediaSlash92['default'], _pluginsSlash92['default'], _pluginsStarHtml2['default'], _pluginsTrailingSlashComma2['default']]; | ||
var plugins = [_bodyEmpty2.default, _htmlCombinatorCommentBody2.default, _htmlFirstChild2.default, _important2.default, _leadingStar2.default, _leadingUnderscore2.default, _mediaSlash2.default, _mediaSlash4.default, _slash2.default, _starHtml2.default, _trailingSlashComma2.default]; | ||
var stylehacks = _postcss2['default'].plugin('stylehacks', function () { | ||
// plugins | ||
var stylehacks = _postcss2.default.plugin('stylehacks', function () { | ||
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var b = opts.browsers; | ||
var browsers = b instanceof Array ? b : (0, _browserslist2['default'])(b); | ||
var browsers = b instanceof Array ? b : (0, _browserslist2.default)(b); | ||
@@ -112,7 +111,7 @@ return function (css, result) { | ||
opts.reporter = {}; | ||
opts.reporter.formatter = _formatter2['default']; | ||
opts.reporter.formatter = _formatter2.default; | ||
opts.map = opts.map || (opts.sourcemap ? true : null); | ||
var processor = (0, _postcss2['default'])([stylehacks(opts)]); | ||
var processor = (0, _postcss2.default)([stylehacks(opts)]); | ||
if (opts.lint && !opts.silent) { | ||
processor.use((0, _postcssReporter2['default'])(opts.reporter)); | ||
processor.use((0, _postcssReporter2.default)(opts.reporter)); | ||
} | ||
@@ -122,3 +121,3 @@ return processor.process(css, opts); | ||
exports['default'] = stylehacks; | ||
exports.default = stylehacks; | ||
module.exports = exports['default']; |
@@ -1,15 +0,9 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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 () { | ||
var Plugin = function () { | ||
function Plugin(css, result) { | ||
@@ -25,65 +19,64 @@ _classCallCheck(this, Plugin); | ||
_createClass(Plugin, [{ | ||
key: 'push', | ||
value: function push(node, message) { | ||
node._stylehacks = message; | ||
this.nodes.push(node); | ||
Plugin.prototype.push = function push(node, metadata) { | ||
metadata.message = "Bad " + metadata.identifier + ": " + metadata.hack; | ||
metadata.browsers = this.targets; | ||
node._stylehacks = metadata; | ||
this.nodes.push(node); | ||
}; | ||
Plugin.prototype.any = function any(node) { | ||
var hasHack = false; | ||
if (~this.nodeTypes.indexOf(node.type)) { | ||
_detect.apply(this, arguments); | ||
if (node._stylehacks) { | ||
hasHack = true; | ||
} | ||
} | ||
}, { | ||
key: 'any', | ||
value: function any(node) { | ||
var hasHack = false; | ||
return hasHack; | ||
}; | ||
Plugin.prototype.detect = function detect() { | ||
this.css.walk(function (node) { | ||
if (~this.nodeTypes.indexOf(node.type)) { | ||
_detect.apply(this, arguments); | ||
if (node._stylehacks) { | ||
hasHack = true; | ||
} | ||
} | ||
return hasHack; | ||
} | ||
}, { | ||
key: 'detect', | ||
value: function detect() { | ||
this.css.walk((function (node) { | ||
if (~this.nodeTypes.indexOf(node.type)) { | ||
_detect.apply(this, arguments); | ||
} | ||
}).bind(this)); | ||
} | ||
}, { | ||
key: 'detectAndResolve', | ||
value: function detectAndResolve() { | ||
this.detect(); | ||
return this.resolve(); | ||
} | ||
}, { | ||
key: 'detectAndWarn', | ||
value: function detectAndWarn() { | ||
this.detect(); | ||
return this.warn(); | ||
} | ||
}, { | ||
key: 'resolve', | ||
value: function resolve() { | ||
return this.nodes.forEach(function (node) { | ||
return node.remove(); | ||
}); | ||
} | ||
}, { | ||
key: 'warn', | ||
value: function warn() { | ||
var _this = this; | ||
}.bind(this)); | ||
}; | ||
return this.nodes.forEach(function (node) { | ||
return _this.result.warn(node._stylehacks, { node: node }); | ||
}); | ||
} | ||
}]); | ||
Plugin.prototype.detectAndResolve = function detectAndResolve() { | ||
this.detect(); | ||
return this.resolve(); | ||
}; | ||
Plugin.prototype.detectAndWarn = function detectAndWarn() { | ||
this.detect(); | ||
return this.warn(); | ||
}; | ||
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; | ||
var message = _node$_stylehacks.message; | ||
var browsers = _node$_stylehacks.browsers; | ||
var identifier = _node$_stylehacks.identifier; | ||
var hack = _node$_stylehacks.hack; | ||
return node.warn(_this.result, message, { browsers: browsers, identifier: identifier, hack: hack }); | ||
}); | ||
}; | ||
return Plugin; | ||
})(); | ||
}(); | ||
return Plugin; | ||
} | ||
exports.default = plugin; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _exists = require('../exists'); | ||
@@ -21,2 +17,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['firefox 2']; | ||
@@ -27,4 +25,7 @@ | ||
selectors.each(function (selector) { | ||
if ((0, _exists2['default'])(selector, 0, 'body') && (0, _exists2['default'])(selector, 1, ':empty') && (0, _exists2['default'])(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, 'Bad selector: ' + selector); | ||
if ((0, _exists2.default)(selector, 0, 'body') && (0, _exists2.default)(selector, 1, ':empty') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, { | ||
identifier: 'selector', | ||
hack: selector.toString() | ||
}); | ||
} | ||
@@ -35,7 +36,7 @@ }); | ||
exports['default'] = (0, _plugin2['default'])(targets, ['rule'], function (rule) { | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
(0, _postcssSelectorParser2['default'])(analyse(this, rule)).process(rule.selector); | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _exists = require('../exists'); | ||
@@ -21,2 +17,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 7', 'ie 6', 'ie 5.5']; | ||
@@ -27,4 +25,7 @@ | ||
selectors.each(function (selector) { | ||
if ((0, _exists2['default'])(selector, 0, '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, 'body') && (0, _exists2['default'])(selector, 5, ' ') && selector.at(6)) { | ||
ctx.push(rule, 'Bad selector: ' + selector); | ||
if ((0, _exists2.default)(selector, 0, '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, 'body') && (0, _exists2.default)(selector, 5, ' ') && selector.at(6)) { | ||
ctx.push(rule, { | ||
identifier: 'selector', | ||
hack: selector.toString() | ||
}); | ||
} | ||
@@ -35,7 +36,7 @@ }); | ||
exports['default'] = (0, _plugin2['default'])(targets, ['rule'], function (rule) { | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector && rule.raws.selector && rule.raws.selector.raw) { | ||
(0, _postcssSelectorParser2['default'])(analyse(this, rule)).process(rule.raws.selector.raw); | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.raws.selector.raw); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _exists = require('../exists'); | ||
@@ -21,2 +17,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['opera 9']; | ||
@@ -27,4 +25,7 @@ | ||
selectors.each(function (selector) { | ||
if ((0, _exists2['default'])(selector, 0, 'html') && (0, _exists2['default'])(selector, 1, ':first-child') && (0, _exists2['default'])(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, 'Bad selector: ' + selector); | ||
if ((0, _exists2.default)(selector, 0, 'html') && (0, _exists2.default)(selector, 1, ':first-child') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, { | ||
identifier: 'selector', | ||
hack: selector.toString() | ||
}); | ||
} | ||
@@ -35,7 +36,7 @@ }); | ||
exports['default'] = (0, _plugin2['default'])(targets, ['rule'], function (rule) { | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
(0, _postcssSelectorParser2['default'])(analyse(this, rule)).process(rule.selector); | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _plugin = require('../plugin'); | ||
@@ -13,11 +9,16 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 5.5', 'ie 6', 'ie 7']; | ||
exports['default'] = (0, _plugin2['default'])(targets, ['decl'], function (decl) { | ||
exports.default = (0, _plugin2.default)(targets, ['decl'], function (decl) { | ||
var match = decl.value.match(/!\w/); | ||
if (match) { | ||
var text = decl.value.substr(match.index, decl.value.length - 1); | ||
this.push(decl, 'Bad !important: ' + text); | ||
this.push(decl, { | ||
identifier: '!important', | ||
hack: text | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
@@ -13,9 +11,11 @@ var _plugin = require('../plugin'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 5.5', 'ie 6', 'ie 7']; | ||
exports['default'] = (0, _plugin2['default'])(targets, ['decl', 'atrule'], function (node) { | ||
exports.default = (0, _plugin2.default)(targets, ['decl', 'atrule'], function (node) { | ||
var _this = this; | ||
if (node.type === 'decl') { | ||
var _ret = (function () { | ||
var _ret = function () { | ||
var before = node.raws.before; | ||
@@ -30,3 +30,6 @@ if (!before) { | ||
if (~before.indexOf(hack)) { | ||
_this.push(node, 'Bad property: ' + before.trim() + node.prop); | ||
_this.push(node, { | ||
identifier: 'property', | ||
hack: '' + before.trim() + node.prop | ||
}); | ||
return true; | ||
@@ -40,3 +43,6 @@ } | ||
if (!node.prop.indexOf(hack)) { | ||
_this.push(node, 'Bad property: ' + node.prop); | ||
_this.push(node, { | ||
identifier: 'property', | ||
hack: node.prop | ||
}); | ||
return true; | ||
@@ -46,12 +52,15 @@ } | ||
} | ||
})(); | ||
}(); | ||
if (typeof _ret === 'object') return _ret.v; | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
} | ||
if (node.type === 'atrule') { | ||
// test for the @property: value; hack | ||
var _name = node.name; | ||
var len = _name.length - 1; | ||
if (_name.lastIndexOf(':') === len) { | ||
this.push(node, 'Bad property: @' + _name.substr(0, len)); | ||
var name = node.name; | ||
var len = name.length - 1; | ||
if (name.lastIndexOf(':') === len) { | ||
this.push(node, { | ||
identifier: 'property', | ||
hack: '@' + name.substr(0, len) | ||
}); | ||
} | ||
@@ -58,0 +67,0 @@ } |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _plugin = require('../plugin'); | ||
@@ -13,5 +9,7 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 6']; | ||
exports['default'] = (0, _plugin2['default'])(targets, ['decl'], function (decl) { | ||
exports.default = (0, _plugin2.default)(targets, ['decl'], function (decl) { | ||
var before = decl.raws.before; | ||
@@ -22,5 +20,8 @@ if (!before) { | ||
if (~before.indexOf('_') || ~before.indexOf('-')) { | ||
this.push(decl, 'Bad property: ' + before.trim() + decl.prop); | ||
this.push(decl, { | ||
identifier: 'property', | ||
hack: '' + before.trim() + decl.prop | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _plugin = require('../plugin'); | ||
@@ -13,10 +9,15 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 8']; | ||
exports['default'] = (0, _plugin2['default'])(targets, ['atrule'], function (rule) { | ||
exports.default = (0, _plugin2.default)(targets, ['atrule'], function (rule) { | ||
var params = rule.params.trim(); | ||
if (params === '\\0screen') { | ||
this.push(rule, 'Bad media query: ' + params); | ||
this.push(rule, { | ||
identifier: 'media query', | ||
hack: params | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _plugin = require('../plugin'); | ||
@@ -13,10 +9,15 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 5.5', 'ie 6', 'ie 7']; | ||
exports['default'] = (0, _plugin2['default'])(targets, ['atrule'], function (rule) { | ||
exports.default = (0, _plugin2.default)(targets, ['atrule'], function (rule) { | ||
var params = rule.params.trim(); | ||
if (params === 'screen\\9') { | ||
this.push(rule, 'Bad media query: ' + params); | ||
this.push(rule, { | ||
identifier: 'media query', | ||
hack: params | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _plugin = require('../plugin'); | ||
@@ -13,10 +9,15 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 8', 'ie 7', 'ie 6']; | ||
exports['default'] = (0, _plugin2['default'])(targets, ['decl'], function (decl) { | ||
exports.default = (0, _plugin2.default)(targets, ['decl'], function (decl) { | ||
var v = decl.value; | ||
if (v && v.length > 2 && v.indexOf('\\9') === v.length - 2) { | ||
this.push(decl, 'Bad value: ' + v); | ||
this.push(decl, { | ||
identifier: 'value', | ||
hack: v | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _exists = require('../exists'); | ||
@@ -21,2 +17,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 6', 'ie 5.5']; | ||
@@ -27,4 +25,7 @@ | ||
selectors.each(function (selector) { | ||
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); | ||
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, { | ||
identifier: 'selector', | ||
hack: selector.toString() | ||
}); | ||
} | ||
@@ -35,7 +36,7 @@ }); | ||
exports['default'] = (0, _plugin2['default'])(targets, ['rule'], function (rule) { | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
(0, _postcssSelectorParser2['default'])(analyse(this, rule)).process(rule.selector); | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
} | ||
}); | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _plugin = require('../plugin'); | ||
@@ -13,9 +9,16 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 7', 'ie 6', 'ie 5.5']; | ||
exports['default'] = (0, _plugin2['default'])(targets, ['rule'], function (rule) { | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
var sel = rule.selector; | ||
if (sel.trim().lastIndexOf(',') === sel.length - 1 || sel.trim().lastIndexOf('\\') === sel.length - 1) { | ||
this.push(rule, 'Bad selector: ' + sel); | ||
var selector = rule.selector; | ||
var trim = selector.trim(); | ||
if (trim.lastIndexOf(',') === selector.length - 1 || trim.lastIndexOf('\\') === selector.length - 1) { | ||
this.push(rule, { | ||
identifier: 'selector', | ||
hack: selector | ||
}); | ||
} | ||
@@ -22,0 +25,0 @@ } |
{ | ||
"name": "stylehacks", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Detect/remove browser hacks from CSS files.", | ||
"main": "dist/index.js", | ||
"bin": { | ||
"stylehacks": "bin/cmd.js" | ||
"stylehacks": "dist/cli.js" | ||
}, | ||
"files": [ | ||
"bin", | ||
"LICENSE-MIT", | ||
"dist" | ||
"dist", | ||
"usage.txt" | ||
], | ||
"scripts": { | ||
"prepublish": "babel src --out-dir dist --ignore /__tests__/", | ||
"test-unformatted": "babel-tape-runner \"src/**/__tests__/*.js\"", | ||
"test": "npm run test-unformatted | tap-spec" | ||
"pretest": "eslint src", | ||
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/", | ||
"test": "npm run prepublish && ava src/__tests__" | ||
}, | ||
@@ -31,6 +31,12 @@ "keywords": [ | ||
"devDependencies": { | ||
"babel": "^5.8.23", | ||
"babel-tape-runner": "^1.2.0", | ||
"tap-spec": "^4.1.0", | ||
"tape": "^4.2.0" | ||
"ava": "^0.12.0", | ||
"babel-cli": "^6.5.1", | ||
"babel-core": "^6.5.2", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-preset-es2015": "^6.5.0", | ||
"babel-preset-es2015-loose": "^7.0.0", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"del-cli": "^0.2.0", | ||
"eslint": "^2.2.0", | ||
"eslint-config-cssnano": "^2.0.0" | ||
}, | ||
@@ -45,14 +51,20 @@ "homepage": "https://github.com/ben-eb/stylehacks", | ||
"dependencies": { | ||
"browserslist": "^1.0.0", | ||
"browserslist": "^1.1.3", | ||
"chalk": "^1.1.1", | ||
"log-symbols": "^1.0.2", | ||
"minimist": "^1.2.0", | ||
"plur": "^2.0.0", | ||
"postcss": "^5.0.5", | ||
"postcss-reporter": "^1.2.1", | ||
"postcss-selector-parser": "^1.2.0", | ||
"read-file-stdin": "^0.2.0", | ||
"plur": "^2.1.2", | ||
"postcss": "^5.0.18", | ||
"postcss-reporter": "^1.3.3", | ||
"postcss-selector-parser": "^1.3.2", | ||
"read-file-stdin": "^0.2.1", | ||
"text-table": "^0.2.0", | ||
"write-file-stdout": "0.0.2" | ||
}, | ||
"eslintConfig": { | ||
"extends": "cssnano" | ||
}, | ||
"ava": { | ||
"require": "babel-core/register" | ||
} | ||
} |
@@ -5,2 +5,3 @@ # 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] | ||
## Install | ||
@@ -14,2 +15,3 @@ | ||
## Example | ||
@@ -37,2 +39,3 @@ | ||
## API | ||
@@ -42,3 +45,3 @@ | ||
Type: `function` | ||
Type: `function` | ||
Returns: `boolean` | ||
@@ -62,3 +65,3 @@ | ||
Type: `string|array` | ||
Type: `string|array` | ||
Default: [browserslist defaults](https://github.com/ai/browserslist) | ||
@@ -72,3 +75,3 @@ | ||
Type: `boolean` | ||
Type: `boolean` | ||
Default: `false` | ||
@@ -82,3 +85,3 @@ | ||
Type: `boolean` | ||
Type: `boolean` | ||
Default: `false` | ||
@@ -91,3 +94,3 @@ | ||
Type: `boolean` | ||
Type: `boolean` | ||
Default: `false` | ||
@@ -111,2 +114,3 @@ | ||
## Related | ||
@@ -119,2 +123,3 @@ | ||
## Contributing | ||
@@ -125,2 +130,3 @@ | ||
## License | ||
@@ -130,2 +136,3 @@ | ||
[ci]: https://travis-ci.org/ben-eb/stylehacks | ||
@@ -132,0 +139,0 @@ [deps]: https://gemnasium.com/ben-eb/stylehacks |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27774
499
131
10
1
Updatedbrowserslist@^1.1.3
Updatedplur@^2.1.2
Updatedpostcss@^5.0.18
Updatedpostcss-reporter@^1.3.3
Updatedread-file-stdin@^0.2.1