Skip to content

Commit

Permalink
adds coverage and eslint, fixes linting errors, makes tests better
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanpedersen committed Sep 27, 2017
1 parent 6670f04 commit a31d531
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 8 deletions.
41 changes: 41 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"rules": {
"camelcase": 0,
"consistent-return": 0,
"curly": [2, "all"],
"dot-notation": 0,
"eol-last": 0,
"eqeqeq": [2, "allow-null"],
"handle-callback-err": 0,
"new-cap": [2, {"capIsNew": false}],
"no-alert": 0,
"no-bitwise": 2,
"no-caller": 2,
"no-debugger": 2,
"no-empty": 2,
"no-eval": 2,
"no-extra-semi": 2,
"no-irregular-whitespace": 0,
"no-multi-spaces": 0,
"no-new": 2,
"no-plusplus": 0,
"no-process-exit": 0,
"no-redeclare": 2,
"no-shadow": 0,
"no-trailing-spaces": [2, { "skipBlankLines": true }],
"no-undef": 2,
"no-underscore-dangle": 0,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-use-before-define": 0,
"object-shorthand": 0,
"one-var": 0,
"quotes": [2, "single"],
"semi": [2, "always"],
"wrap-iife": [2, "inside"]
},
"env": {
"node": true,
"mocha": true,
"es6": true
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*.log
coverage
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: node_js
node_js:
- "8"
- "6"
- "6"
after_success:
- npm run coveralls
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Make re-assigments great again!

[![Build Status](https://travis-ci.org/jonatanpedersen/constipated.svg?branch=master)](https://travis-ci.org/jonatanpedersen/constipated)
[![Build Status](https://img.shields.io/npm/v/constipated.svg)](https://www.npmjs.com/package/constipated)
[![Coverage Status](https://coveralls.io/repos/github/jonatanpedersen/constipated/badge.svg?branch=master)](https://coveralls.io/github/jonatanpedersen/constipated?branch=master)

## Installation

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function relieveGlob (pattern) {
var files = glob.sync(pattern);

files.forEach(relieveFile);
};
}

function relieveFile (file) {
var contents = readFile(file);
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"description": "Turns your consts in to vars, relieve those variables.",
"main": "index.js",
"scripts": {
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha",
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls",
"postversion": "git push && git push --tags",
"preversion": "npm test",
"test": "mocha"
Expand All @@ -23,9 +25,14 @@
},
"devDependencies": {
"chai": "^4.1.2",
"coveralls": "^2.13.1",
"dir-compare": "^1.4.0",
"eslint": "^4.7.2",
"fs-extra": "^4.0.2",
"mocha": "^3.5.3"
"istanbul": "^0.4.5",
"mocha": "^3.5.3",
"mocha-eslint": "^4.1.0",
"mocha-lcov-reporter": "^1.3.0"
},
"engines": {
"node": ">=6"
Expand Down
7 changes: 7 additions & 0 deletions test/eslint.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const mochaEslint = require('mocha-eslint');

mochaEslint([
'./index.js',
'./test/**/*.js',
'!./test/fixtures/**/*.js'
]);
6 changes: 5 additions & 1 deletion test/fixtures/file/actual/foobar.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
var foo = 'foo';
var bar = false;
var bar = false;

(function () {
var baz = 1, qux = 2;
})();
6 changes: 5 additions & 1 deletion test/fixtures/file/expected/foobar.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
var foo = 'foo';
var bar = false;
var bar = false;

(function () {
var baz = 1, qux = 2;
})();
6 changes: 5 additions & 1 deletion test/fixtures/file/input/foobar.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
const foo = 'foo';
const bar = false;
const bar = false;

(function () {
const baz = 1, qux = 2;
})();
4 changes: 2 additions & 2 deletions test/index.js → test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('constipated', () => {
});

describe('relieveFile', () => {
var inputDir, expectedDir, actualDir, actualFile;
var inputDir, expectedDir, actualDir, actualFile, comparison;

before(() => {
inputDir = './test/fixtures/file/input';
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('constipated', () => {
});

describe('relieveGlob', () => {
var inputDir, expectedDir, actualDir, glob;
var inputDir, expectedDir, actualDir, glob, comparison;

before(() => {
inputDir = './test/fixtures/glob/input';
Expand Down
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./test/**/*.spec.js

0 comments on commit a31d531

Please sign in to comment.