Skip to content

Commit

Permalink
Use Yeoman ESLint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
zckrs committed Oct 14, 2015
1 parent 170d9e3 commit bc8f72a
Show file tree
Hide file tree
Showing 54 changed files with 542 additions and 394 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
app/templates/
test/tmp/
coverage/
129 changes: 125 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -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
}
}
4 changes: 2 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
14 changes: 7 additions & 7 deletions app/src/bower.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
};
}

Expand All @@ -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/');
}
}
Expand Down
13 changes: 7 additions & 6 deletions app/src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/src/mock-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var mockOptions = {
defaults: {}
};

options.forEach(function(option) {
options.forEach(function (option) {
mockOptions.defaults[option.name] = option.defaults;
});

Expand Down
26 changes: 13 additions & 13 deletions app/src/mock-prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit bc8f72a

Please sign in to comment.