Skip to content
This repository has been archived by the owner on Feb 2, 2020. It is now read-only.

Commit

Permalink
Merge b58421b into f3feb6d
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Jan 10, 2016
2 parents f3feb6d + b58421b commit 7b9ab9b
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 16 deletions.
22 changes: 22 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ecmaFeatures:
modules: true
blockBindings: true
arrowFunctions: true
destructuring: true
templateStrings: true
rules:
indent:
- 2
- 2
- SwitchCase: 1
quotes:
- 2
- single
semi:
- 2
- always
no-var: 2
env:
node: true
mocha: true
extends: 'eslint:recommended'
4 changes: 3 additions & 1 deletion assets/test-file.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/*eslint no-var: 0*/

var assert = require('assert');
var CLIEngine = require('eslint').CLIEngine;
var eol = require('eol');

var cli = new CLIEngine();

var files = process.env.NODE_ESLINT_FILES.split(',');
var files = process.env.NPM_PACKAGE_CONFIG_ESLINT_FILES.split(',');

var results = cli.executeOnFiles(files).results;

Expand Down
1 change: 1 addition & 0 deletions bin/eslint-mocha.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
/*eslint no-var: 0*/

var yargs = require('yargs');
var eslintMocha = require('../dist/eslint-mocha').default;
Expand Down
2 changes: 1 addition & 1 deletion lib/eslint-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default options => {
let lintTestFile = initEslint(options);

runMocha(lintTestFile, options);
}
};
4 changes: 2 additions & 2 deletions lib/eslint/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import path from 'path';
export default options => {
let { eslintFiles } = options;

process.env.NODE_ESLINT_FILES = eslintFiles.join(',');
process.env.NPM_PACKAGE_CONFIG_ESLINT_FILES = eslintFiles.join(',');

let testFile = path.resolve(__dirname, '../../assets/test-file.js');

return testFile;
}
};
2 changes: 1 addition & 1 deletion lib/mocha/add-compilers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export default (compilers, extensions) => {

_require(mod);
});
}
};
2 changes: 1 addition & 1 deletion lib/mocha/add-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export default (mocha, files, extensions, isRecursive, lintTestFile) => {
files.push(lintTestFile);

files.forEach(file => mocha.addFile(file));
}
};
2 changes: 1 addition & 1 deletion lib/mocha/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ export default (lintTestFile, options) => {
addFiles(mocha, mochaFiles, extensions, isMochaRecursive, lintTestFile);

mocha.run();
}
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"build": "babel lib -d dist",
"pretest": "npm run build",
"precover": "npm run build",
"test": "mocha --compilers js:babel-register \"test/@(acceptance|unit)/**/*-test.js\"",
"cover": "babel-node node_modules/isparta/bin/isparta cover --include-all-sources --report html node_modules/mocha/bin/_mocha -- --compilers js:babel-register \"test/@(acceptance|unit)/**/*-test.js\"",
"debug": "node debug node_modules/mocha/bin/_mocha --compilers js:babel-register \"test/unit/**/*-test.js\""
"test": "mocha --compilers js:babel-register \"test/@(acceptance|unit)/**/*-test.js\" test/lint.js assets/test-file.js",
"cover": "babel-node node_modules/isparta/bin/isparta cover --include-all-sources --report html --report lcov node_modules/mocha/bin/_mocha -- --compilers js:babel-register \"test/@(acceptance|unit)/**/*-test.js\" test/lint.js assets/test-file.js",
"debug": "node debug node_modules/mocha/bin/_mocha --compilers js:babel-register \"test/unit/**/*-test.js\"",
"lint": "mocha test/lint.js assets/test-file.js"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion test/acceptance/babel-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect } from 'chai';
import eol from 'eol';
import run from '../helpers/run';
import { symbols } from 'mocha/lib/reporters/base';

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/babel-project/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ rules:
env:
node: true
mocha: true
root: true
extends: 'eslint:recommended'
1 change: 1 addition & 0 deletions test/fixtures/failure-project/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ rules:
- always
env:
node: true
root: true
extends: 'eslint:recommended'
1 change: 1 addition & 0 deletions test/fixtures/success-project/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ rules:
env:
node: true
mocha: true
root: true
extends: 'eslint:recommended'
2 changes: 1 addition & 1 deletion test/helpers/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export default (args, workingDir) => {
}
});
});
}
};
1 change: 1 addition & 0 deletions test/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
process.env.NPM_PACKAGE_CONFIG_ESLINT_FILES = 'assets/**/*.js,bin/**/*.js,lib/**/*.js,test/!(fixtures)/**/*.js';
8 changes: 4 additions & 4 deletions test/unit/eslint/initialize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ describe('unit - eslint/initialize', function() {
let env, resolve;

beforeEach(function() {
env = process.env.NODE_ESLINT_FILES;
process.env.NODE_ESLINT_FILES = '';
env = process.env.NPM_PACKAGE_CONFIG_ESLINT_FILES;
process.env.NPM_PACKAGE_CONFIG_ESLINT_FILES = '';

initialize.__Rewire__('path', {
resolve: resolve = sinon.stub()
});
});

afterEach(function() {
process.env.NODE_ESLINT_FILES = env;
process.env.NPM_PACKAGE_CONFIG_ESLINT_FILES = env;

initialize.__ResetDependency__('path');
});
Expand All @@ -26,7 +26,7 @@ describe('unit - eslint/initialize', function() {
eslintFiles: ['test-file-1', 'test-file-2']
});

expect(process.env.NODE_ESLINT_FILES).to.equal('test-file-1,test-file-2');
expect(process.env.NPM_PACKAGE_CONFIG_ESLINT_FILES).to.equal('test-file-1,test-file-2');
});

it('returns test file path', function() {
Expand Down

0 comments on commit 7b9ab9b

Please sign in to comment.