From ade3910564b5fcc96ddf74715e94a36075a67d8d Mon Sep 17 00:00:00 2001 From: Eric Baer Date: Wed, 10 Feb 2016 11:12:38 -0800 Subject: [PATCH 1/2] Update airbnb congif from 2.1.1 -> 5.0.0 --- README.md | 2 +- configurations/airbnb/es5.js | 3 +-- rules/eslint/best-practices/airbnb.js | 4 +-- rules/eslint/es6/airbnb.js | 6 ++--- rules/eslint/style/airbnb.js | 9 ++++--- rules/react/airbnb.js | 35 +++++++++++++++++---------- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 682f03b..ea6ebc9 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Due to an issue with ESLint, config extension cannot be called from a globally i - [ESLint](https://github.com/eslint/eslint) 1.10.3 - [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react) 3.12.0 -- [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb) 2.1.1 +- [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb) 5.0.0 - [eslint-config-gulp](https://github.com/gulpjs/eslint-config-gulp) 2.0.0 - [Google JavaScript Style Guide](https://github.com/google/styleguide/tree/43d738ab8bb0c797f78506945729946aacbab17d) 43d738ab8b - [eslint-plugin-filenames](https://www.npmjs.com/package/eslint-plugin-filenames) 0.2.0 diff --git a/configurations/airbnb/es5.js b/configurations/airbnb/es5.js index facb796..152f067 100644 --- a/configurations/airbnb/es5.js +++ b/configurations/airbnb/es5.js @@ -7,8 +7,7 @@ module.exports = { "defaults/rules/eslint/node/airbnb", "defaults/rules/eslint/strict/airbnb", "defaults/rules/eslint/style/airbnb", - "defaults/rules/eslint/variables/airbnb", - "defaults/rules/react/airbnb" + "defaults/rules/eslint/variables/airbnb" ], "parser": "babel-eslint", "env": { diff --git a/rules/eslint/best-practices/airbnb.js b/rules/eslint/best-practices/airbnb.js index ed3595a..4418710 100644 --- a/rules/eslint/best-practices/airbnb.js +++ b/rules/eslint/best-practices/airbnb.js @@ -27,7 +27,7 @@ module.exports = { // disallow use of arguments.caller or arguments.callee "no-caller": 2, // disallow lexical declarations in case clauses - "no-case-declarations": 0, + "no-case-declarations": 2, // disallow division operators explicitly at beginning of regular expression "no-div-regex": 0, // disallow else after a return in an if @@ -116,7 +116,7 @@ module.exports = { // requires to declare all vars on top of their containing scope "vars-on-top": 2, // require immediate function invocation to be wrapped in parentheses - "wrap-iife": [2, "any"], + "wrap-iife": [2, "outside"], // require or disallow Yoda conditions "yoda": 2 } diff --git a/rules/eslint/es6/airbnb.js b/rules/eslint/es6/airbnb.js index 3bfe371..2ddb172 100644 --- a/rules/eslint/es6/airbnb.js +++ b/rules/eslint/es6/airbnb.js @@ -25,7 +25,7 @@ module.exports = { }, "rules": { // require braces in arrow function body - "arrow-body-style": 0, + "arrow-body-style": [2, "as-needed"], // require parens in arrow function arguments "arrow-parens": 0, // require space before/after arrow function's arrow @@ -49,7 +49,7 @@ module.exports = { // require method and property shorthand syntax for object literals "object-shorthand": [2, "always"], // suggest using arrow functions as callbacks - "prefer-arrow-callback": 0, + "prefer-arrow-callback": 2, // suggest using of const declaration for variables that are never modified after declared "prefer-const": 2, // suggest using Reflect methods where applicable @@ -57,7 +57,7 @@ module.exports = { // suggest using the spread operator instead of .apply() "prefer-spread": 0, // suggest using template literals instead of strings concatenation - "prefer-template": 0, + "prefer-template": 2, // disallow generator functions that do not have yield "require-yield": 0 } diff --git a/rules/eslint/style/airbnb.js b/rules/eslint/style/airbnb.js index 070de1f..85d29b0 100644 --- a/rules/eslint/style/airbnb.js +++ b/rules/eslint/style/airbnb.js @@ -41,7 +41,10 @@ module.exports = { // specify the maximum depth that blocks can be nested "max-depth": [0, 4], // specify the maximum length of a line in your program - "max-len": [0, 80, 4], + "max-len": [2, 100, 2, { + "ignoreUrls": true, + "ignoreComments": false + }], // specify the maximum depth callbacks can be nested "max-nested-callbacks": 0, // limits the number of parameters that can be used in the function declaration. @@ -87,7 +90,7 @@ module.exports = { // disallow dangling underscores in identifiers "no-underscore-dangle": 0, // disallow the use of Boolean literals in conditional expressions - "no-unneeded-ternary": 0, + "no-unneeded-ternary": [2, { "defaultAssignment": false }], // require or disallow padding inside curly braces "object-curly-spacing": [2, "always"], // allow just one var statement per function @@ -99,7 +102,7 @@ module.exports = { // enforce padding within blocks "padded-blocks": [2, "never"], // require quotes around object literal property names - "quote-props": 0, + "quote-props": [2, "as-needed", { "keywords": false, "unnecessary": true, "numbers": false }], // specify whether double or single quotes should be used "quotes": [2, "single", "avoid-escape"], // Require JSDoc comment diff --git a/rules/react/airbnb.js b/rules/react/airbnb.js index 3570107..bdccb48 100644 --- a/rules/react/airbnb.js +++ b/rules/react/airbnb.js @@ -10,27 +10,30 @@ module.exports = { }, "rules": { // Prevent missing displayName in a React component definition - "react/display-name": 0, + "react/display-name": [0, { "acceptTranspilerName": false }], // Forbid certain propTypes - "react/forbid-prop-types": 0, + "react/forbid-prop-types": [0, { "forbid": ["any", "array", "object"] }], // Enforce boolean attributes notation in JSX "react/jsx-boolean-value": [2, "never"], // Validate closing bracket location in JSX "react/jsx-closing-bracket-location": [2, "line-aligned"], // Enforce or disallow spaces inside of curly braces in JSX attributes - "react/jsx-curly-spacing": 0, + "react/jsx-curly-spacing": [0, "never", { "allowMultiline": true }], // Enforce event handler naming conventions in JSX - "react/jsx-handler-names": 0, + "react/jsx-handler-names": [0, { + "eventHandlerPrefix": "handle", + "eventHandlerPropPrefix": "on", + }], // Validate props indentation in JSX "react/jsx-indent-props": [2, 2], // Validate JSX has key prop when in array or iterator "react/jsx-key": 0, // Limit maximum of props on a single line in JSX - "react/jsx-max-props-per-line": 0, + "react/jsx-max-props-per-line": [0, { "maximum": 1 }], // Prevent usage of .bind() and arrow functions in JSX props "react/jsx-no-bind": 2, // Prevent duplicate props in JSX - "react/jsx-no-duplicate-props": 0, + "react/jsx-no-duplicate-props": [0, { "ignoreCase": false }], // Prevent usage of isMounted "react/no-is-mounted": 2, // Prevent usage of unwrapped JSX strings @@ -42,17 +45,23 @@ module.exports = { // Enforce quote style for JSX attributes "react/jsx-quotes": 0, // Enforce propTypes declarations alphabetical sorting - "react/jsx-sort-prop-types": 0, + "react/jsx-sort-prop-types": [0, { + "ignoreCase": false, + "callbacksLast": false, + }], // Enforce props alphabetical sorting - "react/jsx-sort-props": 0, + "react/jsx-sort-props": [0, { + "ignoreCase": false, + "callbacksLast": false, + }], // Prevent React to be incorrectly marked as unused - "react/jsx-uses-react": 2, + "react/jsx-uses-react": [2, { "pragma": "React" }], // Prevent variables used in JSX to be incorrectly marked as unused "react/jsx-uses-vars": 2, // Prevent usage of dangerous JSX properties "react/no-danger": 0, // Prevent usage of deprecated methods - "react/no-deprecated": 0, + "react/no-deprecated": [1, { "react": "0.14.0" }], // Prevent usage of setState in componentDidMount "react/no-did-mount-set-state": [2, "allow-in-func"], // Prevent usage of setState in componentDidUpdate @@ -60,7 +69,7 @@ module.exports = { // Prevent direct mutation of this.state "react/no-direct-mutation-state": 0, // Prevent multiple component definition per file - "react/no-multi-comp": 2, + "react/no-multi-comp": [2, { "ignoreStateless": true }], // Prevent usage of setState "react/no-set-state": 0, // Prevent using string references in ref attribute. @@ -70,11 +79,11 @@ module.exports = { // Enforce ES5 or ES6 class for React Components "react/prefer-es6-class": [2, "always"], // Prevent missing props validation in a React component definition - "react/prop-types": 2, + "react/prop-types": [2, { "ignore": [], "customValidators": [] }], // Prevent missing React when using JSX "react/react-in-jsx-scope": 2, // Restrict file extensions that may be required - "react/require-extension": 0, + "react/require-extension": [0, { "extensions": [".jsx"] }], // Prevent extra closing tags for components without children "react/self-closing-comp": 2, // Enforce component methods order From 2a2d0d9bc36d00019d3c276984884e27a21ded58 Mon Sep 17 00:00:00 2001 From: Eric Baer Date: Wed, 10 Feb 2016 11:15:11 -0800 Subject: [PATCH 2/2] Remove dangling commas --- rules/react/airbnb.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rules/react/airbnb.js b/rules/react/airbnb.js index bdccb48..5d3fc4d 100644 --- a/rules/react/airbnb.js +++ b/rules/react/airbnb.js @@ -22,7 +22,7 @@ module.exports = { // Enforce event handler naming conventions in JSX "react/jsx-handler-names": [0, { "eventHandlerPrefix": "handle", - "eventHandlerPropPrefix": "on", + "eventHandlerPropPrefix": "on" }], // Validate props indentation in JSX "react/jsx-indent-props": [2, 2], @@ -47,12 +47,12 @@ module.exports = { // Enforce propTypes declarations alphabetical sorting "react/jsx-sort-prop-types": [0, { "ignoreCase": false, - "callbacksLast": false, + "callbacksLast": false }], // Enforce props alphabetical sorting "react/jsx-sort-props": [0, { "ignoreCase": false, - "callbacksLast": false, + "callbacksLast": false }], // Prevent React to be incorrectly marked as unused "react/jsx-uses-react": [2, { "pragma": "React" }],