Skip to content

Commit

Permalink
Added ESLint, fixed all violations
Browse files Browse the repository at this point in the history
Monster commit, but every change in here is related to a lint error
  • Loading branch information
bbyars committed Nov 16, 2015
1 parent 6d4c320 commit b85ea96
Show file tree
Hide file tree
Showing 75 changed files with 661 additions and 474 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/public/scripts/jquery/**/*.js
145 changes: 145 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"env": {
"node": true,
"browser": true,
"jquery": true,
"mocha": true
},
"rules": {
"accessor-pairs": 2,
"array-bracket-spacing": [2, "never"],
"arrow-body-style": [2, "as-needed"],
"arrow-parens": [2, "as-needed"],
"arrow-parens": [2, "as-needed"],
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "stroustrup", { "allowSingleLine": true }],
"camelcase": [2, {"properties": "always"}],
"comma-dangle": [2, "never"],
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"],
"computed-property-spacing": [2, "never"],
"consistent-return": 2,
"curly": 2,
"dot-location": [2, "object"],
"dot-notation": 2,
"eqeqeq": 2,
"generator-star-spacing": [2, {"before": true, "after": false}],
"handle-callback-err": [2, "error"],
"indent": [2, 4, {"SwitchCase": 1}],
"key-spacing": 2,
"linebreak-style": 2,
"max-depth": [2, 3],
"max-nested-callbacks": [2, 6],
"max-params": [2, 5],
"new-parens": 2,
"no-alert": 2,
"no-array-constructor": 2,
"no-arrow-condition": 2,
"no-bitwise": 2,
"no-caller": 2,
"no-case-declarations": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-const-assign": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-eq-null": 2,
//"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
//"no-inner-declarations": [2, "both"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-lonely-if": 2,
"no-loop-func": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, {"max": 2, "maxEOF": 1}],
"no-native-reassign": 2,
"no-negated-in-lhs": 2,
"no-nested-ternary": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
//"no-param-reassign": 2,
"no-path-concat": 2,
"no-plusplus": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": [2, "always"],
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-underscore-dangle": [2, { "allow": ["_links", "_behaviors", "_mode"] }],
"no-unexpected-multiline": 2,
"no-unneeded-ternary": 2,
"no-unreachable": 2,
"no-unused-expressions": 2,
"no-unused-vars": 2,
"no-use-before-define": 2,
"no-useless-call": 2,
"no-useless-concat": 2,
"no-void": 2,
"no-warning-comments": 1,
"no-with": 2,
"object-curly-spacing": [2, "always"],
//"one-var": [2, "always"],
"operator-assignment": [2, "always"],
"operator-linebreak": [2, "after"],
"quote-props": [2, "as-needed"],
"quotes": [2, "single", "avoid-escape"],
"require-yield": 2,
"semi": [2, "always"],
"semi-spacing": [2, {"before": false, "after": true}],
"space-after-keywords": 2,
"space-before-blocks": 2,
"space-before-function-paren": 2,
"space-before-keywords": [2, "always"],
"space-in-parens": [2, "never"],
"space-infix-ops": [2, {"int32Hint": false}],
"space-return-throw-case": 2,
"space-unary-ops": [1, { "words": true, "nonwords": false }],
"spaced-comment": [2, "always"],
"strict": [2, "global"],
"use-isnan": 2,
//"valid-jsdoc": 2,
"valid-typeof": 2,
"yoda": 2
}
}
16 changes: 14 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-mountebank');
grunt.loadNpmTasks('grunt-wslint');
grunt.loadNpmTasks('grunt-eslint');

grunt.initConfig({
mochaTest: {
Expand Down Expand Up @@ -43,6 +44,17 @@ module.exports = function (grunt) {
src: ['test/**/*.js']
}
},
eslint: {
target: [
'Gruntfile.js',
'src/**/*.js',
'tasks/**/*.js',
'test/**/*.js',
'functionalTest/**/*.js',
'performanceTest/**/*.js',
'bin/mb'
]
},
jshint: {
all: [
'Gruntfile.js',
Expand Down Expand Up @@ -80,7 +92,7 @@ module.exports = function (grunt) {
}
},
jsdoc: {
dist : {
dist: {
src: ['src/**/*.js'],
options: {
destination: 'docs',
Expand Down Expand Up @@ -133,7 +145,7 @@ module.exports = function (grunt) {
grunt.registerTask('test:performance', 'Run the performance tests', ['mochaTest:performance']);
grunt.registerTask('test', 'Run all non-performance tests', ['test:unit', 'test:functional']);
grunt.registerTask('coverage', 'Generate code coverage', ['mochaTest:coverage']);
grunt.registerTask('lint', 'Run all lint checks', ['wslint', 'jsCheck', 'deadCheck', 'jshint']);
grunt.registerTask('lint', 'Run all lint checks', ['wslint', 'jsCheck', 'deadCheck', 'eslint']);
grunt.registerTask('default', ['dist', 'version', 'test', 'lint']);

grunt.registerTask('local', 'Fast build for local development (avoids distribution)', ['test', 'lint']);
Expand Down
18 changes: 9 additions & 9 deletions bin/mb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function error (message) {
process.exit(1);
}

function processExists(pid) {
function processExists (pid) {
try {
// "As a special case, signal 0 can be used to test existence of process"
// https://nodejs.org/api/process.html#process_process_kill_pid_signal
Expand All @@ -59,16 +59,16 @@ function serverAt (options) {

return {
start: function () {
var server = mountebank.create(options);
var server = mountebank.create(options),
shutdown = function shutdown () {
if (fs.existsSync(options.pidfile)) {
fs.unlinkSync(options.pidfile);
}
server.close();
process.exit();
};

fs.writeFileSync(options.pidfile, process.pid.toString());
var shutdown = function shutdown () {
if (fs.existsSync(options.pidfile)) {
fs.unlinkSync(options.pidfile);
}
server.close();
process.exit();
};
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);
},
Expand Down
10 changes: 5 additions & 5 deletions functionalTest/api/foo/fooImposterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('foo imposter', function () {

describe('GET /imposters/:id', function () {
promiseIt('should provide access to all requests', function () {
var request = { protocol: 'foo', port: port, name: this.name };
var imposterRequest = { protocol: 'foo', port: port, name: this.name };

return api.post('/imposters', request).then(function () {
return api.post('/imposters', imposterRequest).then(function () {
return tcp.fireAndForget('first', port);
}).then(function () {
return tcp.fireAndForget('second', port);
Expand All @@ -44,8 +44,8 @@ describe('foo imposter', function () {
});

promiseIt('should return list of stubs in order', function () {
var first = { responses: [{ is: { data: '1' }}]},
second = { responses: [{ is: { data: '2' }}]},
var first = { responses: [{ is: { data: '1' } }] },
second = { responses: [{ is: { data: '2' } }] },
request = { protocol: 'foo', port: port, stubs: [first, second], name: this.name };

return api.post('/imposters', request).then(function () {
Expand All @@ -62,7 +62,7 @@ describe('foo imposter', function () {
});

promiseIt('should record matches against stubs', function () {
var stub = { responses: [{ is: { data: '1' }}, { is: { data: '2' }}]},
var stub = { responses: [{ is: { data: '1' } }, { is: { data: '2' } }] },
request = { protocol: 'foo', port: port, stubs: [stub], name: this.name };

return api.post('/imposters', request).then(function () {
Expand Down
13 changes: 9 additions & 4 deletions functionalTest/api/foo/fooStubTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('foo imposter', function () {
promiseIt('should allow a sequence of stubs as a circular buffer', function () {
var stub = {
predicates: [{ equals: { data: 'request' } }],
responses: [{ is: { data: 'first' }}, { is: { data: 'second' }}]
responses: [{ is: { data: 'first' } }, { is: { data: 'second' } }]
},
request = { protocol: 'foo', port: port, stubs: [stub], name: this.name };

Expand All @@ -59,7 +59,7 @@ describe('foo imposter', function () {

promiseIt('should only return stubbed response if matches complex predicate', function () {
var stub = {
responses: [{ is: { data: 'MATCH' }}],
responses: [{ is: { data: 'MATCH' } }],
predicates: [
{ equals: { data: 'test' } },
{ startsWith: { data: 'te' } }
Expand All @@ -84,8 +84,13 @@ describe('foo imposter', function () {
promiseIt('should allow proxy stubs', function () {
var originServerPort = port + 1,
originServerStub = { responses: [{ is: { data: 'PROXIED' } }] },
originServerRequest = { protocol: 'foo', port: originServerPort, stubs: [originServerStub], name: this.name + ' ORIGIN' },
proxyStub = { responses: [{ proxy: { to: { host: 'localhost', port: originServerPort } } }] },
originServerRequest = {
protocol: 'foo',
port: originServerPort,
stubs: [originServerStub],
name: this.name + ' ORIGIN'
},
proxyStub = { responses: [{ proxy: { to: { host: 'localhost', port: originServerPort } } }] },
proxyRequest = { protocol: 'foo', port: port, stubs: [proxyStub], name: this.name + ' PROXY' };

return api.post('/imposters', originServerRequest).then(function () {
Expand Down
10 changes: 5 additions & 5 deletions functionalTest/api/http/baseHttpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ function create (protocol) {

function optionsFor (spec) {
var defaults = {
hostname: 'localhost',
headers: { accept: 'application/json' },
rejectUnauthorized: false
};
hostname: 'localhost',
headers: { accept: 'application/json' },
rejectUnauthorized: false
};

return helpers.merge(defaults, spec);
}
Expand Down Expand Up @@ -55,7 +55,7 @@ function create (protocol) {
request.on('error', deferred.reject);

if (spec.body) {
if (typeof(spec.body) === 'object') {
if (typeof spec.body === 'object') {
request.write(JSON.stringify(spec.body));
}
else {
Expand Down
Loading

0 comments on commit b85ea96

Please sign in to comment.