Created
April 30, 2019 12:41
-
-
Save lll000111/a69b8ed93604a904b45cd1a3c6e3bb7f to your computer and use it in GitHub Desktop.
TypeScript project eslintrc
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:@typescript-eslint/recommended' | |
], | |
'parser': '@typescript-eslint/parser', | |
'parserOptions': { | |
'ecmaFeatures': {}, | |
'project': './tsconfig.json', | |
'tsconfigRootDir': '.' | |
}, | |
'env': { | |
'es6': true, | |
'mocha': true, | |
'node': true, | |
'browser': true | |
}, | |
'plugins': [ | |
'@typescript-eslint', | |
'jsdoc' | |
], | |
'rules': { | |
'jsdoc/check-alignment': 'error', | |
'jsdoc/check-examples': 'off', | |
'jsdoc/check-indentation': 'off', | |
'jsdoc/check-param-names': 'error', | |
'jsdoc/check-syntax': 'off', | |
'jsdoc/check-tag-names': 'error', | |
'jsdoc/check-types': 'error', | |
'jsdoc/newline-after-description': 'off', | |
'jsdoc/no-undefined-types': 'off', | |
'jsdoc/require-description-complete-sentence': 'off', | |
'jsdoc/require-description': 'off', | |
'jsdoc/require-example': 'off', | |
'jsdoc/require-hyphen-before-param-description': 'warn', | |
'jsdoc/require-param-description': 'off', | |
'jsdoc/require-param-name': 'error', | |
'jsdoc/require-param-type': 'error', | |
'jsdoc/require-param': 'warn', | |
'jsdoc/require-returns-description': 'off', | |
'jsdoc/require-returns-type': 'error', | |
'jsdoc/require-returns-check': 'off', | |
'jsdoc/require-returns': 'error', | |
'jsdoc/valid-types': 'error', | |
'camelcase': 'off', // OVERRIDE BY TYPESCRIPT RULE | |
'@typescript-eslint/camelcase': ['error', { 'properties': 'never' }], | |
'no-extra-parens': 'off', // OVERRIDE BY TYPESCRIPT RULE | |
'@typescript-eslint/no-extra-parens': ['off', 'all', {'nestedBinaryExpressions': false}], | |
'@typescript-eslint/array-type': 'off', | |
'@typescript-eslint/explicit-function-return-type': [ | |
'error', | |
{ | |
allowExpressions: true, | |
allowTypedFunctionExpressions: true | |
} | |
], | |
'@typescript-eslint/indent': ['off', 2], | |
'@typescript-eslint/no-explicit-any': 'off', | |
'@typescript-eslint/no-namespace': 'error', | |
'@typescript-eslint/no-require-imports': 'error', | |
'@typescript-eslint/no-unused-vars': [ | |
'warn', | |
{ | |
'vars': 'all', | |
'args': 'all', | |
'argsIgnorePattern': '^_|^ignore', | |
'varsIgnorePattern': '^_|^ignore', | |
'caughtErrors': 'all', | |
'caughtErrorsIgnorePattern': '^ignore' | |
} | |
], | |
'@typescript-eslint/no-use-before-define': 'off', | |
'@typescript-eslint/prefer-interface': 'off', | |
'semi': 'off', // OVERRIDE BY TYPESCRIPT RULE | |
'@typescript-eslint/semi': ['error', 'awlays'], | |
// ------------------------------------------------------------------------- | |
// eslint rules | |
// ------------------------------------------------------------------------- | |
'no-restricted-syntax': | |
[ | |
'error', | |
{ | |
'selector': 'ExportDefaultDeclaration', | |
'message': 'Prefer named exports' | |
} | |
], | |
// 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}], | |
'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', // OVERRIDE BY TYPESCRIPT RULE | |
'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 using an async function as a Promise executor | |
'no-async-promise-executor': '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', | |
// 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', {'builtinGlobals': true}], | |
// Disallows unnecessary return await: WE USE THAT - needed to (some day) get an async. | |
// stack trace | |
'no-return-await': 'off', | |
// Disallow Self Assignment | |
'no-self-assign': 'error', | |
'no-self-compare': 'error', | |
// Disallow variable declarations from shadowing variables declared in the outer scope | |
'no-shadow': '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': 'off', // OVERRIDE BY TYPESCRIPT RULE | |
// Disallow unnecessary .call() and .apply() | |
'no-useless-call': 'warn', | |
// Disallow unnecessary catch claus | |
'no-useless-catch': 'error', | |
// 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': 'any', 'prev': 'case', 'next': '*'}, | |
{'blankLine': 'always', 'prev': '*', 'next': ['export', 'cjs-export']}, | |
{'blankLine': 'always', 'prev': ['export', 'cjs-export'], 'next': '*'}, | |
{'blankLine': 'any', 'prev': ['export', 'cjs-export'], 'next': ['export', 'cjs-export']}, | |
{'blankLine': 'always', 'prev': '*', 'next': ['while', 'switch', 'for']}, | |
{'blankLine': 'always', 'prev': '*', 'next': ['block', 'block-like']}, | |
{'blankLine': 'any', 'prev': 'case', '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 assignments that can lead to race conditions due to usage of await or yield | |
'require-atomic-updates': 'error', | |
// Disallow async functions which have no await expression | |
'require-await': 'warn', | |
'require-yield': 'error', | |
'sort-imports': [ | |
'off', | |
{ | |
'ignoreCase': false, | |
'ignoreDeclarationSort': false, | |
'ignoreMemberSort': false, | |
'memberSyntaxSortOrder': ['none', 'all', 'multiple', 'single'] | |
} | |
], | |
// 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' | |
}, | |
'settings': { | |
'jsdoc': { | |
'tagNamePreference': { | |
'function': 'function', | |
'file': 'file', | |
'link': 'link', | |
'property': 'property', | |
'throws': 'throws', | |
'param': 'param', | |
'returns': 'returns' | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment