analyze-css
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -9,2 +9,3 @@ /** | ||
fs = require('fs'), | ||
path = require('path'), | ||
preprocessors = new(require('./preprocessors'))(), | ||
@@ -70,2 +71,6 @@ slickParse = require('slick').parse, | ||
// @see https://github.com/macbre/phantomas/issues/664 | ||
analyzer.path = path.normalize(__dirname + '/..'); | ||
analyzer.pathBin = analyzer.path + '/bin/analyze-css.js'; | ||
// exit codes | ||
@@ -72,0 +77,0 @@ analyzer.EXIT_NEED_OPTIONS = 2; |
{ | ||
"name": "analyze-css", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"author": "Maciej Brencz <maciej.brencz@gmail.com> (https://github.com/macbre)", | ||
@@ -23,3 +23,3 @@ "description": "CSS selectors complexity and performance analyzer", | ||
"dependencies": { | ||
"cli": "^0.11.3", | ||
"cli": "^1.0.0", | ||
"css": "2.2.x", | ||
@@ -31,3 +31,3 @@ "css-shorthand-properties": "1.0.x", | ||
"http-proxy-agent": "^1.0.0", | ||
"node-fetch": "^1.6.0", | ||
"node-fetch": "^1.6.1", | ||
"onecolor": "^3.0.4", | ||
@@ -34,0 +34,0 @@ "optimist": "0.6.x", |
@@ -44,3 +44,3 @@ analyze-css | ||
HTTP proxy can be provided via: | ||
HTTP proxy (e.g. `http://localhost:8080`) can be provided via: | ||
@@ -96,3 +96,2 @@ * `--proxy` or `-x` option | ||
"complexSelectors": 37, | ||
"complexSelectorsByAttribute": 3, | ||
"duplicatedSelectors": 7, | ||
@@ -125,3 +124,2 @@ "duplicatedProperties": 24, | ||
"selectorsByTag": 533, | ||
"universalSelectors": 5, | ||
"length": 55173, | ||
@@ -148,3 +146,2 @@ "rules": 433, | ||
* **complexSelectors**: number of complex selectors (consisting of more than three expressions, e.g. ``header ul li .foo``) | ||
* **complexSelectorsByAttribute**: number of selectors with complex matching by attribute (e.g. ``[class$="foo"]``) | ||
* **duplicatedSelectors**: number of CSS selectors defined more than once in CSS source | ||
@@ -177,3 +174,2 @@ * **duplicatedProperties**: number of CSS property definitions duplicated within a selector | ||
* **selectorsByTag**: number of selectors by tag name | ||
* **universalSelectors**: number of selectors trying to match every element (e.g. ``.foo > *``) | ||
* **length**: length of CSS source (in bytes) | ||
@@ -180,0 +176,0 @@ * **rules**: number of rules (e.g. ``.foo, .bar { color: red }`` is counted as one rule) |
@@ -7,3 +7,2 @@ 'use strict'; | ||
analyzer.setMetric('complexSelectors'); | ||
analyzer.setMetric('complexSelectorsByAttribute'); | ||
@@ -17,22 +16,2 @@ // #foo .bar ul li a | ||
}); | ||
// .foo[type*=bar] | ||
// @see http://www.w3.org/TR/css3-selectors/#attribute-selectors | ||
analyzer.on('expression', function(selector, expression) { | ||
if (typeof expression.attributes !== 'undefined') { | ||
switch (expression.attributes[0].operator) { | ||
case '=': | ||
break; | ||
case '~=': // contains value in a whitespace-separated list of words | ||
case '|=': // starts with value or value- | ||
case '^=': // starts with | ||
case '$=': // ends with | ||
case '*=': // contains | ||
analyzer.incrMetric('complexSelectorsByAttribute'); | ||
analyzer.addOffender('complexSelectorsByAttribute', selector); | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
@@ -39,0 +18,0 @@ |
@@ -7,21 +7,3 @@ exports.tests = [ | ||
} | ||
}, | ||
{ | ||
css: 'input[class$="span"] {}', | ||
metrics: { | ||
complexSelectorsByAttribute: 1 | ||
} | ||
}, | ||
{ | ||
css: '[class*="span"] {}', | ||
metrics: { | ||
complexSelectorsByAttribute: 1 | ||
} | ||
}, | ||
{ | ||
css: '[class="span"] {}', | ||
metrics: { | ||
complexSelectorsByAttribute: 0 | ||
} | ||
} | ||
]; |
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
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
201036
69
4993
197
+ Addedcli@1.0.1(transitive)
- Removedcli@0.11.3(transitive)
Updatedcli@^1.0.0
Updatednode-fetch@^1.6.1