Skip to content

Commit

Permalink
enforced eslint to close #20
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Jun 11, 2016
1 parent 12fbbcd commit 3124c93
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 54 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: '@travi/travi/rules/es6'

rules:
one-var: off
func-style: off
no-magic-numbers:
- error
- ignore:
- 1
10 changes: 6 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*eslint filenames/match-regex: "off" */

module.exports = function (grunt) {
require('time-grunt')(grunt);
require('load-grunt-config')(grunt, {
jitGrunt: {}
});

grunt.event.on('coverage', function(lcov, done){
require('coveralls').handleInput(lcov, function(err){
grunt.event.on('coverage', (lcov, done) => {
require('coveralls').handleInput(lcov, (err) => {
if (err) {
return done(err);
done(err);
}
done();
});
});
};
};
7 changes: 4 additions & 3 deletions any.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ const email = () => chance.email();
const date = () => chance.date({string: true});

function simpleObject() {
var object = {},
const
object = {},
size = integer(DEFAULT_SIZE_RANGE);

for (var i = 0; i < size; i += 1) {
for (let i = 0; i < size; i += 1) {
object[word()] = string();
}

Expand All @@ -27,7 +28,7 @@ function listOf(factory, options = {}) {
list = [],
listSize = options.size || integer(Object.assign({}, DEFAULT_SIZE_RANGE, options));

for (var i = 0; i < listSize; i += 1) {
for (let i = 0; i < listSize; i += 1) {
list.push(factory());
}

Expand Down
3 changes: 3 additions & 0 deletions grunt/aliases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ build:
- clean
- rollup

lint: eslint

unit: mocha_istanbul

test: unit

verify:
- clean
- lint
- test

default: verify
5 changes: 5 additions & 0 deletions grunt/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target:
- "*.js"
- grunt/**/*.js
- src/**/*.js
- test/**/*.js
58 changes: 29 additions & 29 deletions grunt/rollup.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
var babel = require('rollup-plugin-babel');
const babel = require('rollup-plugin-babel');

module.exports = {
es5: {
options: {
format: 'cjs',
plugins: [
babel({
babelrc: false,
exclude: './node_modules/**',
presets: ['es2015-rollup']
})
]
es5: {
options: {
format: 'cjs',
plugins: [
babel({
babelrc: false,
exclude: './node_modules/**',
presets: ['es2015-rollup']
})
]
},
files: {
'dist/any.js': 'any.js'
}
},
files: {
'dist/any.js': 'any.js'
es6: {
options: {
format: 'es6',
plugins: [
babel({
babelrc: false,
exclude: './node_modules/**',
presets: ['es2015-node']
})
]
},
files: {
'dist/any.mjs': 'any.js'
}
}
},
es6: {
options: {
format: 'es6',
plugins: [
babel({
babelrc: false,
exclude: './node_modules/**',
presets: ['es2015-node']
})
]
},
files: {
'dist/any.mjs': 'any.js'
}
}
};

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"chance": "1.0.3"
},
"devDependencies": {
"@travi/eslint-config-travi": "0.1.3",
"babel-cli": "6.9.0",
"babel-preset-es2015-node": "6.1.0",
"babel-preset-es2015-rollup": "1.1.1",
Expand All @@ -40,6 +41,7 @@
"grunt": "1.0.1",
"grunt-cli": "1.2.0",
"grunt-contrib-clean": "1.0.0",
"grunt-eslint": "18.1.0",
"grunt-mocha-istanbul": "5.0.1",
"grunt-rollup": "0.7.1",
"istanbul": "1.0.0-alpha.2",
Expand Down
1 change: 1 addition & 0 deletions test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: '@travi/travi/rules/tests/base'
1 change: 1 addition & 0 deletions test/unit/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: '@travi/travi/rules/tests/mocha'
38 changes: 20 additions & 18 deletions test/unit/any-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const chance = new Chance();

suite('random data generator', () => {
let sandbox, any, chanceStub;
const options = {foo: 'bar'};
const INTEGER_RANGE = {min: 1, max: 10};
const
options = {foo: 'bar'},
INTEGER_RANGE = {min: 1, max: 10};

setup(() => {
sandbox = sinon.sandbox.create();
Expand Down Expand Up @@ -72,13 +73,15 @@ suite('random data generator', () => {
});

test('that the object size is randomly set', () => {
const strings = [];
const words = [];
const objectSize = chance.natural(INTEGER_RANGE);
const
strings = [],
words = [],
objectSize = chance.natural(INTEGER_RANGE);
chanceStub.natural.withArgs({min: 1, max: 20}).returns(objectSize);
for (let i = 0; i < objectSize; i += 1) {
const string = chance.string();
const word = chance.word();
const
string = chance.string(),
word = chance.word();

strings[i] = string;
words[i] = word;
Expand All @@ -87,7 +90,8 @@ suite('random data generator', () => {
chanceStub.word.onCall(i).returns(word);
}

var object = any.simpleObject();
const object = any.simpleObject();

assert.equal(Object.keys(object).length, objectSize);
for (let i = 0; i < objectSize; i += 1) {
assert.equal(object[words[i]], strings[i]);
Expand All @@ -103,18 +107,18 @@ suite('random data generator', () => {
});

test('that a list of random size is returned by default', () => {
const factory = sinon.spy();

const list = any.listOf(factory);
const
factory = sinon.spy(),
list = any.listOf(factory);

assert.equal(list.length, listSize);
assert.callCount(factory, listSize);
});

test('that the list size can be set through the options', () => {
const size = chance.natural(INTEGER_RANGE);

const list = any.listOf(sinon.spy(), {size});
const
size = chance.natural(INTEGER_RANGE),
list = any.listOf(sinon.spy(), {size});

assert.equal(list.length, size);
});
Expand All @@ -123,9 +127,7 @@ suite('random data generator', () => {
const min = chance.natural(INTEGER_RANGE);
chanceStub.natural.withArgs({min, max: 20}).returns(listSize);

const list = any.listOf(sinon.spy(), {min});

assert.equal(list.length, listSize);
assert.equal(any.listOf(sinon.spy(), {min}).length, listSize);
});
});

Expand All @@ -147,4 +149,4 @@ suite('random data generator', () => {
assert.equal(any.fromList(list), list[index]);
});
});
});
});

0 comments on commit 3124c93

Please sign in to comment.