Permalink
Browse files

Use Yeoman ESLint rule

  • Loading branch information...
zckrs committed Oct 14, 2015
1 parent 170d9e3 commit bc8f72a8b8d27e8e11c036ccee4f17dc03b7d852
Showing with 542 additions and 394 deletions.
  1. +1 −0 .eslintignore
  2. +125 −4 .eslintrc
  3. +2 −2 app/index.js
  4. +7 −7 app/src/bower.js
  5. +7 −6 app/src/files.js
  6. +1 −1 app/src/mock-options.js
  7. +13 −13 app/src/mock-prompts.js
  8. +1 −1 app/src/modules.js
  9. +2 −2 app/src/options.js
  10. +1 −1 app/src/paths.js
  11. +22 −22 app/src/preprocessors.js
  12. +14 −14 app/src/prompts.js
  13. +1 −1 app/src/router.js
  14. +5 −5 app/src/techs.js
  15. +2 −2 app/src/ui.js
  16. +2 −3 app/src/utils.js
  17. +5 −5 app/src/write.js
  18. +3 −1 scripts/buildBoilerplate.js
  19. +5 −5 test/inception.js
  20. +18 −18 test/inception/test-inception.js
  21. +17 −17 test/node/mock-generator.js
  22. +20 −20 test/node/test-bower.js
  23. +4 −4 test/node/test-files.js
  24. +6 −6 test/node/test-index.js
  25. +4 −4 test/node/test-modules.js
  26. +6 −6 test/node/test-options.js
  27. +11 −10 test/node/test-paths.js
  28. +17 −17 test/node/test-preprocessors.js
  29. +17 −17 test/node/test-prompts.js
  30. +6 −6 test/node/test-router.js
  31. +4 −4 test/node/test-techs.js
  32. +4 −4 test/node/test-ui.js
  33. +2 −2 test/node/test-utils.js
  34. +16 −15 test/node/test-writes.js
  35. +5 −4 test/template-cli.js
  36. +12 −11 test/template-tools.js
  37. +1 −1 test/template/mock-model.js
  38. +15 −14 test/template/test-bower.js
  39. +11 −10 test/template/test-build.js
  40. +7 −6 test/template/test-conf.js
  41. +6 −5 test/template/test-eslintrc.js
  42. +7 −6 test/template/test-gitignore.js
  43. +10 −9 test/template/test-index-html.js
  44. +12 −8 test/template/test-index-module-js.js
  45. +8 −7 test/template/test-inject.js
  46. +9 −8 test/template/test-karma-conf.js
  47. +6 −5 test/template/test-main-po.js
  48. +6 −5 test/template/test-markups.js
  49. +10 −9 test/template/test-package.js
  50. +6 −5 test/template/test-scripts.js
  51. +6 −5 test/template/test-server.js
  52. +7 −6 test/template/test-styles.js
  53. +18 −17 test/template/test-tsd.js
  54. +9 −8 test/template/test-watch.js
View
@@ -1,3 +1,4 @@
node_modules/
app/templates/
test/tmp/
coverage/
View
129 .eslintrc
@@ -1,9 +1,130 @@
{
"rules": {
"strict": [2, "global"],
"quotes": [2, "single"]
},
"extends": "eslint:recommended",
"env": {
"node": true
},
"rules": {
"array-bracket-spacing": [
2,
"never"
],
"brace-style": [
2,
"1tbs"
],
"consistent-return": 0,
"indent": [
2,
2
],
"no-multiple-empty-lines": [
2,
{
"max": 2
}
],
"no-use-before-define": [
2,
"nofunc"
],
"one-var": [
2,
"never"
],
"quote-props": [
2,
"as-needed"
],
"quotes": [
2,
"single"
],
"space-after-keywords": [
2,
"always"
],
"space-before-function-paren": [
2,
{
"anonymous": "always",
"named": "never"
}
],
"space-in-parens": [
2,
"never"
],
"strict": [
2,
"global"
],
"curly": [
2,
"all"
],
"eol-last": 2,
"key-spacing": [
2,
{
"beforeColon": false,
"afterColon": true
}
],
"no-eval": 2,
"no-with": 2,
"space-infix-ops": 2,
"dot-notation": [
2,
{
"allowKeywords": true
}
],
"eqeqeq": 2,
"no-alert": 2,
"no-caller": 2,
"no-empty-label": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-unused-expressions": 2,
"yoda": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-undef-init": 2,
"camelcase": 2,
"comma-spacing": 2,
"new-cap": 2,
"new-parens": 2,
"no-array-constructor": 2,
"no-extra-parens": 2,
"no-new-object": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-underscore-dangle": 2,
"semi": 2,
"semi-spacing": [
2,
{
"before": false,
"after": true
}
],
"space-return-throw-case": 2
}
}
View
@@ -21,8 +21,8 @@ var GulpAngularGenerator = yeoman.generators.Base.extend({
this.version = pkg.version;
this.insight = new Insight({
trackingCode: 'UA-66934495-2',
pkg: pkg
trackingCode: 'UA-66934495-2',
pkg: pkg
});
this.props = {};
View
@@ -2,7 +2,7 @@
var _ = require('lodash');
module.exports = function(GulpAngularGenerator) {
module.exports = function (GulpAngularGenerator) {
/**
* Prepare Bower overrides property to fix external bower.json with missing
@@ -60,7 +60,7 @@ module.exports = function(GulpAngularGenerator) {
if (this.props.router.key === 'new-router') {
bowerOverrides['angular-new-router'] = {
main: [ 'dist/router.es5.js' ]
main: ['dist/router.es5.js']
};
}
@@ -82,20 +82,20 @@ module.exports = function(GulpAngularGenerator) {
this.wiredepExclusions.push('/jquery/');
}
if (this.props.ui.key === 'bootstrap') {
if(this.props.bootstrapComponents.key !== 'official') {
if (this.props.bootstrapComponents.key !== 'official') {
this.wiredepExclusions.push('/\\\/bootstrap\\.js$/');
if(this.props.cssPreprocessor.extension === 'scss') {
if (this.props.cssPreprocessor.extension === 'scss') {
this.wiredepExclusions.push('/\\\/bootstrap-sass\\/.*\\.js/');
}
}
if(this.props.cssPreprocessor.key !== 'noCssPrepro') {
if (this.props.cssPreprocessor.key !== 'noCssPrepro') {
this.wiredepExclusions.push('/\\\/bootstrap\\.css/');
}
} else if (this.props.ui.key === 'foundation') {
if(this.props.foundationComponents.key !== 'official') {
if (this.props.foundationComponents.key !== 'official') {
this.wiredepExclusions.push('/foundation\\.js/');
}
if(this.props.cssPreprocessor.extension === 'scss') {
if (this.props.cssPreprocessor.extension === 'scss') {
this.wiredepExclusions.push('/foundation\\.css/');
}
}
View
@@ -10,17 +10,18 @@ var files = require('../files.json');
* Look for the js preprocessor equivalent file and use it if exist
*/
function resolvePaths(template) {
return function(file) {
var src = file, dest = file;
return function (file) {
var src = file;
var dest = file;
if(template) {
if (template) {
var basename = path.basename(file);
src = file.replace(basename, '_' + basename);
}
if(src.match(/\.js$/)) {
if (src.match(/\.js$/)) {
var preprocessorFile = this.sourceRoot() + '/' + src.replace(/\.js$/, '.' + this.props.jsPreprocessor.srcExtension);
if(this.fs.exists(preprocessorFile)) {
if (this.fs.exists(preprocessorFile)) {
src = src.replace(/\.js$/, '.' + this.props.jsPreprocessor.srcExtension);
dest = dest.replace(/\.js$/, '.' + this.props.jsPreprocessor.extension);
}
@@ -34,7 +35,7 @@ function resolvePaths(template) {
};
}
module.exports = function(GulpAngularGenerator) {
module.exports = function (GulpAngularGenerator) {
/**
* Prepare all files from files.json and add them to `this.files` as
View
@@ -13,7 +13,7 @@ var mockOptions = {
defaults: {}
};
options.forEach(function(option) {
options.forEach(function (option) {
mockOptions.defaults[option.name] = option.defaults;
});
View
@@ -29,55 +29,55 @@ var questions = [
var model = {};
questions.forEach(function(question) {
questions.forEach(function (question) {
model[question] = {
choices: _.findWhere(prompts, {name: question}).choices,
values: {}
};
});
model.angularVersion.choices.forEach(function(choice) {
model.angularVersion.choices.forEach(function (choice) {
var title = choice.name.substring(0, 3);
model.angularVersion.values[title] = choice.value;
});
model.angularModules.choices.forEach(function(choice) {
model.angularModules.choices.forEach(function (choice) {
model.angularModules.values[choice.value.name] = choice.value;
});
model.jQuery.choices.forEach(function(choice) {
model.jQuery.choices.forEach(function (choice) {
model.jQuery.values[choice.value.key] = choice.value;
});
model.resource.choices.forEach(function(choice) {
model.resource.choices.forEach(function (choice) {
model.resource.values[choice.value.key] = choice.value;
});
model.router.choices.forEach(function(choice) {
model.router.choices.forEach(function (choice) {
model.router.values[choice.value.key] = choice.value;
});
model.ui.choices.forEach(function(choice) {
model.ui.choices.forEach(function (choice) {
model.ui.values[choice.value.key] = choice.value;
});
model.bootstrapComponents.choices.forEach(function(choice) {
model.bootstrapComponents.choices.forEach(function (choice) {
model.bootstrapComponents.values[choice.value.key] = choice.value;
});
model.foundationComponents.choices.forEach(function(choice) {
model.foundationComponents.choices.forEach(function (choice) {
model.foundationComponents.values[choice.value.key] = choice.value;
});
model.cssPreprocessor.choices.forEach(function(choice) {
model.cssPreprocessor.choices.forEach(function (choice) {
model.cssPreprocessor.values[choice.value.key] = choice.value;
});
model.jsPreprocessor.choices.forEach(function(choice) {
model.jsPreprocessor.choices.forEach(function (choice) {
model.jsPreprocessor.values[choice.value.key] = choice.value;
});
model.htmlPreprocessor.choices.forEach(function(choice) {
model.htmlPreprocessor.choices.forEach(function (choice) {
model.htmlPreprocessor.values[choice.value.key] = choice.value;
});
@@ -86,7 +86,7 @@ module.exports = {
defaults: {
angularVersion: model.angularVersion.values['1.4'],
angularModules: _.pluck(model.angularModules.choices, 'value'),
jQuery: model.jQuery.values['jquery2'],
jQuery: model.jQuery.values.jquery2,
resource: model.resource.values['angular-resource'],
router: model.router.values['ui-router'],
ui: model.ui.values.bootstrap,
View
@@ -2,7 +2,7 @@
var _ = require('lodash');
module.exports = function(GulpAngularGenerator) {
module.exports = function (GulpAngularGenerator) {
/**
* Compute Angular's module to load and format the dependency list to insert
View
@@ -6,13 +6,13 @@ var s = require('underscore.string');
var options = require('../options.json');
module.exports = function(GulpAngularGenerator) {
module.exports = function (GulpAngularGenerator) {
/**
* Declares options in the generator (only used for the help messages)
*/
GulpAngularGenerator.prototype.defineOptions = function defineOptions() {
options.forEach(function(option) {
options.forEach(function (option) {
this.option(option.name, {
type: global[option.type],
required: option.required,
View
@@ -7,7 +7,7 @@ var utils = require('./utils.js');
var pathOptions = ['app-path', 'dist-path', 'e2e-path', 'tmp-path'];
module.exports = function(GulpAngularGenerator) {
module.exports = function (GulpAngularGenerator) {
/**
* Check paths options to refuse absolutes ones and normalize them
Oops, something went wrong.

0 comments on commit bc8f72a

Please sign in to comment.