Skip to content

Commit

Permalink
Add eslint files and fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aldeed committed Feb 22, 2017
1 parent ab45209 commit c29f42c
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
browser-shim.js
package.js
32 changes: 32 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"extends": "airbnb",
"parser": "babel-eslint",
"plugins": [
"react"
],
"env": {
"mocha": true,
"node": true
},
"globals": {
"describe": false,
"expect": false,
"Meteor": false
},
"rules": {
"arrow-body-style": 0,
"consistent-return": 1,
"import/no-unresolved": [2, { "ignore": ["^meteor/"] }],
"max-len": 0,
"new-cap": 0,
"newline-per-chained-call": 0,
"no-console": 0,
"no-param-reassign": 0,
"no-unused-expressions": 0,
"no-use-before-define": [2, "nofunc"],
"react/no-did-update-set-state": 0,
"react/no-multi-comp": 0,
"react/prefer-stateless-function": 0,
"space-before-function-paren": 0
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,12 @@ A good best practice is to define these commands as run scripts in your app's `p
```

And then run `npm run test-chrome`, etc.

## Contributing

Run eslint:

```bash
$ npm i
$ npm run lint
```
8 changes: 4 additions & 4 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package.describe({
name: "dispatch:mocha",
summary: "Run package or app tests with Mocha, using a headless browser for the client tests",
git: "https://github.com/DispatchMe/meteor-mocha.git",
name: 'dispatch:mocha',
summary: 'Run package or app tests with Mocha, using a headless browser for the client tests',
git: 'https://github.com/DispatchMe/meteor-mocha.git',
version: '0.1.0',
testOnly: true,
});

Package.onUse(function (api) {
Package.onUse(function onUse(api) {
api.use([
'practicalmeteor:[email protected]',
'[email protected]',
Expand Down
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "meteor-mocha",
"version": "0.0.0",
"description": "Run package or app tests with Mocha, using a headless browser for the client tests",
"scripts": {
"lint": "eslint ."
},
"author": "Dispatch (dispatch.me)",
"license": "MIT",
"devDependencies": {
"babel-eslint": "7.1.1",
"eslint": "3.0.1",
"eslint-config-airbnb": "9.0.1",
"eslint-plugin-import": "1.10.2",
"eslint-plugin-jsx-a11y": "1.5.5",
"eslint-plugin-react": "5.2.2"
}
}
22 changes: 9 additions & 13 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Meteor.startup(() => {
// finished running and then dump the buffer to the screen and continue
// logging in real time after that if client tests are still running.
let serverTestsDone = false;
let clientLines = [];
const clientLines = [];
function clientLogBuffer(line) {
if (serverTestsDone) {
// printing and removing the extra new-line character. The first was added by the client log, the second here.
Expand Down Expand Up @@ -54,7 +54,7 @@ function exitIfDone(type, failures) {
} else {
serverFailures = failures;
serverTestsDone = true;
if (shouldRunClientTests) {//
if (shouldRunClientTests) {
clientLines.forEach((line) => {
// printing and removing the extra new-line character. The first was added by the client log, the second here.
console.log(line.replace(/\n$/, ''));
Expand All @@ -80,7 +80,7 @@ function exitIfDone(type, failures) {
}
}

function serverTests(cb){
function serverTests(cb) {
printHeader('SERVER');

// We need to set the reporter when the tests actually run to ensure no conflicts with
Expand All @@ -92,11 +92,9 @@ function serverTests(cb){
exitIfDone('server', failureCount);
if (cb) { cb(); }
});

}

function clientTests(cb){

function clientTests(cb) {
if (!shouldRunClientTests) {
console.log('SKIPPING CLIENT TESTS BECAUSE TEST_BROWSER_DRIVER ENVIRONMENT VARIABLE IS NOT SET');
exitIfDone('client', 0);
Expand All @@ -121,17 +119,15 @@ function clientTests(cb){

// Before Meteor calls the `start` function, app tests will be parsed and loaded by Mocha
function start() {

// Run in PARALLEL or SERIES
// run in series is a better default IMHO since it avoids db and state conflicts for newbs
// if you want parallel you will know these risks
if (shouldRunInParallel){
// Running in series is a better default since it avoids db and state conflicts for newbs.
// If you want parallel you will know these risks.
if (shouldRunInParallel) {
console.log('Warning: Running in parallel can cause side-effects from state/db sharing');

serverTests();
clientTests();

} else { // run in series by default
} else {
serverTests(() => {
clientTests();
});
Expand Down

0 comments on commit c29f42c

Please sign in to comment.