mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
Upgrating linting to use babel-eslint
This commit is contained in:
parent
bd11de1b51
commit
52725437d4
34
.eslintrc
34
.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
|
||||
@ -107,6 +118,7 @@
|
||||
"no-warning-comments": 0, // disallow usage of configurable warning terms in comments": 1, // e.g. TODO or FIXME (off by default)
|
||||
"no-with": 1, // disallow use of the with statement
|
||||
"radix": 1, // require use of the second argument for parseInt() (off by default)
|
||||
"semi-spacing": 1, // require a space after a semi-colon
|
||||
"vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default)
|
||||
"wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default)
|
||||
"yoda": 1, // require or disallow Yoda conditions
|
||||
@ -177,7 +189,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 +202,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
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
};
|
17
linter.js
17
linter.js
@ -1,17 +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 transformSource = require('./jestSupport/scriptPreprocess.js').transformSource;
|
||||
var linterTransform = require('./lint/linterTransform');
|
||||
|
||||
linterTransform.setLinterTransform(transformSource);
|
||||
|
||||
// Run the original CLI
|
||||
require('eslint/bin/eslint');
|
@ -69,6 +69,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest-cli": "0.4.5",
|
||||
"eslint": "0.9.2"
|
||||
"babel-eslint": "3.1.5",
|
||||
"eslint": "0.21.2",
|
||||
"eslint-plugin-react": "2.3.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user