Skip to content

Instantly share code, notes, and snippets.

@florestankorp
Created April 19, 2021 13:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florestankorp/b1121c86da4886b057fe457e8dd691ce to your computer and use it in GitHub Desktop.
Save florestankorp/b1121c86da4886b057fe457e8dd691ce to your computer and use it in GitHub Desktop.
ES Lint Rules
module.exports = {
ignorePatterns: ['.eslintrc.js'],
env: {
browser: true,
es6: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@angular-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:unicorn/recommended',
'plugin:prettier/recommended',
],
plugins: [
'@angular-eslint/eslint-plugin-template',
'@angular-eslint/eslint-plugin',
'eslint-plugin-import',
'eslint-plugin-no-null',
'eslint-plugin-unicorn',
'eslint-plugin-jsdoc',
'@typescript-eslint',
'@typescript-eslint/tslint',
'eslint-plugin-prettier',
],
overrides: [
{
files: ['*.spec.ts'],
rules: {
'max-lines-per-function': ['error', 500],
},
},
],
rules: {
/* Explicilty disabled after vote:*/
'@typescript-eslint/ban-types': 'off',
'unicorn/no-null': 'off',
'unicorn/no-array-for-each': 'off',
'unicorn/prefer-number-properties': 'off',
'unicorn/prefer-array-find': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/consistent-destructuring': 'off',
'unicorn/better-regex': 'off',
/* ^^ END */
/* Explicilty disabled because it collides with exiting rules:*/
'no-useless-constructor': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/no-new-array': 'off',
/* ^^ END */
'prefer-const': 'error',
'max-lines-per-function': ['error', 50],
'no-extra-boolean-cast': 'error',
'no-case-declarations': 'error',
'no-var': 'error',
'no-unused-vars': 'off', // note you must disable the base rule 'no-unused-vars' as it can report incorrect errors
'@typescript-eslint/no-unused-vars': ['error', { vars: 'all', args: 'none', ignoreRestSiblings: false }],
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: false, allowTernary: true }],
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/naming-convention': 'off', // 1371 problems
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
overrides: {
accessors: 'explicit',
constructors: 'no-public',
methods: 'explicit',
properties: 'explicit',
parameterProperties: 'explicit',
},
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off', // 86 problems
'@angular-eslint/no-output-on-prefix': 'error',
'unicorn/catch-error-name': 'error',
'unicorn/explicit-length-check': 'error',
'unicorn/new-for-builtins': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-spread': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
'unicorn/prefer-string-slice': 'error',
'unicorn/no-array-callback-reference': 'error',
'unicorn/no-array-reduce': 'off', // risky to fix
'unicorn/no-for-loop': 'error',
'unicorn/no-array-push-push': 'error',
'import/namespace': 'off', // 79 problems
'import/no-duplicates': 'error',
'import/no-deprecated': 'error',
'import/no-extraneous-dependencies': 'error',
'@typescript-eslint/tslint/config': [
'error',
{
rules: {
'strict-comparisons': true,
'invalid-void': false,
'match-default-export-name': true,
'no-default-import': true,
'no-inferred-empty-object-type': true,
'no-mergeable-namespace': true,
'no-null-undefined-union': true,
'no-promise-as-boolean': true,
'no-restricted-globals': true,
'no-tautology-expression': true,
'prefer-conditional-expression': true,
'prefer-method-signature': true,
'prefer-switch': true,
'prefer-while': true,
'return-undefined': true,
'static-this': true,
'strict-string-expressions': true,
'unnecessary-else': true,
'no-floating-promises': false,
'no-unnecessary-class': false,
},
},
],
'@angular-eslint/component-class-suffix': 'error',
'@angular-eslint/component-selector': [
'off',
{
type: 'element',
prefix: 'kebab-case',
style: true,
},
],
'@angular-eslint/contextual-lifecycle': 'error',
'@angular-eslint/directive-class-suffix': 'error',
'@angular-eslint/directive-selector': [
'off',
{
type: 'attribute',
prefix: 'camelCase',
style: true,
},
],
'@angular-eslint/no-attribute-decorator': 'error',
'@angular-eslint/no-conflicting-lifecycle': 'error',
'@angular-eslint/no-host-metadata-property': 'error',
'@angular-eslint/no-input-rename': 'error',
'@angular-eslint/no-inputs-metadata-property': 'error',
'@angular-eslint/no-lifecycle-call': 'error',
'@angular-eslint/no-output-native': 'error',
'@angular-eslint/no-output-rename': 'error',
'@angular-eslint/no-outputs-metadata-property': 'error',
'@angular-eslint/prefer-output-readonly': 'error',
'@angular-eslint/template/no-negated-async': 'off',
'@angular-eslint/use-component-view-encapsulation': 'error',
'@angular-eslint/use-lifecycle-interface': 'error',
'@angular-eslint/use-pipe-transform-interface': 'error',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': [
'error',
{
default: 'array',
},
],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/member-delimiter-style': [
'off',
{
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-shadow': [
'error',
{
hoist: 'all',
},
],
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/prefer-readonly': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/quotes': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/semi': ['off', null],
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/triple-slash-reference': [
'error',
{
path: 'always',
types: 'prefer-import',
lib: 'always',
},
],
'@typescript-eslint/type-annotation-spacing': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'error',
'arrow-body-style': 'off',
'arrow-parens': ['off', 'always'],
'brace-style': ['off', 'off'],
'class-methods-use-this': 'off',
'comma-dangle': 'off',
complexity: ['error', 10],
'constructor-super': 'error',
curly: 'error',
'default-case': 'off',
'eol-last': 'off',
eqeqeq: ['error', 'always'],
'guard-for-in': 'error',
'id-match': 'error',
'import/no-default-export': 'error',
'import/no-internal-modules': 'off',
'import/no-unassigned-import': 'error',
'import/order': 'off',
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/newline-after-description': 'error',
'jsdoc/no-types': 'error',
'linebreak-style': 'off',
'max-classes-per-file': 'off',
'max-len': 'off',
'max-lines': ['error', 500],
'new-parens': 'off',
'newline-per-chained-call': 'off',
'no-bitwise': 'error',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': 'error',
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'error',
'no-empty': 'off',
'no-eval': 'error',
'no-extra-bind': 'error',
'no-extra-semi': 'off',
'no-irregular-whitespace': 'off',
'no-magic-numbers': 'off',
'no-multiple-empty-lines': 'off',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-null/no-null': 'off',
'no-param-reassign': 'error',
'no-plusplus': [
'off',
{
allowForLoopAfterthoughts: true,
},
],
'no-redeclare': 'error',
'no-restricted-syntax': ['error', 'ForInStatement'],
'no-return-await': 'error',
'no-sequences': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'off',
'no-undef-init': 'error',
'no-underscore-dangle': 'error',
'no-unsafe-finally': 'error',
'no-unused-labels': 'error',
'no-void': 'off',
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'padding-line-between-statements': [
'off',
{
blankLine: 'always',
prev: '*',
next: 'return',
},
],
'prefer-object-spread': 'error',
'prefer-template': 'off',
'quote-props': 'off',
radix: 'error',
'space-before-function-paren': 'off',
'space-in-parens': ['off', 'never'],
'spaced-comment': [
'error',
'always',
{
markers: ['/'],
},
],
'unicorn/filename-case': 'error',
'use-isnan': 'error',
yoda: 'off',
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment