From ac0130a5e3100b87bf08a515c367101a7ac1a831 Mon Sep 17 00:00:00 2001 From: Randy Coulman Date: Fri, 17 Jun 2016 14:41:15 -0700 Subject: [PATCH 1/2] Upgrade to latest eslint and eslint-plugin-react Add new rules to configurations. --- README.md | 6 +++--- index.js | 15 +++++++++++++++ package.json | 8 ++++---- react.js | 8 ++++++++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 465179b..f1c4d24 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ You can override settings from the configuration(s) by adding them directly to y We have added some additional optional configurations that you can add on top of the base `zeal` config: -* `zeal/react`: Adds rules for [React](https://github.com/reactjs) development. You'll need to install [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) `^5.1.1` to use this configuration. +* `zeal/react`: Adds rules for [React](https://github.com/reactjs) development. You'll need to install [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) to use this configuration. * `zeal/mocha`: Overrides rules for use with [Mocha](https://mochajs.org/). We recommend creating a separate `.eslintrc` file in the directory containing your tests and `extend`ing this config there. * `zeal/chai`: Overrides rules for use with [Chai](http://chaijs.com/). We recommend creating a separate `.eslintrc` file in the directory containing your tests and `extend`ing this config there. @@ -96,8 +96,8 @@ or, if your webpack config file is not in the default location: This plugin contains all of the rules available in: -* [ESLint](http://eslint.org/): 2.10.2 -* [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react): 5.1.1 +* [ESLint](http://eslint.org/): 2.13.0 +* [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react): 5.2.2 * [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import): 1.8.0 ## License diff --git a/index.js b/index.js index 5e4949e..0f8d0bf 100644 --- a/index.js +++ b/index.js @@ -64,6 +64,8 @@ module.exports = { // disallow the use of object properties of the global object (Math and // JSON) as functions 'no-obj-calls': 1, + // Disallow use of Object.prototypes builtins directly + 'no-prototype-builtins': 1, // disallow multiple spaces in a regular expression literal 'no-regex-spaces': 1, // disallow sparse arrays @@ -328,6 +330,8 @@ module.exports = { 'max-depth': 1, // specify the maximum length of a line in your program 'max-len': [1, 80, 2], + // enforce a maximum file length + 'max-lines': 0, // specify the maximum depth callbacks can be nested 'max-nested-callbacks': [1, 3], // limits the number of parameters that can be used in the function @@ -358,6 +362,8 @@ module.exports = { 'no-inline-comments': 0, // disallow if as the only statement in an else block 'no-lonely-if': 1, + // disallow mixes of different operators + 'no-mixed-operators': 1, // disallow mixed spaces and tabs for indentation 'no-mixed-spaces-and-tabs': 1, // disallow multiple empty lines @@ -384,6 +390,8 @@ module.exports = { 'no-underscore-dangle': 1, // disallow the use of ternary operators when a simpler alternative exists 'no-unneeded-ternary': 1, + // enforce consistent line breaks inside braces + 'object-curly-newline': 0, // require or disallow padding inside curly braces 'object-curly-spacing': [1, 'always'], // enforce placing object properties on separate lines @@ -426,6 +434,8 @@ module.exports = { // require or disallow a space immediately following the // or /* in a // comment 'spaced-comment': 1, + // require or disallow the Unicode BOM + 'unicode-bom': 1, // require regex literals to be wrapped in parentheses 'wrap-regex': 1, @@ -460,6 +470,9 @@ module.exports = { 'no-useless-computed-key': 1, // disallow unnecessary constructor 'no-useless-constructor': 1, + // disallow renaming import, export, and destructured assignments to the + // same name + 'no-useless-rename': 1, // require let or const instead of var 'no-var': 1, // require method and property shorthand syntax for object literals @@ -479,6 +492,8 @@ module.exports = { 'prefer-template': 1, // disallow generator functions that do not have yield 'require-yield': 1, + // enforce spacing between rest and spread operators and their expressions + 'rest-spread-spacing': 1, // enforce spacing around embedded expressions of template strings 'template-curly-spacing': 1, // enforce spacing around the * in yield* expressions diff --git a/package.json b/package.json index 3746260..1db55f2 100644 --- a/package.json +++ b/package.json @@ -35,14 +35,14 @@ ], "devDependencies": { "babel-eslint": "^6.0.4", - "eslint": "^2.10.2", - "eslint-find-rules": "^1.9.2", + "eslint": "^2.13.0", + "eslint-find-rules": "^1.10.0", "eslint-plugin-import": "^1.8.0", - "eslint-plugin-react": "^5.1.1" + "eslint-plugin-react": "^5.2.2" }, "peerDependencies": { "babel-eslint": "^6.0.4", - "eslint": "^2.10.2", + "eslint": "^2.13.0", "eslint-plugin-import": "^1.8.0" } } diff --git a/react.js b/react.js index 3fd0102..1ed8624 100644 --- a/react.js +++ b/react.js @@ -19,6 +19,8 @@ module.exports = { 'react/jsx-curly-spacing': 1, // Enforce or disallow spaces around equal signs in JSX attributes 'react/jsx-equals-spacing': 1, + // Restrict file extensions that may contain JSX + 'react/jsx-filename-extension': 0, // Enforce position of the first prop in JSX 'react/jsx-first-prop-new-line': [1, 'multiline'], // Enforce event handler naming conventions in JSX @@ -51,6 +53,8 @@ module.exports = { 'react/jsx-uses-react': 1, // Prevent variables used in JSX to be incorrectly marked as unused 'react/jsx-uses-vars': 1, + // Prevent comments from being inserted as text nodes + 'react/no-comment-textnodes': 1, // Prevent usage of dangerous JSX properties 'react/no-danger': 1, // Prevent usage of deprecated methods @@ -65,6 +69,8 @@ module.exports = { 'react/no-is-mounted': 1, // Prevent multiple component definition per file 'react/no-multi-comp': [1, { ignoreStateless: true }], + // Prevent usage of the return value of React.render + 'react/no-render-return-value': 1, // Prevent usage of setState 'react/no-set-state': 1, // Prevent using string references in ref attribute @@ -81,6 +87,8 @@ module.exports = { 'react/react-in-jsx-scope': 1, // Restrict file extensions that may be required 'react/require-extension': 1, + // Enforce React components to have a shouldComponentUpdate method + 'react/require-optimization': 0, // Enforce ES5 or ES6 class for returning value in render function 'react/require-render-return': 1, // Prevent extra closing tags for components without children From a797dcd33ad28a6173453e003e2b776fb7b31456 Mon Sep 17 00:00:00 2001 From: Randy Coulman Date: Mon, 20 Jun 2016 12:59:09 -0700 Subject: [PATCH 2/2] Upgrade to ESLint 2.13.1 This fixes a bug in relative paths that was making our build fail. --- README.md | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f1c4d24..4557b14 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ or, if your webpack config file is not in the default location: This plugin contains all of the rules available in: -* [ESLint](http://eslint.org/): 2.13.0 +* [ESLint](http://eslint.org/): 2.13.1 * [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react): 5.2.2 * [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import): 1.8.0 diff --git a/package.json b/package.json index 1db55f2..b88ed02 100644 --- a/package.json +++ b/package.json @@ -35,14 +35,14 @@ ], "devDependencies": { "babel-eslint": "^6.0.4", - "eslint": "^2.13.0", + "eslint": "^2.13.1", "eslint-find-rules": "^1.10.0", "eslint-plugin-import": "^1.8.0", "eslint-plugin-react": "^5.2.2" }, "peerDependencies": { "babel-eslint": "^6.0.4", - "eslint": "^2.13.0", + "eslint": "^2.13.1", "eslint-plugin-import": "^1.8.0" } }