Created
April 9, 2018 13:29
-
-
Save lll000111/1819c5c900e3d5825031e45a5eeb53cb to your computer and use it in GitHub Desktop.
eslint configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
'root': true, | |
// eslint recommended defaults can be found in [INSTALL_DIR]/eslint/conf/eslint.json | |
'extends': [ | |
'eslint:recommended', | |
"plugin:flowtype/recommended" | |
], | |
'parser': 'babel-eslint', | |
'parserOptions': { | |
'ecmaVersion': 6, | |
'ecmaFeatures': { | |
'impliedStrict': false, | |
'arrowFunctions': true, | |
'binaryLiterals': true, | |
'blockBindings': true, | |
'classes': false, // NO WAY! | |
'defaultParams': true, | |
'destructuring': true, | |
'forOf': true, | |
'generators': true, | |
'modules': false, // turn on when moving to true ES 2015 modules | |
'newTarget': true, | |
'objectLiteralComputedProperties': true, | |
'objectLiteralDuplicateProperties': false, | |
'objectLiteralShorthandMethods': true, | |
'objectLiteralShorthandProperties': true, | |
'octalLiterals': false, | |
'regexUFlag': true, | |
'regexYFlag': true, | |
'restParams': true, | |
'spread': true, | |
'superInFunctions': false, | |
'templateStrings': true, | |
'unicodeCodePointEscapes': true | |
}, | |
'sourceType': 'module' | |
}, | |
'env': { | |
'es6': true, | |
'mocha': true, | |
'node': true, | |
'browser': true | |
}, | |
'plugins': [ | |
'flowtype'//, | |
//'flowtype-errors' | |
], | |
'rules': { | |
// Flowtype rules | |
'flowtype/boolean-style': ['error', 'boolean'], | |
'flowtype/define-flow-type': 'warn', | |
'flowtype/delimiter-dangle': 0, | |
'flowtype/generic-spacing': ['error', 'never'], | |
'flowtype/no-dupe-keys': 'error', | |
'flowtype/no-weak-types': 0, | |
'flowtype/require-parameter-type': ['off', {'excludeArrowFunctions': 'expressionsOnly'}], | |
'flowtype/require-return-type': ['off', {'excludeArrowFunctions': 'expressionsOnly'}], | |
'flowtype/require-valid-file-annotation': 0, | |
'flowtype/semi': 'error', | |
'flowtype/space-after-type-colon': ['error', 'always'], | |
'flowtype/space-before-generic-bracket': ['error', 'never'], | |
'flowtype/space-before-type-colon': ['error', 'never'], | |
'flowtype/type-id-match': 0, | |
'flowtype/union-intersection-spacing': ['error', 'always'], | |
'flowtype/use-flow-type': 'warn', | |
'flowtype/valid-syntax': 'warn', | |
//'flowtype-errors/show-errors': 'error', | |
// ------------------------------------------------------------------------- | |
// eslint rules | |
// ------------------------------------------------------------------------- | |
// enforce line breaks after opening and before closing array brackets | |
'array-bracket-newline': 'off', | |
// Enforces return statements in callbacks of array's methods | |
'array-callback-return': 'error', | |
// Require parens in arrow function arguments | |
'arrow-parens': ['warn', 'as-needed'], | |
// Enforces getter/setter pairs in objects | |
'accessor-pairs': ['off', {'setWithoutGet': true, 'getWithoutSet': false}], | |
// Require space before/after arrow functions arrow | |
'arrow-spacing': ['error', {'before': true, 'after': true}], | |
'brace-style': ['error', '1tbs', {'allowSingleLine': false}], | |
'camelcase': ['error', {'properties': 'never'}], | |
'consistent-this': ['error', 'self'], | |
'comma-dangle': ['error', 'never'], | |
'comma-style': ['error', 'last'], | |
// Require optional curly braces when a block contains only one statement after if, | |
// else, while, etc. | |
'curly': ['error', 'all'], | |
// Enforce newline before and after dot | |
'dot-location': ['error', 'property'], | |
// "allowPattern": "^[a-z]+(_[a-z]+)+$" | |
'dot-notation': ['warn', {'allowKeywords': true}], | |
'eol-last': 'error', | |
// Require === and !== | |
'eqeqeq': 'error', | |
// Enforce “for” loop update clause moving the counter in the right direction | |
'for-direction': 'error', | |
'function-paren-newline': ['off'], | |
'generator-star-spacing': ['error', {'before': false, 'after': true}], | |
// Disallow require() outside of the top-level module scope | |
'global-require': 'error', | |
'indent': ['off', 4, {'SwitchCase': 1, 'MemberExpression': 0}], | |
'key-spacing': ['error', {'beforeColon': false, 'afterColon': true}], | |
'keyword-spacing': 'error', | |
'max-nested-callbacks': ['warn', 4], | |
// Require newline before return statement | |
'newline-before-return': 'off', | |
// Require a newline after each call in a method chain | |
'newline-per-chained-call': ['error', {'ignoreChainWithDepth': 3}], | |
'no-alert': 'error', | |
// Disallow await inside of loops | |
'no-await-in-loop': 'error', | |
// disallow use of the Buffer() constructor | |
'no-buffer-constructor': 'error', | |
// Disallow Use of caller/callee | |
'no-caller': 'error', | |
// Disallow lexical declarations in case/default clauses | |
'no-case-declarations': 'error', | |
// disallow comparing against -0 | |
'no-compare-neg-zero': 'error', | |
// Disallow assignment in conditional statements | |
'no-cond-assign': 'error', | |
// Disallow arrow functions where they could be confused with comparisons | |
'no-confusing-arrow': 'off', | |
// Disallow modifying variables that are declared using const | |
'no-const-assign': 'error', | |
// Disallow use of constant expressions in conditions | |
'no-constant-condition': 'error', | |
// Disallow controls characters in regular expressions | |
'no-control-regex': 'error', | |
// Disallow "debugger" statement | |
'no-debugger': 'error', | |
// Disallow duplicate keys | |
'no-dupe-keys': 'error', | |
// Rule to disallow a duplicate case label | |
'no-duplicate-case': 'error', | |
// Disallow duplicate imports | |
'no-duplicate-imports': 'error', | |
// Disallow empty block statements | |
'no-empty': 'error', | |
// Disallow empty character classes | |
'no-empty-character-class': 'error', | |
// Disallow empty functions | |
'no-empty-function': 'off', | |
'no-eq-null': 'error', | |
// Disallow assigning to the exception in a catch block | |
'no-ex-assign': 'error', | |
'no-extra-parens': ['off', 'all', {'nestedBinaryExpressions': false}], | |
// Disallow unnecessary semicolons | |
'no-extra-semi': 'error', | |
// Disallow overwriting functions written as function declarations | |
'no-func-assign': 'error', | |
// Disallow assignment to native objects or read-only global variables | |
'no-global-assign': 'error', | |
// Disallow this keywords outside of classes or class-like objects | |
'no-invalid-this': 'error', | |
// Disallow irregular whitespace outside of strings and comments | |
'no-irregular-whitespace': 'error', | |
'no-lonely-if': 'error', | |
// Disallow mixes of different operators | |
'no-mixed-operators': 'error', | |
'no-mixed-spaces-and-tabs': 'error', | |
'no-multi-spaces': ['error', {'ignoreEOLComments': true}], | |
'no-negated-condition': 'error', | |
// Disallow negation of the left operand of an in expression | |
'no-negated-in-lhs': 'error', | |
// Disallow Symbol Constructor | |
'no-new-symbol': 'error', | |
// Disallow the use of object properties of the global object (Math and JSON) as functions | |
'no-obj-calls': 'error', | |
// Disallow reassignment of function parameters | |
'no-param-reassign': 'off', | |
// Disallow string concatenation when using _dirname and _filename | |
'no-path-concat': 'error', | |
// Disallow redeclaring variables | |
'no-redeclare': 'error', | |
// Disallows unnecessary return await | |
'no-return-await': 'error', | |
// Disallow Self Assignment | |
'no-self-assign': 'error', | |
'no-self-compare': 'error', | |
'no-sync': 'error', | |
// Disallow tabs in file | |
'no-tabs': 'error', | |
// Disallow template literal placeholder syntax in regular strings | |
'no-template-curly-in-string': 'error', | |
'no-trailing-spaces': 'error', | |
'no-throw-literal': 'error', | |
// Disallow Undeclared Variables | |
'no-undef': 'error', | |
'no-underscore-dangle': 'off', | |
// Avoid code that looks like two expressions but is actually one | |
'no-unexpected-multiline': 'error', | |
// Disallow unreachable statements after a return, throw, continue, or break statement | |
'no-unreachable': 'error', | |
// Disallow control flow statements in finally blocks | |
'no-unsafe-finally': 'error', | |
// Disallow negating the left operand of relational operators | |
'no-unsafe-negation': 'error', | |
'no-unused-vars': [ | |
'warn', | |
{ | |
'vars': 'all', | |
'args': 'none', | |
'caughtErrorsIgnorePattern': '^ignore' | |
} | |
], | |
// Disallow unnecessary .call() and .apply() | |
'no-useless-call': 'warn', | |
// Disallow unnecessary computed property keys on objects | |
'no-useless-computed-key': 'error', | |
// Disallow unncessary concatenation of strings | |
'no-useless-concat': 'error', | |
// Disallow unnecessary escape usage | |
'no-useless-escape': 'error', | |
// Disallow renaming import, export, and destructured assignments to the same name | |
'no-useless-rename': 'error', | |
// Disallow "var" to declare variables | |
'no-var': 'error', | |
// Disallow whitespace before properties | |
'no-whitespace-before-property': 'error', | |
'operator-linebreak': ['error', 'after', {"overrides": {"?": "ignore", ":": "ignore"}}], | |
'padded-blocks': ['off', 'never'], | |
'padding-line-between-statements': [ | |
'error', | |
{ 'blankLine': 'always', 'prev': 'directive', 'next': 'import' }, | |
{ 'blankLine': 'always', 'prev': 'import', 'next': '*' }, | |
{ 'blankLine': 'any', 'prev': 'import', 'next': 'import' }, | |
{ 'blankLine': 'always', 'prev': '*', 'next': ['export', 'cjs-export'] }, | |
{ 'blankLine': 'always', 'prev': ['export', 'cjs-export'], 'next': '*' }, | |
{ 'blankLine': 'always', 'prev': '*', 'next': ['while', 'switch', 'for'] }, | |
{ 'blankLine': 'always', 'prev': '*', 'next': ['block','block-like'] }, | |
{ 'blankLine': 'always', 'prev': ['block','block-like'], 'next': 'return' }, | |
{ 'blankLine': 'always', 'prev': '*', 'next': ['const', 'let'] }, | |
{ 'blankLine': 'any', 'prev': ['const', 'let'], 'next': ['const', 'let'] } | |
], | |
// Suggest using arrow functions as callbacks | |
'prefer-arrow-callback': 'error', | |
// Prefer "const" over "let" for constant variables | |
'prefer-const': 'error', | |
// require using Error objects as Promise rejection reasons | |
'prefer-promise-reject-errors': 'error', | |
// Suggest using Reflect methods where applicable | |
'prefer-reflect': 'off', | |
// Suggest using the rest parameters instead of arguments | |
'prefer-rest-params': 'error', | |
// Suggest using of the spread operator instead of .apply() | |
'prefer-spread': 'error', | |
'quotes': ['error', 'single'], | |
'radix': 'error', | |
// Disallow async functions which have no await expression | |
'require-await': 'warn', | |
'require-yield': 'error', | |
// Require JSDoc comment | |
'require-jsdoc': 'error', | |
'semi': ['error', 'always'], | |
// Requires or disallows a whitespace (space or tab) beginning a comment | |
'spaced-comment': [ | |
'warn', | |
'always', | |
{ | |
'line': { | |
'exceptions': ['region', 'endregion', '-', '+'], | |
'markers': ['region', 'endregion', 'noinspection', 'global', 'eslint-disable'] | |
}, | |
'block': { | |
'exceptions': ['*'], | |
'markers': ['eslint-disable', 'eslint-enabled', ':', '::'] | |
} | |
} | |
], | |
'space-before-blocks': ['error', 'always'], | |
'space-before-function-paren': ['error', 'always'], | |
'space-in-parens': ['error', 'never'], | |
// Require spaces around infix operators | |
'space-infix-ops': 'error', | |
'space-unary-ops': ['error', {'words': true, 'nonwords': false}], | |
// Turned off to make it work in the Flow context | |
'strict': ['off', 'global'], | |
'switch-colon-spacing': ['error', {'after': true, 'before': false}], | |
// Enforce Usage of Spacing in Template Strings | |
'template-curly-spacing': 'error', | |
// Require or disallow the Unicode Byte Order Mark | |
'unicode-bom': 'error', | |
// Disallow comparisons with the value NaN | |
'use-isnan': 'error' | |
//"valid-jsdoc": ["error", { | |
// "requireParamDescription": false, | |
// "requireReturnDescription": false, | |
// "prefer": {"return": "returns"}, | |
// "requireReturn": false, | |
// "preferType": { | |
// "String": "string", | |
// "Number": "number", | |
// "Boolean": "boolean", | |
// "object": "Object" | |
// } | |
//}] | |
}, | |
'settings': { | |
'flowtype': { | |
'onlyFilesWithFlowAnnotation': false | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment