diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..7bb186f6 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +node_modules/ +app/templates/ +test/tmp/ diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..eb3dc1bc --- /dev/null +++ b/.eslintrc @@ -0,0 +1,9 @@ +{ + "rules": { + "strict": [2, "global"], + "quotes": [2, "single"] + }, + "env": { + "node": true + } +} diff --git a/.gitignore b/.gitignore index 33d139cc..0ea753f6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ npm-debug.log .idea *.iml test/tmp -.jshintignore diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 8a764469..00000000 --- a/.jshintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "node": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "indent": 2, - "latedef": true, - "newcap": true, - "noarg": true, - "quotmark": "single", - "regexp": true, - "undef": true, - "unused": true, - "strict": true, - "trailing": true, - "smarttabs": true, - "white": true, - "validthis": true, - "globals": { - /* Angular Mocks */ - "inject": false, - /* MOCHA */ - "describe": false, - "it": false, - "before": false, - "beforeEach": false, - "after": false, - "afterEach": false - } -} diff --git a/app/src/mock-options.js b/app/src/mock-options.js index d365a743..fb237ccc 100644 --- a/app/src/mock-options.js +++ b/app/src/mock-options.js @@ -4,7 +4,7 @@ * * This module gets default yo options from options.json into a hash * to be reused in tests and other places that requires default options - * + * */ var options = require('../options.json'); diff --git a/app/src/prompts.js b/app/src/prompts.js index 04bcf2c4..bf416db4 100644 --- a/app/src/prompts.js +++ b/app/src/prompts.js @@ -19,20 +19,20 @@ module.exports = function(GulpAngularGenerator) { * Check if the default option is set, if it is, use defaults props and log them */ GulpAngularGenerator.prototype.defaultOption = function defaultOption() { - if (this.options['default']) { + if (this.options.default) { this.props = _.merge(this.props, mockPrompts.defaults); this.log('__________________________'); this.log('You use ' + chalk.green('--default') + ' option:'); - _.forEach(this.props, function(prop, key) { + _.forEach(this.props, function(propOrProps, key) { var prompt = _.find(prompts, {name: key}); - if(_.isArray(prop)) { - prop.forEach(function(prop) { + if(_.isArray(propOrProps)) { + propOrProps.forEach(function(prop) { logChoice.call(this, prompt, prop); }, this); } else { - logChoice.call(this, prompt, prop); + logChoice.call(this, prompt, propOrProps); } }, this); @@ -46,12 +46,12 @@ module.exports = function(GulpAngularGenerator) { GulpAngularGenerator.prototype.checkYoRc = function checkYoRc() { var done = this.async(); - if(this.config.get('props') && !this.options['default']) { + if(this.config.get('props') && !this.options.default) { this.prompt([{ type: 'confirm', name: 'skipConfig', message: 'Existing ' + chalk.green('.yo-rc') + ' configuration found, would you like to use it?', - default: true, + default: true }], function (answers) { this.skipConfig = answers.skipConfig; @@ -73,7 +73,7 @@ module.exports = function(GulpAngularGenerator) { * Complete responses with null answers for questions not asked */ GulpAngularGenerator.prototype.askQuestions = function askQuestions() { - if (this.skipConfig || this.options['default']) { + if (this.skipConfig || this.options.default) { return; } @@ -121,7 +121,7 @@ module.exports = function(GulpAngularGenerator) { this.qrCode = false; if (this.skipConfig || !this.options.advanced) { - return ; + return; } var done = this.async(); diff --git a/app/src/techs.js b/app/src/techs.js index e66b2c26..c6d22663 100644 --- a/app/src/techs.js +++ b/app/src/techs.js @@ -37,7 +37,7 @@ module.exports = function(GulpAngularGenerator) { .replace(/\n/g, '\n '); usedTechs.forEach(function(value) { - var path ='src/assets/images/' + listTechs[value].logo; + var path = 'src/assets/images/' + listTechs[value].logo; this.files.push({ src: path, diff --git a/app/src/write.js b/app/src/write.js index e899b9c5..df136935 100644 --- a/app/src/write.js +++ b/app/src/write.js @@ -2,8 +2,6 @@ var utils = require('./utils'); -var _ = require('lodash'); - module.exports = function(GulpAngularGenerator) { /** diff --git a/package.json b/package.json index 501658e1..0b33a5bc 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "coveralls": "~2.11.2", "cross-spawn": "~0.4.1", "ejs": "~2.3.1", + "eslint": "^0.24.0", "fixture-stdout": "~0.2.1", "istanbul": "~0.3.15", "js-beautify": "~1.5.6", diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000..83b73636 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,8 @@ +{ + "rules": { + "no-unused-expressions": 0 + }, + "env": { + "mocha": true + } +} diff --git a/test/inception/test-inception.js b/test/inception/test-inception.js index fdd896b4..ee26acc9 100644 --- a/test/inception/test-inception.js +++ b/test/inception/test-inception.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var inception = require('../inception'); diff --git a/test/mute.js b/test/mute.js index 0663374e..8ff09b60 100644 --- a/test/mute.js +++ b/test/mute.js @@ -20,13 +20,13 @@ var fixtureErr = new Fixture({ stream: process.stderr }); -var _writesOut = []; -var _writesErr = []; +var writesOut = []; +var writesErr = []; // Mute module.exports.mute = function () { fixtureOut.capture(function onWrite(string) { - _writesOut.push({ + writesOut.push({ string: string }); @@ -36,7 +36,7 @@ module.exports.mute = function () { fixtureErr.capture(function onWrite(string) { - _writesErr.push({ + writesErr.push({ string: string }); @@ -54,7 +54,7 @@ module.exports.unmute = function () { // Return the output that was captured module.exports.getMutedWrites = function () { return { - out: _writesOut, - err: _writesErr + out: writesOut, + err: writesErr }; }; diff --git a/test/node/mock-generator.js b/test/node/mock-generator.js index ac0c85b1..cfdba554 100644 --- a/test/node/mock-generator.js +++ b/test/node/mock-generator.js @@ -3,7 +3,7 @@ require('yeoman-generator'); var _ = require('lodash'); -module.exports = function() { +module.exports = function() { this._ = _; this.log = function() {}; this.async = function() { diff --git a/test/node/test-files.js b/test/node/test-files.js index b140cecd..57c4ff37 100644 --- a/test/node/test-files.js +++ b/test/node/test-files.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinon = require('sinon'); diff --git a/test/node/test-index.js b/test/node/test-index.js index 1688eb09..eefb1cbd 100644 --- a/test/node/test-index.js +++ b/test/node/test-index.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinon = require('sinon'); diff --git a/test/node/test-modules.js b/test/node/test-modules.js index e8304906..30be8a6f 100644 --- a/test/node/test-modules.js +++ b/test/node/test-modules.js @@ -1,14 +1,10 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); -var sinon = require('sinon'); var sinonChai = require('sinon-chai'); chai.should(); chai.use(sinonChai); -var _ = require('lodash'); - var Generator = require('./mock-generator'); var generator; @@ -34,7 +30,7 @@ describe('gulp-angular generator modules script', function () { router: { module: 'testModule1' }, ui: { module: 'testModule2' }, bootstrapComponents: { module: 'testModule3' }, - foundationComponents: { module: 'testModule4' }, + foundationComponents: { module: 'testModule4' } }; generator.computeModules(); generator.modulesDependencies.should.match(/\', \'/); diff --git a/test/node/test-paths.js b/test/node/test-paths.js index 3ba72c87..42e025da 100644 --- a/test/node/test-paths.js +++ b/test/node/test-paths.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinon = require('sinon'); diff --git a/test/node/test-preprocessors.js b/test/node/test-preprocessors.js index d88f961c..c37889bd 100644 --- a/test/node/test-preprocessors.js +++ b/test/node/test-preprocessors.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/node/test-prompts.js b/test/node/test-prompts.js index add9fafd..4e928c72 100644 --- a/test/node/test-prompts.js +++ b/test/node/test-prompts.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinon = require('sinon'); @@ -36,7 +35,7 @@ describe('gulp-angular generator prompts script', function () { it('should use default props if option is set', function() { sinon.spy(generator, 'log'); - generator.options['default'] = true; + generator.options.default = true; generator.defaultOption(); generator.props.should.be.deep.equal(mockPrompts.defaults); var logLines = 3 + _.flatten(_.values(generator.props)).length; diff --git a/test/node/test-router.js b/test/node/test-router.js index 256226d5..aa4e4a95 100644 --- a/test/node/test-router.js +++ b/test/node/test-router.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinon = require('sinon'); diff --git a/test/node/test-techs.js b/test/node/test-techs.js index c8ca18e0..af102c13 100644 --- a/test/node/test-techs.js +++ b/test/node/test-techs.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); @@ -35,8 +34,8 @@ describe('gulp-angular generator techs script', function () { ui: { key: 'tech-name-2' }, bootstrapComponents: { key: null }, foundationComponents: { key: 'none' }, - cssPreprocessor: { extension: 'default' }, - jsPreprocessor: { extension: 'css' }, + cssPreprocessor: { extension: 'default' }, + jsPreprocessor: { extension: 'css' }, htmlPreprocessor: { extension: 'official' } }; generator.files = []; diff --git a/test/node/test-ui.js b/test/node/test-ui.js index 282bb3ec..b6422168 100644 --- a/test/node/test-ui.js +++ b/test/node/test-ui.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); chai.should(); @@ -24,7 +23,7 @@ describe('gulp-angular generator ui script', function () { generator.props = { router: { module: null }, ui: { key: 'none' }, - cssPreprocessor: { key: 'none', extension: 'css' } + cssPreprocessor: { key: 'none', extension: 'css' } }; generator.files = []; generator.uiFiles(); @@ -39,7 +38,7 @@ describe('gulp-angular generator ui script', function () { generator.props = { router: { module: 'ngRoute' }, ui: { key: 'bootstrap' }, - cssPreprocessor: { key: 'notnone', extension: 'scss' } + cssPreprocessor: { key: 'notnone', extension: 'scss' } }; generator.files = []; generator.uiFiles(); @@ -58,7 +57,7 @@ describe('gulp-angular generator ui script', function () { jQuery: { key: 'jquery1' }, ui: { key: 'bootstrap' }, bootstrapComponents: { key: 'angular-bootstrap' }, - cssPreprocessor: { extension: 'scss' } + cssPreprocessor: { extension: 'scss' } }; generator.computeWiredepExclusions(); generator.wiredepExclusions[0].should.be.equal('/bootstrap\.js$/'); @@ -71,7 +70,7 @@ describe('gulp-angular generator ui script', function () { jQuery: { key: 'jquery1' }, ui: { key: 'bootstrap' }, bootstrapComponents: { key: 'angular-bootstrap' }, - cssPreprocessor: { extension: 'less' } + cssPreprocessor: { extension: 'less' } }; generator.computeWiredepExclusions(); generator.wiredepExclusions[0].should.be.equal('/bootstrap\.js$/'); @@ -83,7 +82,7 @@ describe('gulp-angular generator ui script', function () { jQuery: { key: 'jquery1' }, ui: { key: 'foundation' }, foundationComponents: { key: 'angular-foundation' }, - cssPreprocessor: { extension: 'scss' } + cssPreprocessor: { extension: 'scss' } }; generator.computeWiredepExclusions(); generator.wiredepExclusions[0].should.be.equal('/foundation\\.js/'); @@ -95,7 +94,7 @@ describe('gulp-angular generator ui script', function () { jQuery: { key: 'jquery1' }, ui: { key: 'foundation' }, foundationComponents: { key: 'angular-foundation' }, - cssPreprocessor: { extension: 'notscss' } + cssPreprocessor: { extension: 'notscss' } }; generator.computeWiredepExclusions(); generator.wiredepExclusions[0].should.be.equal('/foundation\\.js/'); diff --git a/test/node/test-writes.js b/test/node/test-writes.js index c80f8fba..ade6d1fa 100644 --- a/test/node/test-writes.js +++ b/test/node/test-writes.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinon = require('sinon'); diff --git a/test/template-tools.js b/test/template-tools.js index 3018f49a..9f4af0e7 100644 --- a/test/template-tools.js +++ b/test/template-tools.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint camelcase:false */ var fs = require('mz/fs'); var Promise = require('bluebird'); @@ -46,7 +45,7 @@ function compile(fileName) { fs.readFile(sourceFilePath) ]).then(function(results) { var content = results[1].toString(); - var sourceContent = sourceHeader + beautify(compileEjs(content), { indent_size: 2 }) + sourceFooter; + var sourceContent = sourceHeader + beautify(compileEjs(content), { 'indent_size': 2 }) + sourceFooter; sourceContent = sourceContent.replace('with(locals || {})', 'with(locals)'); return fs.writeFile(destinationFilePath, sourceContent); }); diff --git a/test/template/mock-model.js b/test/template/mock-model.js index 95acaaec..fed504e0 100644 --- a/test/template/mock-model.js +++ b/test/template/mock-model.js @@ -4,7 +4,7 @@ require('yeoman-generator'); var _ = require('lodash'); var mockPrompts = require('../../app/src/mock-prompts'); -module.exports = function() { +module.exports = function() { var props = _.extend(_.cloneDeep(mockPrompts.defaults), { paths: { src: null, diff --git a/test/template/test-bower.js b/test/template/test-bower.js index c95dc566..69e802e5 100644 --- a/test/template/test-bower.js +++ b/test/template/test-bower.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-build.js b/test/template/test-build.js index 90aeefe9..6429e773 100644 --- a/test/template/test-build.js +++ b/test/template/test-build.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); @@ -40,7 +39,7 @@ describe('gulp-angular build template', function () { }); it('should replace bootstrap font paths', function() { - model.computedPaths.appToBower = 'appToBower' + model.computedPaths.appToBower = 'appToBower'; model.props.ui.key = 'none'; model.props.cssPreprocessor.extension = 'css'; var result = build(model); diff --git a/test/template/test-conf.js b/test/template/test-conf.js index 6c02b99d..e382fd18 100644 --- a/test/template/test-conf.js +++ b/test/template/test-conf.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-gitignore.js b/test/template/test-gitignore.js index b9f4fd84..558cea73 100644 --- a/test/template/test-gitignore.js +++ b/test/template/test-gitignore.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-index-html.js b/test/template/test-index-html.js index 8c534a0c..597e5971 100644 --- a/test/template/test-index-html.js +++ b/test/template/test-index-html.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-index-module-js.js b/test/template/test-index-module-js.js index aa4f5442..3b09aceb 100644 --- a/test/template/test-index-module-js.js +++ b/test/template/test-index-module-js.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); @@ -35,7 +34,7 @@ describe('gulp-angular index js template', function () { it('should name the module as the app name and add modules dependencies in the module declaration', function() { model.appName = 'testAppName'; model.modulesDependencies = 'test value'; - var testJs = /angular\n \.module\('testAppName', \[test value\]\)/; + var testJs = /angular\n {4}\.module\('testAppName', \[test value\]\)/; var testEs6 = /angular\.module\('testAppName', \[test value\]\)/; var testTs = /angular\.module\('testAppName', \[test value\]\)/; var testCoffee = /angular\.module 'testAppName', \[test value\]/; diff --git a/test/template/test-inject.js b/test/template/test-inject.js index 65bf44fa..478d22fb 100644 --- a/test/template/test-inject.js +++ b/test/template/test-inject.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-jshintrc.js b/test/template/test-jshintrc.js index c60842aa..70a47fec 100644 --- a/test/template/test-jshintrc.js +++ b/test/template/test-jshintrc.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-karma-conf.js b/test/template/test-karma-conf.js index 3a1f3937..cfa51e2e 100644 --- a/test/template/test-karma-conf.js +++ b/test/template/test-karma-conf.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-main-po.js b/test/template/test-main-po.js index 05728603..63594fea 100644 --- a/test/template/test-main-po.js +++ b/test/template/test-main-po.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-markups.js b/test/template/test-markups.js index a2c7da61..de2d06d5 100644 --- a/test/template/test-markups.js +++ b/test/template/test-markups.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); @@ -30,7 +29,7 @@ describe('gulp-angular markups template', function () { model.props.htmlPreprocessor.key = 'jade'; result = markups(model); - result.should.match(/\$\.consolidate\('jade', \{ basedir: conf\.paths\.src, doctype: 'html', pretty: ' ' \}/); + result.should.match(/\$\.consolidate\('jade', \{ basedir: conf\.paths\.src, doctype: 'html', pretty: ' {2}' \}/); model.props.htmlPreprocessor.key = 'haml'; result = markups(model); diff --git a/test/template/test-package.js b/test/template/test-package.js index e6b1d2e0..31a38853 100644 --- a/test/template/test-package.js +++ b/test/template/test-package.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-server.js b/test/template/test-server.js index 9f0012f7..ea7c3382 100644 --- a/test/template/test-server.js +++ b/test/template/test-server.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-styles.js b/test/template/test-styles.js index 3b727ae9..5351296e 100644 --- a/test/template/test-styles.js +++ b/test/template/test-styles.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-tsd.js b/test/template/test-tsd.js index 2d0305e8..8167ab81 100644 --- a/test/template/test-tsd.js +++ b/test/template/test-tsd.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai'); diff --git a/test/template/test-watch.js b/test/template/test-watch.js index e0a35eb0..09b36635 100644 --- a/test/template/test-watch.js +++ b/test/template/test-watch.js @@ -1,5 +1,4 @@ 'use strict'; -/* jshint expr:true */ var chai = require('chai'); var sinonChai = require('sinon-chai');