diff --git a/.eslintrc b/.eslintrc index da893862db6b11..cd085d8468b2cb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,19 @@ { + "parser": "babel-eslint", + + "ecmaFeatures": { + "jsx": true + }, + "env": { + "es6": true, "jasmine": true, }, + "plugins": [ + "react" + ], + // Map from global var to bool specifying if it can be redefined "globals": { "__DEV__": true, @@ -36,10 +47,10 @@ }, "rules": { + "comma-dangle": 0, // disallow trailing commas in object literals "no-cond-assign": 1, // disallow assignment in conditional expressions "no-console": 0, // disallow use of console (off by default in the node environment) "no-constant-condition": 0, // disallow use of constant expressions in conditions - "no-comma-dangle": 0, // disallow trailing commas in object literals "no-control-regex": 1, // disallow control characters in regular expressions "no-debugger": 1, // disallow use of debugger "no-dupe-keys": 1, // disallow duplicate keys when creating object literals @@ -177,7 +188,7 @@ "space-in-parens": 0, // require or disallow spaces inside parentheses (off by default) "space-infix-ops": 1, // require spaces around operators "space-return-throw-case": 1, // require a space after return, throw, and case - "space-unary-word-ops": 1, // require a space around word operators such as typeof (off by default) + "space-unary-ops": [1, { "words": true, "nonwords": false }], // require or disallow spaces before/after unary operators (words on by default, nonwords off by default) "max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default) "one-var": 0, // allow just one var statement per function (off by default) "wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default) @@ -190,6 +201,22 @@ "max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default) "max-statements": 0, // specify the maximum number of statement allowed in a function (off by default) "no-bitwise": 1, // disallow use of bitwise operators (off by default) - "no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default) + "no-plusplus": 0, // disallow use of unary operators, ++ and -- (off by default) + + "react/display-name": 0, + "react/jsx-boolean-value": 0, + "react/jsx-quotes": [1, "double", "avoid-escape"], + "react/jsx-no-undef": 1, + "react/jsx-sort-props": 0, + "react/jsx-uses-react": 0, + "react/jsx-uses-vars": 1, + "react/no-did-mount-set-state": [1, "allow-in-func"], + "react/no-did-update-set-state": [1, "allow-in-func"], + "react/no-multi-comp": 0, + "react/no-unknown-property": 0, + "react/prop-types": 0, + "react/react-in-jsx-scope": 0, + "react/self-closing-comp": 1, + "react/wrap-multilines": 0 } } diff --git a/lint/linterTransform.js b/lint/linterTransform.js deleted file mode 100644 index 669baf556c442c..00000000000000 --- a/lint/linterTransform.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -'use strict'; - -var eslint = require('eslint'); - -var ignoredStylisticRules = { - 'key-spacing': false, - 'comma-spacing': true, - 'no-multi-spaces': true, - 'brace-style': true, - 'camelcase': true, - 'consistent-this': true, - 'eol-last': true, - 'func-names': true, - 'func-style': true, - 'new-cap': true, - 'new-parens': true, - 'no-nested-ternary': true, - 'no-array-constructor': true, - 'no-lonely-if': true, - 'no-new-object': true, - 'no-spaced-func': true, - 'no-space-before-semi': true, - 'no-ternary': true, - 'no-trailing-spaces': true, - 'no-underscore-dangle': true, - 'no-wrap-func': true, - 'no-mixed-spaces-and-tabs': true, - 'quotes': true, - 'quote-props': true, - 'semi': true, - 'sort-vars': true, - 'space-after-keywords': true, - 'space-in-brackets': true, - 'space-in-parens': true, - 'space-infix-ops': true, - 'space-return-throw-case': true, - 'space-unary-word-ops': true, - 'max-nested-callbacks': true, - 'one-var': true, - 'wrap-regex': true, - 'curly': true, - 'no-mixed-requires': true, -}; - -function setLinterTransform(transformSource) { - var originalVerify = eslint.linter.verify; - eslint.linter.verify = function(text, config, filename, saveState) { - var transformedText; - try { - transformedText = transformSource(text, filename); - } catch (e) { - return [{ - severity: 2, - line: e.lineNumber, - message: e.message, - source: text - }]; - } - var originalLines = text.split('\n'); - var transformedLines = transformedText.split('\n'); - var warnings = originalVerify.call(eslint.linter, transformedText, config, filename, saveState); - - // JSX and ES6 transforms usually generate pretty ugly code. Let's skip lint warnings - // about code style for lines that have been changed by transform step. - // Note that more important issues, like use of undefined vars, will still be reported. - return warnings.filter(function(error) { - var lineHasBeenTransformed = originalLines[error.line - 1] !== transformedLines[error.line - 1]; - var shouldIgnore = ignoredStylisticRules[error.ruleId] && lineHasBeenTransformed; - return !shouldIgnore; - }); - }; -} - -module.exports = { - setLinterTransform: setLinterTransform, -}; diff --git a/linter.js b/linter.js index f243a2d2fb8ce3..4bd2fbe9ca9e9c 100644 --- a/linter.js +++ b/linter.js @@ -8,10 +8,5 @@ */ 'use strict'; -var transformSource = require('./jestSupport/scriptPreprocess.js').transformSource; -var linterTransform = require('./lint/linterTransform'); - -linterTransform.setLinterTransform(transformSource); - // Run the original CLI require('eslint/bin/eslint'); diff --git a/package.json b/package.json index 3fffc54910936c..65e074a1448743 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,8 @@ }, "devDependencies": { "jest-cli": "0.4.5", - "eslint": "0.9.2" + "babel-eslint": "^3.1.6", + "eslint": "^0.21.2", + "eslint-plugin-react": "^2.3.0" } }