Skip to content

Commit

Permalink
Merge 1c00415 into 7aa2b99
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed Jun 9, 2021
2 parents 7aa2b99 + 1c00415 commit 3d468d4
Show file tree
Hide file tree
Showing 11 changed files with 4,451 additions and 1,693 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ jobs:
time npm install node-sass@5.0.0
npm test
# https://github.com/marketplace/actions/coveralls-github-action
# upload coverage report for just one of Node.js version matrix runs
- name: Upload coverage report to Coveralls
if: matrix.node-version == '15.x'
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ github.token }}

- name: Run bin/analyze-css.js for CSS file
run: ./bin/analyze-css.js --file examples/ti.mobile.css -p | jq .metrics

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lib-cov
pids
logs
results
coverage/

npm-debug.*
node_modules
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
examples/
test/
coverage/
*.md
*.yml
*.json
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ analyze-css
[![NPM version](https://badge.fury.io/js/analyze-css.png)](http://badge.fury.io/js/analyze-css)
[![Known Vulnerabilities](https://snyk.io/test/github/macbre/analyze-css/badge.svg)](https://snyk.io/test/github/macbre/analyze-css)
[![Inline docs](http://inch-ci.org/github/macbre/analyze-css.svg?branch=devel&style=flat-square)](http://inch-ci.org/github/macbre/analyze-css)
[![Coverage Status](https://coveralls.io/repos/github/macbre/analyze-css/badge.svg?branch=devel)](https://coveralls.io/github/macbre/analyze-css?branch=devel)

[![Download stats](https://nodei.co/npm/analyze-css.png?downloads=true&downloadRank=true)](https://nodei.co/npm/analyze-css/)

Expand Down
6,070 changes: 4,399 additions & 1,671 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eslint": "^7.12.1",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-node": "^11.1.0",
"mocha": "^9.0.0",
"jest": "^27.0.4",
"nyc": "^15.1.0",
"postcss": "^8.2.6",
"prettier": "2.3.1"
Expand All @@ -50,16 +50,26 @@
"bin": "./bin/analyze-css.js",
"preferGlobal": true,
"scripts": {
"test": "mocha -R spec",
"test": "jest test/ --coverage --detectOpenHandles",
"lint": "eslint .",
"prettier": "npx prettier --write .",
"coverage": "nyc mocha -R spec",
"prefixes": "npx browserslist@latest --update-db; DEBUG=* node data/prefixes.js"
},
"jshintConfig": {
"esversion": 6,
"node": true,
"strict": true,
"validthis": true
},
"jest": {
"verbose": true,
"coverageThreshold": {
"global": {
"statements": 97,
"branches": 94,
"functions": 100,
"lines": 97
}
}
}
}
4 changes: 2 additions & 2 deletions test/colors.js → test/colors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
var extractColors = require('../rules/colors').extractColors,
assert = require('assert');

describe('Colors', function() {
it('should be properly extracted from CSS properties', function() {
describe('Colors', () => {
it('should be properly extracted from CSS properties', () => {
var testCases = [
[
'-moz-linear-gradient(top, rgba(240, 231, 223, 0) 50%, #f0e7df 100%)',
Expand Down
6 changes: 3 additions & 3 deletions test/errors.js → test/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ tests = [
}
];

describe('Errors handling', function() {
describe('Errors handling', () => {
tests.forEach(function(test) {
describe(test.name || '"' + test.css + '" CSS snippet', function() {
it('should raise an error with correct error code', function(done) {
describe(test.name || '"' + test.css + '" CSS snippet', () => {
it('should raise an error with correct error code', done => {
new analyzer(test.css, function(err, res) {
assert.equal(err instanceof Error, true, 'Error should be thrown');

Expand Down
8 changes: 4 additions & 4 deletions test/opts.js → test/opts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ var analyzer = require('../'),
assert = require('assert'),
css = '.foo { color: white }';

describe('CommonJS module API', function() {
describe('noOffenders option', function() {
it('should be respected', function(done) {
describe('CommonJS module API', () => {
describe('noOffenders option', () => {
it('should be respected', done => {
var opts = {
'noOffenders': true
};
Expand All @@ -19,7 +19,7 @@ describe('CommonJS module API', function() {
});
});

it('should be void if not provided', function(done) {
it('should be void if not provided', done => {
new analyzer(css, function(err, res) {
assert.strictEqual(err, null);
assert.equal(typeof res.offenders, 'object', 'Results should contain offenders');
Expand Down
13 changes: 8 additions & 5 deletions test/rules.js → test/rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ function runTest(tests) {
}

Object.keys(metricsExpected).forEach(function(metric) {
it('should emit "' + metric + '" metric with a valid value - #' + (testId + 1), function() {
assert.strictEqual(metricsActual[metric], metricsExpected[metric], "Testing metric against: " + test.css);
});
it(
'should emit "' + metric + '" metric with a valid value - #' + (testId + 1),
() => {
assert.strictEqual(metricsActual[metric], metricsExpected[metric], "Testing metric against: " + test.css);
}
);
});
});
});
Expand All @@ -27,15 +30,15 @@ function runTest(tests) {
/**
* Read all files in rules/ subdirectory and perform tests defined there
*/
describe('Rules', function() {
describe('Rules', () => {
var files = glob.sync(__dirname + "/rules/*.js"),
nameRe = /([^/]+)\.js$/;

files.forEach(function(file) {
var name = file.match(nameRe)[1],
testDef = require(file);

describe(name, function() {
describe(name, () => {
runTest(testDef.tests || []);
});
});
Expand Down
16 changes: 11 additions & 5 deletions test/sass.js → test/sass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,30 @@ function testSassNotInstalled(done) {
}
}

describe('SASS preprocessor [' + (isSassInstalled ? 'node-sass installed' : 'node-sass missing') + ']', function() {
it('should be chosen for SCSS files', function() {
describe('SASS preprocessor [' + (isSassInstalled ? 'node-sass installed' : 'node-sass missing') + ']', () => {
it('should be chosen for SCSS files', () => {
var preprocessors = new(require('../lib/preprocessors.js'))();

assert.equal(preprocessors.findMatchingByFileName('test/foo.scss'), 'sass');
assert.equal(preprocessors.findMatchingByFileName('test/foo.sass'), 'sass');
assert.equal(preprocessors.findMatchingByFileName('test/foo.css'), false);
});

it('should report parsing error (if not selected)', function(done) {
it('should report parsing error (if not selected)', done => {
new analyzer(scss, function(err, res) {
assert.strictEqual(err, null);
assert.equal(res.metrics.parsingErrors, 3);
done();
});
});

it('should generate CSS from SCSS correctly', !isSassInstalled ? testSassNotInstalled : testSassInstalled);
it(
'should generate CSS from SCSS correctly',
!isSassInstalled ? testSassNotInstalled : testSassInstalled
);

it('should generate CSS from SASS correctly', !isSassInstalled ? testSassNotInstalled : testSassInstalled);
it(
'should generate CSS from SASS correctly',
!isSassInstalled ? testSassNotInstalled : testSassInstalled
);
});

0 comments on commit 3d468d4

Please sign in to comment.