Skip to content

Commit

Permalink
Tighten various test case configs;
Browse files Browse the repository at this point in the history
Remove JSCS and update ESLint code styles config;
Update code style accordingly;
  • Loading branch information
adametry committed Jan 15, 2016
1 parent 3536eeb commit 90841cb
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 63 deletions.
30 changes: 21 additions & 9 deletions .eslintrc
Expand Up @@ -2,37 +2,35 @@ env:
node: true

rules:
indent: [2, 'tab']
indent: [1, 'tab']
brace-style: [2, "1tbs"]
comma-style: [2, "last"]
comma-style: [1, "last"]
default-case: 2
func-style: [2, "declaration"]
no-floating-decimal: 2
no-nested-ternary: 2
no-undefined: 2
radix: 2
space-before-function-paren: [1, "never"]
space-after-keywords: [2, "always"]
space-before-blocks: 2
keyword-spacing: [2, {after: true}]
space-before-blocks: 1
spaced-comment: [2, "always", { exceptions: ["-"]}]
valid-jsdoc: [1, { requireReturn: false, prefer: { return": "returns" }}]
valid-jsdoc: [1, { requireReturn: false, prefer: { return: "returns" }}]
wrap-iife: 2
guard-for-in: 2
strict: [2, "global"]
global-strict: 0
no-alert: 2
camelcase: 1
curly: [2, "all"]
eqeqeq: [2, "allow-null"]
no-empty: 2
no-underscore-dangle: 0
no-use-before-define: 2
no-obj-calls: 2
no-unused-vars: [0, {"vars": "local", "args": "after-used"}]
no-unused-vars: [1, {vars: "local", args: "after-used"}]
new-cap: 2
no-shadow: 1
no-invalid-regexp: 2
comma-dangle: [2, "never"]
comma-dangle: [1, "never"]
no-undef: 2
no-new: 2
no-extra-semi: 2
Expand All @@ -42,3 +40,17 @@ rules:
quotes: [1, "single", "avoid-escape"]
no-unreachable: 2
eol-last: 1
operator-linebreak: [1, "before", {overrides: {"?": "after", ":": "after"}}]
max-len: [1, 98, 4, {"ignoreComments": true}]
no-multi-str: 1
no-mixed-spaces-and-tabs: 1
no-trailing-spaces: 1
space-infix-ops: 1
space-unary-ops: 1
no-with: 2
dot-notation: 1
semi-spacing: 1
key-spacing: [1, {beforeColon: false, afterColon: true, mode: "minimum"}]
space-in-parens: [1, "never"]
space-return-throw-case: 1
space-after-keywords: 1
4 changes: 2 additions & 2 deletions example/config.js
Expand Up @@ -28,9 +28,9 @@ gulp.task('inline-config', function() {
.pipe(eslint({
// gulp-eslint's config works much like .eslintrc with a dash of ESLint's CLI

'extends':'eslint:recommended',
'extends': 'eslint:recommended',

'ecmaFeatures':{
'ecmaFeatures': {
'modules': true
},

Expand Down
2 changes: 1 addition & 1 deletion example/fail.js
Expand Up @@ -16,7 +16,7 @@ gulp.task('fail-immediately', function() {
.pipe(eslint.failOnError())
// need to do something before the process exits? Try this:
.on('error', function(error) {
gulpUtil.log('Stream Exiting With Error');
gulpUtil.log('Stream Exiting With Error: ' + error.message);
});
});

Expand Down
3 changes: 0 additions & 3 deletions example/quiet.js
Expand Up @@ -10,9 +10,6 @@ gulp.task('quiet-lint', function() {
.pipe(eslint({
// only report errors
quiet: true
}))
.pipe(eslint.result(function(result) {

}))
.pipe(eslint.format());
});
Expand Down
12 changes: 1 addition & 11 deletions package.json
Expand Up @@ -12,7 +12,7 @@
"test": "test"
},
"scripts": {
"pretest": "jscs *.js test/*.js && gulp test",
"pretest": "gulp test",
"test": "mocha",
"gulp": "gulp",
"gulp-example": "gulp --gulpfile=example/config.js",
Expand Down Expand Up @@ -51,18 +51,8 @@
"gulp": "^3.9.0",
"istanbul": "^0.4.0",
"istanbul-coveralls": "^1.0.3",
"jscs": "^2.0.0",
"mocha": "^2.2.5",
"should": "^8.0.1",
"vinyl": "^1.0.0"
},
"jscsConfig": {
"preset": "google",
"validateIndentation": "\t",
"disallowMultipleVarDecl": null,
"maximumLineLength": {
"value": 98,
"allowComments": true
}
}
}
6 changes: 3 additions & 3 deletions test/fail.js
Expand Up @@ -19,7 +19,7 @@ describe('gulp-eslint failOnError', function() {
.on('error', function(err) {
this.removeListener('finish', endWithoutError);
should.exists(err);
err.message.should.equal('"x" is not defined.');
err.message.should.equal('\'x\' is not defined.');
err.fileName.should.equal('test/fixtures/invalid.js');
err.plugin.should.equal('gulp-eslint');
done();
Expand Down Expand Up @@ -57,9 +57,9 @@ describe('gulp-eslint failOnError', function() {
file.eslint = {};

eslint.failOnError()
.on('error', function(error) {
.on('error', function(err) {
this.removeListener('finish', done);
done(error);
done(err);
})
.on('finish', done)
.end(file);
Expand Down
3 changes: 0 additions & 3 deletions test/fixtures/.eslintrc-babel

This file was deleted.

11 changes: 6 additions & 5 deletions test/format.js
Expand Up @@ -52,7 +52,7 @@ describe('gulp-eslint format', function() {
* @param {String} message - a message to trigger an error
*/
function failWriter(message) {
var error = new Error('Writer Test Error');
var error = new Error('Writer Test Error' + (message ? ': ' + message : ''));
error.name = 'TestError';
throw error;
}
Expand Down Expand Up @@ -87,7 +87,8 @@ describe('gulp-eslint format', function() {
it('should format all ESLint results at once', function(done) {
var files = getFiles();

var lintStream = eslint().on('error', done);
var lintStream = eslint({useEslintrc: false, rules: {'strict': 2}});
lintStream.on('error', done);

var formatStream = eslint.format(formatResults, outputWriter);

Expand Down Expand Up @@ -154,7 +155,7 @@ describe('gulp-eslint format', function() {

var files = getFiles();

var lintStream = eslint()
var lintStream = eslint({useEslintrc: false, rules: {'strict': 2}})
.on('error', done);

var formatStream = eslint.formatEach(formatResult, outputWriter)
Expand Down Expand Up @@ -184,15 +185,15 @@ describe('gulp-eslint format', function() {

var files = getFiles();

var lintStream = eslint()
var lintStream = eslint({useEslintrc: false, rules: {'strict': 2}})
.on('error', done);

var formatStream = eslint.formatEach(formatResult, failWriter);

formatStream
.on('error', function(err) {
should.exists(err);
err.message.should.equal('Writer Test Error');
err.message.should.equal('Writer Test Error: 1 messages');
err.name.should.equal('TestError');
err.plugin.should.equal('gulp-eslint');
done();
Expand Down
41 changes: 20 additions & 21 deletions test/linting.js
@@ -1,23 +1,22 @@
/* global describe, it*/
'use strict';

var fs = require('fs');
var eslint = require('../');
var stream = require('stream');
var File = require('vinyl');
var should = require('should');
var BufferStreams = require('bufferstreams');
var fs = require('fs'),
eslint = require('../'),
stream = require('stream'),
File = require('vinyl'),
should = require('should'),
BufferStreams = require('bufferstreams');

require('mocha');

describe('gulp-eslint plugin', function() {

it('should configure an alternate parser', function(done) {
eslint({
configFile: 'test/fixtures/.eslintrc-babel',
globals: {
'$': true
}
parser: 'babel-eslint',
useEslintrc: false,
rules: {strict: [2, 'global']}
})
.on('error', done)
.on('data', function(file) {
Expand All @@ -38,7 +37,7 @@ describe('gulp-eslint plugin', function() {
})
.end(new File({
path: 'test/fixtures/es6.js',
contents: new Buffer('(() => {\n\t$.fn.foo = (a) => `${a}b`; }());')
contents: new Buffer('(() => {\n\treturn (a) => `${a}b`; }());')
}));
});

Expand Down Expand Up @@ -68,7 +67,7 @@ describe('gulp-eslint plugin', function() {
});

it('should produce expected message upon stream completion', function(done) {
eslint()
eslint({useEslintrc: false, rules: {strict: [2, 'global']}})
.on('error', done)
.on('data', function(file) {
should.exist(file);
Expand Down Expand Up @@ -101,7 +100,7 @@ describe('gulp-eslint plugin', function() {
it('should lint multiple streaming files', function(done) {
var fileCount = 0;

var lintStream = eslint()
var lintStream = eslint({useEslintrc: false, rules: {strict: [2, 'global']}})
.on('error', done)
.on('data', function(file) {
should.exist(file);
Expand Down Expand Up @@ -138,7 +137,7 @@ describe('gulp-eslint plugin', function() {
});

it('should ignore files with null content', function(done) {
eslint()
eslint({useEslintrc: false, rules: {'strict': 2}})
.on('error', done)
.on('data', function(file) {
should.exist(file);
Expand All @@ -155,7 +154,7 @@ describe('gulp-eslint plugin', function() {
describe('"warnFileIgnored" option', function() {

it('when true, should warn when a file is ignored by .eslintignore', function(done) {
eslint({warnFileIgnored: true})
eslint({useEslintrc: false, warnFileIgnored: true})
.on('error', done)
.on('data', function(file) {
should.exist(file);
Expand All @@ -174,14 +173,14 @@ describe('gulp-eslint plugin', function() {
});

it('when true, should warn when a "node_modules" file is ignored', function(done) {
eslint({warnFileIgnored: true})
eslint({useEslintrc: false, warnFileIgnored: true})
.on('error', done)
.on('data', function(file) {
should.exist(file);
should.exist(file.eslint);
file.eslint.messages.should.be.instanceof(Array).and.have.lengthOf(1);
file.eslint.messages[0]
.should.have.property('message', 'File ignored because it has a node_modules/** path');
file.eslint.messages[0].should.have.property('message',
'File ignored because it has a node_modules/** path');
file.eslint.errorCount.should.equal(0);
file.eslint.warningCount.should.equal(1);
done();
Expand All @@ -193,7 +192,7 @@ describe('gulp-eslint plugin', function() {
});

it('when not true, should silently ignore files', function(done) {
eslint({warnFileIgnored: false})
eslint({useEslintrc: false, warnFileIgnored: false})
.on('error', done)
.on('data', function(file) {
should.exist(file);
Expand All @@ -211,7 +210,7 @@ describe('gulp-eslint plugin', function() {
describe('"quiet" option', function() {

it('when true, should remove warnings', function(done) {
eslint({quiet: true, rules: {'no-undef': 1, 'strict': 2}})
eslint({quiet: true, useEslintrc: false, rules: {'no-undef': 1, 'strict': 2}})
.on('data', function(file) {
should.exist(file);
should.exist(file.eslint);
Expand All @@ -230,7 +229,7 @@ describe('gulp-eslint plugin', function() {
function warningsOnly(message) {
return message.severity === 1;
}
eslint({quiet: warningsOnly, rules: {'no-undef': 1, 'strict': 2}})
eslint({quiet: warningsOnly, useEslintrc: false, rules: {'no-undef': 1, 'strict': 2}})
.on('data', function(file) {
should.exist(file);
should.exist(file.eslint);
Expand Down
16 changes: 14 additions & 2 deletions test/result.js
Expand Up @@ -12,7 +12,13 @@ describe('gulp-eslint result', function() {

it('should provide an ESLint result', function(done) {
var resultCount = 0;
var lintStream = eslint({useEslintrc: false, rules: {'no-undef': 2, 'strict': [1, 'global']}});
var lintStream = eslint({
useEslintrc: false,
rules: {
'no-undef': 2,
'strict': [1, 'global']
}
});

lintStream
.pipe(eslint.result(function(result) {
Expand Down Expand Up @@ -174,7 +180,13 @@ describe('gulp-eslint results', function() {

it('should provide ESLint results', function(done) {
var resultsCalled = false;
var lintStream = eslint({useEslintrc: false, rules: {'no-undef': 2, 'strict': [1, 'global']}});
var lintStream = eslint({
useEslintrc: false,
rules: {
'no-undef': 2,
'strict': [1, 'global']
}
});

lintStream
.pipe(eslint.results(function(results) {
Expand Down
6 changes: 3 additions & 3 deletions test/util.js
Expand Up @@ -2,10 +2,8 @@
'use strict';

var File = require('vinyl'),
path = require('path'),
stream = require('stream'),
should = require('should'),
CLIEngine = require('eslint').CLIEngine,
util = require('../util');

require('mocha');
Expand Down Expand Up @@ -109,7 +107,9 @@ describe('utility methods', function() {
result.errorCount.should.equal(0);
result.warningCount.should.equal(1);
result.messages.should.be.instanceof(Array).and.have.lengthOf(1);
result.messages[0].message.should.equal('File ignored because it has a node_modules/** path');
result.messages[0].message.should.equal(
'File ignored because it has a node_modules/** path'
);

});

Expand Down

0 comments on commit 90841cb

Please sign in to comment.