From 2ad03c2ffadc04f48858c55a00675d331052120c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 19:44:34 +0200 Subject: [PATCH 01/10] Automatically created .eslintrc file (in json, to be compatible with grunt-eslint) --- .eslintrc.json | 261 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..4a3b497e0 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,261 @@ +{ + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "accessor-pairs": "error", + "array-bracket-spacing": "off", + "array-callback-return": "off", + "arrow-body-style": "error", + "arrow-parens": "off", + "arrow-spacing": [ + "error", + { + "after": true, + "before": true + } + ], + "block-scoped-var": "off", + "block-spacing": "off", + "brace-style": "off", + "callback-return": "off", + "camelcase": "off", + "capitalized-comments": "off", + "class-methods-use-this": "error", + "comma-dangle": "off", + "comma-spacing": "off", + "comma-style": "off", + "complexity": "off", + "computed-property-spacing": "off", + "consistent-return": "off", + "consistent-this": "off", + "curly": "off", + "default-case": "error", + "dot-location": [ + "error", + "property" + ], + "dot-notation": "off", + "eol-last": "off", + "eqeqeq": "off", + "func-call-spacing": "off", + "func-name-matching": "error", + "func-names": "off", + "func-style": "off", + "generator-star-spacing": "error", + "global-require": "off", + "guard-for-in": "off", + "handle-callback-err": "off", + "id-blacklist": "error", + "id-length": "off", + "id-match": "error", + "indent": "off", + "init-declarations": "off", + "jsx-quotes": "error", + "key-spacing": "off", + "keyword-spacing": "off", + "line-comment-position": "off", + "linebreak-style": "off", + "lines-around-comment": "off", + "lines-around-directive": "off", + "max-depth": "off", + "max-len": "off", + "max-lines": "off", + "max-nested-callbacks": "error", + "max-params": "off", + "max-statements": "off", + "max-statements-per-line": "off", + "multiline-ternary": "off", + "new-parens": "error", + "newline-after-var": "off", + "newline-before-return": "off", + "newline-per-chained-call": "off", + "no-alert": "error", + "no-array-constructor": "error", + "no-await-in-loop": "error", + "no-bitwise": "off", + "no-caller": "error", + "no-catch-shadow": "off", + "no-compare-neg-zero": "error", + "no-confusing-arrow": "error", + "no-continue": "off", + "no-div-regex": "error", + "no-duplicate-imports": "error", + "no-else-return": "off", + "no-empty-function": "off", + "no-eq-null": "off", + "no-eval": "off", + "no-extend-native": "error", + "no-extra-bind": "error", + "no-extra-label": "error", + "no-extra-parens": "off", + "no-floating-decimal": "error", + "no-implicit-coercion": [ + "error", + { + "boolean": false, + "number": false, + "string": false + } + ], + "no-implicit-globals": "error", + "no-implied-eval": "error", + "no-inline-comments": "off", + "no-inner-declarations": [ + "error", + "functions" + ], + "no-invalid-this": "off", + "no-iterator": "error", + "no-label-var": "error", + "no-labels": "error", + "no-lone-blocks": "error", + "no-lonely-if": "off", + "no-loop-func": "error", + "no-magic-numbers": "off", + "no-mixed-operators": "off", + "no-mixed-requires": "off", + "no-multi-assign": "off", + "no-multi-spaces": "off", + "no-multi-str": "error", + "no-multiple-empty-lines": "off", + "no-native-reassign": "error", + "no-negated-condition": "off", + "no-negated-in-lhs": "error", + "no-nested-ternary": "off", + "no-new": "error", + "no-new-func": "off", + "no-new-object": "error", + "no-new-require": "error", + "no-new-wrappers": "error", + "no-octal-escape": "error", + "no-param-reassign": "off", + "no-path-concat": "error", + "no-plusplus": "off", + "no-process-env": "off", + "no-process-exit": "off", + "no-proto": "error", + "no-prototype-builtins": "off", + "no-restricted-globals": "error", + "no-restricted-imports": "error", + "no-restricted-modules": "error", + "no-restricted-properties": "error", + "no-restricted-syntax": "error", + "no-return-assign": "off", + "no-return-await": "error", + "no-script-url": "error", + "no-self-compare": "off", + "no-sequences": "off", + "no-shadow": "off", + "no-shadow-restricted-names": "off", + "no-spaced-func": "off", + "no-sync": "off", + "no-tabs": "off", + "no-template-curly-in-string": "off", + "no-ternary": "off", + "no-throw-literal": "off", + "no-trailing-spaces": "off", + "no-undef-init": "off", + "no-undefined": "off", + "no-underscore-dangle": "off", + "no-unmodified-loop-condition": "off", + "no-unneeded-ternary": "off", + "no-unused-expressions": "off", + "no-use-before-define": "off", + "no-useless-call": "off", + "no-useless-computed-key": "error", + "no-useless-concat": "off", + "no-useless-constructor": "error", + "no-useless-escape": "off", + "no-useless-rename": "error", + "no-useless-return": "error", + "no-var": "off", + "no-void": "off", + "no-warning-comments": "error", + "no-whitespace-before-property": "error", + "no-with": "error", + "nonblock-statement-body-position": [ + "error", + "any" + ], + "object-curly-newline": "off", + "object-curly-spacing": "off", + "object-property-newline": "off", + "object-shorthand": "off", + "one-var": "off", + "one-var-declaration-per-line": "off", + "operator-assignment": "off", + "operator-linebreak": "off", + "padded-blocks": "off", + "prefer-arrow-callback": "off", + "prefer-const": "off", + "prefer-destructuring": [ + "error", + { + "array": false, + "object": false + } + ], + "prefer-numeric-literals": "error", + "prefer-promise-reject-errors": "error", + "prefer-reflect": "off", + "prefer-rest-params": "off", + "prefer-spread": "off", + "prefer-template": "off", + "quote-props": "off", + "quotes": "off", + "radix": [ + "error", + "always" + ], + "require-await": "error", + "require-jsdoc": "off", + "rest-spread-spacing": "error", + "semi": "off", + "semi-spacing": "off", + "sort-imports": "error", + "sort-keys": "off", + "sort-vars": "off", + "space-before-blocks": "off", + "space-before-function-paren": "off", + "space-in-parens": "off", + "space-infix-ops": "off", + "space-unary-ops": [ + "error", + { + "nonwords": false, + "words": false + } + ], + "spaced-comment": "off", + "strict": "off", + "symbol-description": "error", + "template-curly-spacing": [ + "error", + "never" + ], + "template-tag-spacing": "error", + "unicode-bom": [ + "error", + "never" + ], + "valid-jsdoc": "off", + "valid-typeof": [ + "error", + { + "requireStringLiterals": false + } + ], + "vars-on-top": "off", + "wrap-iife": "off", + "wrap-regex": "off", + "yield-star-spacing": "error", + "yoda": "off" + } +} \ No newline at end of file From a3ed9d9d59b41427758e0e8d8a7b65ae4946d9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 20:11:07 +0200 Subject: [PATCH 02/10] Changed some errors to be warnings, whilst solving related questions on github --- .eslintrc.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.eslintrc.json b/.eslintrc.json index 4a3b497e0..2c7a5baa9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -85,9 +85,16 @@ "no-compare-neg-zero": "error", "no-confusing-arrow": "error", "no-continue": "off", + "no-console": "warn", "no-div-regex": "error", "no-duplicate-imports": "error", "no-else-return": "off", + "no-empty": [ + "error", + { + "allowEmptyCatch": true + } + ], "no-empty-function": "off", "no-eq-null": "off", "no-eval": "off", @@ -96,6 +103,7 @@ "no-extra-label": "error", "no-extra-parens": "off", "no-floating-decimal": "error", + "no-extra-boolean-cast": "warn", "no-implicit-coercion": [ "error", { @@ -163,10 +171,12 @@ "no-trailing-spaces": "off", "no-undef-init": "off", "no-undefined": "off", + "no-undef": "off", "no-underscore-dangle": "off", "no-unmodified-loop-condition": "off", "no-unneeded-ternary": "off", "no-unused-expressions": "off", + "no-unused-vars": "warn", "no-use-before-define": "off", "no-useless-call": "off", "no-useless-computed-key": "error", From 066094b46f1ce2fd6ee17282bbdb13f9398ab3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 20:12:23 +0200 Subject: [PATCH 03/10] Added .eslintignore --- .eslintignore | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..410486937 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,14 @@ +node_modules +examples/node_modules +examples/**/_package/ +*.min.js +client/src/renderers/support/jade-runtime.js +src/components/oc-client/src/head.load.js +src/components/oc-client/_package/**/* +src/components/base-component-handlebars/_package/**/* +src/components/base-component-handlebars/server.js +src/components/base-component-jade/_package/**/* +src/components/base-component-jade/server.js +test/fixtures +test/front-end +test/configuration \ No newline at end of file From d4ee4a479dfbe8c82361d682f007afded9642c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 20:22:53 +0200 Subject: [PATCH 04/10] Fixed tab indentation to be spaced --- src/registry/routes/helpers/apply-default-values.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registry/routes/helpers/apply-default-values.js b/src/registry/routes/helpers/apply-default-values.js index dc26d7b01..83811ef4f 100644 --- a/src/registry/routes/helpers/apply-default-values.js +++ b/src/registry/routes/helpers/apply-default-values.js @@ -8,7 +8,7 @@ module.exports = function(requestParameters, expectedParameters) { }); _.forEach(optionalParametersWithDefaults, function(expectedParameter, expectedParameterName){ - var param = requestParameters[expectedParameterName]; + var param = requestParameters[expectedParameterName]; if(_.isUndefined(param) || _.isNull(param)) { requestParameters[expectedParameterName] = expectedParameter.default; } From a7098d784447a71669ef2139a2809ca360c85200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 20:27:19 +0200 Subject: [PATCH 05/10] Removed .jshintrc (and its container folder) --- tasks/support/.jshintrc | 81 ----------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 tasks/support/.jshintrc diff --git a/tasks/support/.jshintrc b/tasks/support/.jshintrc deleted file mode 100644 index 2de0b3e74..000000000 --- a/tasks/support/.jshintrc +++ /dev/null @@ -1,81 +0,0 @@ -{ - - "maxerr" : 50, // {int} Maximum error before stopping - - "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : true, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison - "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() - "immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "indent" : 2, // {int} Number of spaces to use for indentation - "latedef" : true, // true: Require variables/functions to be defined before being used - "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonew" : true, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : "single", // Quotation mark consistency: - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : false, // true: Require all defined variables be used - "strict" : true, // true: Requires all functions run in ES5 Strict Mode - "maxparams" : 8, // {int} Max number of formal params allowed per function - "maxdepth" : 4, // {int} Max depth of nested blocks (within functions) - "maxstatements" : 100, // {int} Max number statements per function - "maxlen" : 170, // {int} Max number of characters per line - - "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : false, // true: Tolerate assignments where comparisons would be expected - "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : true, // true: Tolerate use of `== null` - "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) - "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : false, // true: Tolerate use of `eval` and `new Function()` - "expr" : true, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : false, // true: Tolerate defining variables inside control statements - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') - "iterator" : false, // true: Tolerate using the `__iterator__` property - "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : true, // true: Tolerate possibly unsafe line breakings - "laxcomma" : false, // true: Tolerate comma-first style coding - "loopfunc" : false, // true: Tolerate functions being defined in loops - "multistr" : false, // true: Tolerate multi-line strings - "proto" : false, // true: Tolerate using the `__proto__` property - "scripturl" : false, // true: Tolerate script-targeted URLs - "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : true, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : false, // true: Tolerate using this in a non-constructor function - - "browser" : false, // Web Browser (window, document, etc) - "couch" : false, // CouchDB - "devel" : true, // Development/debugging (alert, confirm, etc) - "dojo" : false, // Dojo Toolkit - "jquery" : false, // jQuery - "mootools" : false, // MooTools - "node" : true, // Node.js - "nonstandard" : true, // Widely adopted globals (escape, unescape, etc) - "prototypejs" : false, // Prototype and Scriptaculous - "rhino" : false, // Rhino - "worker" : false, // Web Workers - "wsh" : false, // Windows Scripting Host - "yui" : false, // Yahoo User Interface - - "predef" : [ - "console", - "jQuery", - "$", - "window", - "componentsList", - "q", - "thisComponentHref", - "describe", - "it", - "before", - "beforeEach", - "after", - "afterEach", - "define" - ] -} From e72219b89d603b48e4f4cc998c245e88277d51d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 20:30:04 +0200 Subject: [PATCH 06/10] Use eslint instead of jshint in grunt --- Gruntfile.js | 6 +++--- package.json | 2 +- tasks/eslint.js | 5 +++++ tasks/jshint.js | 25 ------------------------- 4 files changed, 9 insertions(+), 29 deletions(-) create mode 100644 tasks/eslint.js delete mode 100644 tasks/jshint.js diff --git a/Gruntfile.js b/Gruntfile.js index 3bb76bfab..42ec1afba 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,9 +23,9 @@ module.exports = function(grunt){ grunt.registerTask('default', ['test-local', 'build']); grunt.registerTask('sauce', ['karma:sauce-linux', 'karma:sauce-osx', 'karma:sauce-windows']); - grunt.registerTask('test-local', ['jshint:all', 'mochaTest:unit', 'mochaTest:acceptance', 'karma:local']); - grunt.registerTask('test-local-silent', ['jshint:all', 'mochaTest:silent', 'karma:local']); - grunt.registerTask('test', ['jshint:all', 'mochaTest:unit', 'mochaTest:integration', 'mochaTest:acceptance']); + grunt.registerTask('test-local', ['eslint', 'mochaTest:unit', 'mochaTest:acceptance', 'karma:local']); + grunt.registerTask('test-local-silent', ['eslint', 'mochaTest:silent', 'karma:local']); + grunt.registerTask('test', ['eslint', 'mochaTest:unit', 'mochaTest:integration', 'mochaTest:acceptance']); grunt.registerTask('git-stage', [ 'gitadd:versionFiles', 'gitcommit:version', diff --git a/package.json b/package.json index d1cf16b49..947dbf9ad 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "chai": "1.10.0", "cheerio": "0.22.0", "grunt": "^1.0.1", - "grunt-contrib-jshint": "^1.0.0", + "grunt-eslint": "^19.0.0", "grunt-git": "^1.0.0", "grunt-karma": "^2.0.0", "grunt-mocha-test": "^0.12.7", diff --git a/tasks/eslint.js b/tasks/eslint.js new file mode 100644 index 000000000..4ddf3fad4 --- /dev/null +++ b/tasks/eslint.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + target: ['.'] +}; diff --git a/tasks/jshint.js b/tasks/jshint.js deleted file mode 100644 index e22b89a0f..000000000 --- a/tasks/jshint.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -module.exports = { - options: { - jshintrc: 'tasks/support/.jshintrc', - ignores: [ - 'node_modules', - 'examples/node_modules', - 'examples/**/_package/', - 'client/src/oc-client.min.js', - 'client/src/renderers/support/jade-runtime.js', - 'src/components/oc-client/src/head.load.js', - 'src/components/oc-client/src/oc-client.min.js', - 'src/components/oc-client/_package/**/*', - 'src/components/base-component-handlebars/_package/**/*', - 'src/components/base-component-handlebars/server.js', - 'src/components/base-component-jade/_package/**/*', - 'src/components/base-component-jade/server.js', - 'test/fixtures', - 'test/front-end', - 'test/configuration' - ] - }, - all: ['.'] -}; From 94264975a56fe7cc4ce225930e2ed31bbf5ede99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 20:30:47 +0200 Subject: [PATCH 07/10] Removed unreachable code --- .../cli-domain-package-server-script.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/cli-domain-package-server-script/cli-domain-package-server-script.js b/test/integration/cli-domain-package-server-script/cli-domain-package-server-script.js index 1354acf33..0bacaf7c1 100644 --- a/test/integration/cli-domain-package-server-script/cli-domain-package-server-script.js +++ b/test/integration/cli-domain-package-server-script/cli-domain-package-server-script.js @@ -63,7 +63,6 @@ describe('cli : domain : package-server-script', function(){ } catch(e) { return done(e); } - return done('error'); } ); } catch (e) { From 4d7547922ecf71426d7951ce1f06345317c8db32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 20:36:57 +0200 Subject: [PATCH 08/10] Setting no-unsed-vars to error --- .eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 2c7a5baa9..eb97280f5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -176,7 +176,7 @@ "no-unmodified-loop-condition": "off", "no-unneeded-ternary": "off", "no-unused-expressions": "off", - "no-unused-vars": "warn", + "no-unused-vars": "error", "no-use-before-define": "off", "no-useless-call": "off", "no-useless-computed-key": "error", From ef81c2422bd1da17c1489ba8391b0ef7af86b89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 21:04:55 +0200 Subject: [PATCH 09/10] Fixed no-unused-vars issues --- src/cli/domain/package-template.js | 5 +-- .../registry/registry-with-fallback.js | 2 - test/unit/client-warmup.js | 10 ++--- test/unit/client.js | 3 +- test/unit/registry-domain-components-cache.js | 1 + test/unit/registry-domain-extract-package.js | 3 +- test/unit/registry-domain-nested-renderer.js | 5 +-- .../registry-domain-plugins-initialiser.js | 45 +++++++------------ 8 files changed, 27 insertions(+), 47 deletions(-) diff --git a/src/cli/domain/package-template.js b/src/cli/domain/package-template.js index eb5ae7c1a..3b813c686 100644 --- a/src/cli/domain/package-template.js +++ b/src/cli/domain/package-template.js @@ -43,15 +43,14 @@ var compileView = function(viewPath, type, cb) { module.exports = function(params, callback){ var viewSrc = params.ocOptions.files.template.src, - viewPath = path.join(params.componentPath, viewSrc), - compiled; + viewPath = path.join(params.componentPath, viewSrc); if(!fs.existsSync(viewPath)){ return callback(format(strings.errors.cli.TEMPLATE_NOT_FOUND, viewSrc)); } try { - compiled = compileView(viewPath, params.ocOptions.files.template.type, (err, compiled) => { + compileView(viewPath, params.ocOptions.files.template.type, (err, compiled) => { if (err) { return callback(format('{0} compilation failed - {1}', viewSrc, err)); } diff --git a/test/acceptance/registry/registry-with-fallback.js b/test/acceptance/registry/registry-with-fallback.js index e04e0e561..d55c6f90a 100644 --- a/test/acceptance/registry/registry-with-fallback.js +++ b/test/acceptance/registry/registry-with-fallback.js @@ -7,7 +7,6 @@ var request = require('minimal-request'); describe('registry', function(){ describe('when fallbackRegistryUrl is specified', function(){ var oc = require('../../../src/index'); - var error; var fallbackRegistry; var registry; var result; @@ -27,7 +26,6 @@ describe('registry', function(){ function next(done){ return function(e, r){ - error = e; result = r; done(); }; diff --git a/test/unit/client-warmup.js b/test/unit/client-warmup.js index 1b432abd5..6d20da681 100644 --- a/test/unit/client-warmup.js +++ b/test/unit/client-warmup.js @@ -23,7 +23,7 @@ describe('client : warmup', function(){ describe('when warming up the client for responsive components', function(){ - var error, response, renderComponentStub; + var error, renderComponentStub; beforeEach(function(done){ initialise(); @@ -40,9 +40,8 @@ describe('client : warmup', function(){ } }, renderComponentStub); - warmup({}, function(err, res){ + warmup({}, function(err){ error = err; - response = res; done(); }); }); @@ -64,7 +63,7 @@ describe('client : warmup', function(){ }); describe('when warming up the client for component with parameters', function(){ - var error, response, renderComponentStub; + var error, renderComponentStub; beforeEach(function(done){ initialise(null, { @@ -93,9 +92,8 @@ describe('client : warmup', function(){ } }, renderComponentStub); - warmup({}, function(err, res){ + warmup({}, function(err){ error = err; - response = res; done(); }); }); diff --git a/test/unit/client.js b/test/unit/client.js index 217525c74..3055ae85b 100644 --- a/test/unit/client.js +++ b/test/unit/client.js @@ -7,7 +7,6 @@ var sinon = require('sinon'); describe('client', function(){ var validatorStub, - client, Client, init; @@ -23,7 +22,7 @@ describe('client', function(){ before(function(){ initialise(); validatorStub.returns({ isValid: false, error: 'argh!' }); - init = function(){ client = new Client(); }; + init = function(){ Client(); }; }); it('should throw an exception', function(){ diff --git a/test/unit/registry-domain-components-cache.js b/test/unit/registry-domain-components-cache.js index a99d1e16b..dc0ae54d1 100644 --- a/test/unit/registry-domain-components-cache.js +++ b/test/unit/registry-domain-components-cache.js @@ -1,4 +1,5 @@ 'use strict'; +/* eslint no-unused-vars: 'off' */ var expect = require('chai').expect; var injctr = require('injectr'); diff --git a/test/unit/registry-domain-extract-package.js b/test/unit/registry-domain-extract-package.js index 458057f2d..b57779d4b 100644 --- a/test/unit/registry-domain-extract-package.js +++ b/test/unit/registry-domain-extract-package.js @@ -17,7 +17,7 @@ describe('registry : domain : extract-package', function(){ describe('when successfully extracting package', function(){ - var error, response; + var response; beforeEach(function(done){ pathResolveStub.reset(); @@ -33,7 +33,6 @@ describe('registry : domain : extract-package', function(){ path: '/some-path/registry/temp/1478279453422.tar.gz' } }, function(err, res){ - error = err; response = res; done(); }); diff --git a/test/unit/registry-domain-nested-renderer.js b/test/unit/registry-domain-nested-renderer.js index 29f47e7a0..efecec465 100644 --- a/test/unit/registry-domain-nested-renderer.js +++ b/test/unit/registry-domain-nested-renderer.js @@ -69,7 +69,7 @@ describe('registry : routes : helpers : nested-renderer', function(){ describe('when requesting a not existent component', function(){ - var result, error; + var error; beforeEach(function(done){ initialise({ status: 404, @@ -78,8 +78,7 @@ describe('registry : routes : helpers : nested-renderer', function(){ } }); - nestedRenderer.renderComponent('404-component', {}, function(err, res){ - result = res; + nestedRenderer.renderComponent('404-component', {}, function(err){ error = err; done(); }); diff --git a/test/unit/registry-domain-plugins-initialiser.js b/test/unit/registry-domain-plugins-initialiser.js index 8810bb866..a9ba6acb5 100644 --- a/test/unit/registry-domain-plugins-initialiser.js +++ b/test/unit/registry-domain-plugins-initialiser.js @@ -10,16 +10,15 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugin not registered correctly', function(){ - var result, error; + var error; beforeEach(function(done){ var plugins = [{ name: 'doSomething' }]; - pluginsInitialiser.init(plugins, function(err, res){ + pluginsInitialiser.init(plugins, function(err){ error = err; - result = res; done(); }); }); @@ -31,7 +30,7 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugin is anonymous', function(){ - var result, error; + var error; beforeEach(function(done){ var plugins = [{ @@ -41,9 +40,8 @@ describe('registry : domain : plugins-initialiser', function(){ } }]; - pluginsInitialiser.init(plugins, function(err, res){ + pluginsInitialiser.init(plugins, function(err){ error = err; - result = res; done(); }); }); @@ -55,7 +53,7 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugin does not expose a register method', function(){ - var result, error; + var error; beforeEach(function(done){ var plugins = [{ @@ -63,9 +61,8 @@ describe('registry : domain : plugins-initialiser', function(){ register: { execute: function(){}} }]; - pluginsInitialiser.init(plugins, function(err, res){ + pluginsInitialiser.init(plugins, function(err){ error = err; - result = res; done(); }); }); @@ -77,7 +74,7 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugin does not expose an execute method', function(){ - var result, error; + var error; beforeEach(function(done){ var plugins = [{ @@ -85,9 +82,8 @@ describe('registry : domain : plugins-initialiser', function(){ register: { register: function(){}} }]; - pluginsInitialiser.init(plugins, function(err, res){ + pluginsInitialiser.init(plugins, function(err){ error = err; - result = res; done(); }); }); @@ -100,7 +96,7 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when initialising valid plugins', function(){ - var passedOptions, flag, error, result; + var passedOptions, flag, result; beforeEach(function(done){ var plugins = [{ @@ -133,7 +129,6 @@ describe('registry : domain : plugins-initialiser', function(){ }]; pluginsInitialiser.init(plugins, function(err, res){ - error = err; result = res; done(); }); @@ -159,7 +154,7 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugin specifies dependencies', function(){ - var passedDeps, flag, error, result; + var passedDeps, flag; beforeEach(function(done){ var plugins = [{ @@ -187,9 +182,7 @@ describe('registry : domain : plugins-initialiser', function(){ options: {} }]; - pluginsInitialiser.init(plugins, function(err, res){ - error = err; - result = res; + pluginsInitialiser.init(plugins, function(){ done(); }); }); @@ -201,14 +194,13 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugins have a circular dependency', function(){ - var passedDeps, flag, error, result; + var flag, error; beforeEach(function(done){ var plugins = [{ name: 'getValue', register: { register: function(options, deps, cb){ - passedDeps = deps; cb(); }, execute: function(){}, @@ -230,9 +222,8 @@ describe('registry : domain : plugins-initialiser', function(){ } }]; - pluginsInitialiser.init(plugins, function(err, res){ + pluginsInitialiser.init(plugins, function(err){ error = err; - result = res; done(); }); }); @@ -244,14 +235,13 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugin depends on a plugin that is not registered', function(){ - var passedDeps, error, result; + var error; beforeEach(function(done){ var plugins = [{ name: 'getValue', register: { register: function(options, deps, cb){ - passedDeps = deps; cb(); }, execute: function(){}, @@ -260,9 +250,8 @@ describe('registry : domain : plugins-initialiser', function(){ options: {} }]; - pluginsInitialiser.init(plugins, function(err, res){ + pluginsInitialiser.init(plugins, function(err){ error = err; - result = res; done(); }); }); @@ -274,7 +263,7 @@ describe('registry : domain : plugins-initialiser', function(){ describe('when plugin chain requires multiple passes', function(){ - var passedDeps, flag, error, result; + var flag, result; beforeEach(function(done){ var plugins = [{ @@ -292,7 +281,6 @@ describe('registry : domain : plugins-initialiser', function(){ name: 'getValue', register: { register: function(options, deps, cb){ - passedDeps = deps; cb(); }, execute: function(){}, @@ -314,7 +302,6 @@ describe('registry : domain : plugins-initialiser', function(){ }]; pluginsInitialiser.init(plugins, function(err, res){ - error = err; result = res; done(); }); From 0bc756a2d90bc228bfa10616098d04d7110811e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=92scar=20Casajuana?= Date: Fri, 7 Apr 2017 23:17:32 +0200 Subject: [PATCH 10/10] Set semi: ["error", "always"] --- .eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index eb97280f5..ddb802b84 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -227,7 +227,7 @@ "require-await": "error", "require-jsdoc": "off", "rest-spread-spacing": "error", - "semi": "off", + "semi": ["error", "always"], "semi-spacing": "off", "sort-imports": "error", "sort-keys": "off",