Skip to content
Permalink
Browse files
[Tests] add eclint and eslint, to enforce a consistent style
  • Loading branch information
ljharb committed May 8, 2018
1 parent 45788a5 commit c6f5313217bc0b553ccab9a70a195b26881b63d8
Show file tree
Hide file tree
Showing 52 changed files with 720 additions and 658 deletions.
@@ -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
@@ -0,0 +1,6 @@
{
"root": true,
"rules": {
"indent": ["error", 4],
},
}
@@ -1,6 +1,8 @@
language: node_js
sudo: false
os:
- linux
node_js:
- "10"
- "9"
- "8"
- "7"
@@ -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"
@@ -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 }));
}
});

@@ -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) {
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -3,7 +3,7 @@ var test = require('../');

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

setTimeout(function () {
throw new Error('doom');
}, 100);
@@ -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);
@@ -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);

2 comments on commit c6f5313

@marques-work
Copy link
Contributor

@marques-work marques-work commented on c6f5313 May 13, 2018

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.