Skip to content

Commit

Permalink
[Tests] add eclint and eslint, to enforce a consistent style
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 8, 2018
1 parent 45788a5 commit c6f5313
Show file tree
Hide file tree
Showing 52 changed files with 720 additions and 658 deletions.
33 changes: 33 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 140
block_comment_start = /*
block_comment = *
block_comment_end = */

[*.md]
indent_style = space
indent_size = 4

[readme.markdown]
indent_size = off
max_line_length = off

[*.json]
max_line_length = off

[*.yml]
max_line_length = off

[Makefile]
max_line_length = off

[.travis.yml]
indent_size = 2
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": true,
"rules": {
"indent": ["error", 4],
},
}
16 changes: 15 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js
sudo: false
os:
- linux
node_js:
- "10"
- "9"
- "8"
- "7"
Expand All @@ -12,11 +14,23 @@ node_js:
- "0.10"
- "0.8"
before_install:
- 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac'
- 'nvm install-latest-npm'
install:
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
script:
- 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
- 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi'
- 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi'
- 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
sudo: false
env:
- TEST=true
matrix:
fast_finish: true
include:
- node_js: "lts/*"
env: PRETEST=true
allow_failures:
- node_js: "9"
- node_js: "7"
Expand Down
9 changes: 5 additions & 4 deletions bin/tape
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ if (typeof opts.require === 'string') {

opts.require.forEach(function(module) {
if (module) {
/* This check ensures we ignore `-r ""`, trailing `-r`, or
* other silly things the user might (inadvertently) be doing. */
require(resolveModule(module, { basedir: cwd }));
/* This check ensures we ignore `-r ""`, trailing `-r`, or
* other silly things the user might (inadvertently) be doing.
*/
require(resolveModule(module, { basedir: cwd }));
}
});

Expand All @@ -31,7 +32,7 @@ opts._.forEach(function (arg) {
var files = glob.sync(arg);

if (!Array.isArray(files)) {
throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
throw new TypeError('unknown error: glob.sync did not return an array or throw. Please report this.');
}

files.forEach(function (file) {
Expand Down
8 changes: 4 additions & 4 deletions example/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ var test = require('../');

test('array', function (t) {
t.plan(5);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
];

Function(['fn','g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
Expand Down
8 changes: 4 additions & 4 deletions example/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ var test = require('../');

test('array', function (t) {
t.plan(5);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
];

Function(['fn','g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
Expand Down
12 changes: 6 additions & 6 deletions example/nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ var test = require('../');

test('nested array test', function (t) {
t.plan(5);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

t.test('inside test', function (q) {
q.plan(2);
q.ok(true, 'inside ok');

setTimeout(function () {
q.ok(true, 'inside delayed');
}, 3000);
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
];

Function(['fn','g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
Expand Down
12 changes: 6 additions & 6 deletions example/nested_fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ var test = require('../');

test('nested array test', function (t) {
t.plan(5);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

t.test('inside test', function (q) {
q.plan(2);
q.ok(true);

setTimeout(function () {
q.equal(3, 4);
}, 3000);
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
];

Function(['fn','g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
Expand Down
8 changes: 4 additions & 4 deletions example/not_enough.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ var test = require('../');

test('array', function (t) {
t.plan(8);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
];

Function(['fn','g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
Expand Down
2 changes: 1 addition & 1 deletion example/throw.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var test = require('../');

test('throw', function (t) {
t.plan(2);

setTimeout(function () {
throw new Error('doom');
}, 100);
Expand Down
4 changes: 2 additions & 2 deletions example/timing.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ var test = require('../');

test('timing test', function (t) {
t.plan(2);

t.equal(typeof Date.now, 'function');
var start = new Date;

setTimeout(function () {
t.equal(new Date - start, 100);
}, 100);
Expand Down
8 changes: 4 additions & 4 deletions example/too_many.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ var test = require('../');

test('array', function (t) {
t.plan(3);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
];

Function(['fn','g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
Expand Down
Loading

2 comments on commit c6f5313

@marques-work
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb any inclination to cut a micro release soon?

@ljharb
Copy link
Collaborator Author

@ljharb ljharb commented on c6f5313 Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v4.9.1 is released.

Please sign in to comment.