diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..fe8b65f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# v0.1.1 +* Updated ESLint React settings with new rules implemented +* Added ESLint settings for Backbone diff --git a/app/index.js b/app/index.js index c021cbe..d21451a 100644 --- a/app/index.js +++ b/app/index.js @@ -234,6 +234,7 @@ module.exports = generators.Base.extend({ var devDependencies = [ 'browser-sync', 'del', + 'eslint-friendly-formatter', 'gulp', 'gulp-autoprefixer', 'gulp-eslint', @@ -281,7 +282,8 @@ module.exports = generators.Base.extend({ if (this.useBackbone) { devDependencies.push( - 'node-underscorify' + 'node-underscorify', + 'eslint-plugin-backbone' ); dependencies.push( 'backbone', diff --git a/app/templates/.eslintrc b/app/templates/.eslintrc index 7cdee0f..319d515 100644 --- a/app/templates/.eslintrc +++ b/app/templates/.eslintrc @@ -116,7 +116,7 @@ "computed-property-spacing": [2, "never"], "consistent-this": [2, "self"], "eol-last": 2, - "func-names": 2, + "func-names": 0, "func-style": [2, "expression"], "quotes": [1, "single"], "no-underscore-dangle": 0, @@ -126,21 +126,73 @@ }]<% if (useReact) { %>, // react - "react/display-name": 2, - "react/jsx-quotes": [2, "double", "avoid-escape"], - "react/jsx-uses-react": 1, - "react/jsx-uses-vars": 1, + "react/display-name": 0, + "react/jsx-boolean-value": 0, + "react/jsx-closing-bracket-location": 2, + "react/jsx-curly-spacing": 2, + "react/jsx-indent-props": [2, 4], + "react/jsx-max-props-per-line": 0, + "react/jsx-no-duplicate-props": 2, + "react/jsx-no-literals": 0, + "react/jsx-no-undef": 2, + "react/jsx-sort-prop-types": 0, + "react/jsx-sort-props": 0, + "react/jsx-uses-react": 2, + "react/jsx-uses-vars": 2, + "react/no-danger": 2, "react/no-did-mount-set-state": [1, "allow-in-func"], "react/no-did-update-set-state": 1, - "react/no-multi-comp": 1, - "react/no-unknown-property": 1, - "react/prop-types": 1, - "react/self-closing-comp": 1, - "react/wrap-multilines": 1<% } %><% if (useBackbone) { %>, + "react/no-multi-comp": 2, + "react/no-set-state": 0, + "react/no-unknown-property": 2, + "react/prop-types": 2, + "react/react-in-jsx-scope": 0, + "react/require-extension": 2, + "react/self-closing-comp": 2, + "react/sort-comp": 2, + "react/wrap-multilines": 2<% } %><% if (useBackbone) { %>, // backbone - // https://github.com/ilyavolodin/eslint-plugin-backbone - <% } %><% if (useBabel) { %> + "backbone/collection-model": 2, + "backbone/defaults-on-top": 2, + "backbone/event-scope": 0, // unfortunately this errors on jQuery events too which can't pass scope + "backbone/events-on-top": [2, [ + "id", + "el", + "tagName", + "className" + ]], + "backbone/initialize-on-top": [2, { + View: [ + "id", + "el", + "tagName", + "className", + "events" + ], + Model: [ + "defaults", + "url", + "urlRoot" + ], + Collection: [ + "model", + "url", + "comparator" + ] + }], + "backbone/model-defaults": 2, + "backbone/no-changed-set": 2, + "backbone/no-collection-models": 2, + "backbone/no-constructor": 2, + "backbone/no-el-assign": 2, + "backbone/no-model-attributes": 2, + "backbone/no-native-jquery": 0, + "backbone/no-silent": 0, + "backbone/no-view-collection-models": 2, + "backbone/no-view-model-attributes": 2, + "backbone/no-view-onoff-binding": 2, + "backbone/render-return": 2<% } %><% if (useBabel) { %>, // es6 <% } %> diff --git a/app/templates/gulp/tasks/lint.js b/app/templates/gulp/tasks/lint.js index 230a72b..18cb151 100644 --- a/app/templates/gulp/tasks/lint.js +++ b/app/templates/gulp/tasks/lint.js @@ -3,6 +3,7 @@ var gulp = require('gulp'), config = require('../config.json'), eslint = require('gulp-eslint'), + friendlyFormatter = require('eslint-friendly-formatter'), handleErrors = require('../utils/handle-errors'); gulp.task('lint', function() { @@ -13,7 +14,7 @@ gulp.task('lint', function() { '!' + config.js + '/**/*.min.js' ]) .pipe(eslint()) - .pipe(eslint.format()) + .pipe(eslint.format(friendlyFormatter)) .pipe(eslint.failAfterError()) .on('error', handleErrors); }); diff --git a/app/templates/package.json b/app/templates/package.json index 07cee52..6820e3d 100644 --- a/app/templates/package.json +++ b/app/templates/package.json @@ -1,7 +1,7 @@ { "name": "<%= slug %>", "description": "<%= description %>", - "version": "0.1.0", + "version": "0.1.1", "author": { "name": "<%= name %>", "email": "<%= email %>", @@ -15,8 +15,8 @@ "main": <% if (useBrowserify) { %>"js/app.js"<% } else { %>"js/main.js"<% } %><% if (useBrowserify && (usejQuery || useBackbone || useBabel || useReact)) { %>, "browserify": { "transform": [ - <% if (useBabel || useReact) { %>"babelify",<% } %> - <% if (useBackbone) { %>"browserify-shim", + <% if (useBabel || useReact) { %>"babelify"<% } %><% if (useBackbone) { %><% if (useBabel || useReact) { %>, + <% } %>"browserify-shim", "node-underscorify"<% } %> ] }<% if (usejQuery && useBackbone) { %>, diff --git a/app/templates/react/es6/app.js b/app/templates/react/es6/app.js index 00d2903..78c9e52 100644 --- a/app/templates/react/es6/app.js +++ b/app/templates/react/es6/app.js @@ -11,7 +11,6 @@ let routes = ( Router.run( routes, - Router.HistoryLocation, (Handler, state) => { React.render(, document.getElementById('wrapper')); } diff --git a/package.json b/package.json index c4fac85..a19ef69 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,22 @@ "app" ], "keywords": [ - "yeoman-generator" + "yeoman-generator", + "backbone", + "react", + "sass", + "css", + "javascript", + "front-end", + "eslint", + "gulp", + "autoprefixer", + "babel", + "jquery", + "lodash", + "sprites", + "icon fonts", + "icomoon" ], "dependencies": { "lodash": "^3.10.0",