Last active
January 5, 2023 21:58
-
-
Save anushshukla/f7036be3519745b3bdb112e70206a269 to your computer and use it in GitHub Desktop.
Typescript best Eslint configurations
This file contains hidden or 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
| root: false | |
| parser: "@typescript-eslint/parser" | |
| "parserOptions": | |
| ecmaVersion: 2020 | |
| sourceType: "module" | |
| # relative path to tsconfig file | |
| project: "tsconfig.json" | |
| env: | |
| es6: true | |
| node: true | |
| plugins: | |
| - "@typescript-eslint" | |
| - prettier | |
| extends: | |
| - eslint:recommended | |
| - "plugin:@typescript-eslint/eslint-recommended" | |
| - "plugin:@typescript-eslint/recommended" | |
| - prettier | |
| rules: | |
| # Override default settings | |
| require-await: 2 | |
| no-return-await: 2 | |
| # anonymous functions makes debugging difficult | |
| func-names: | |
| - error | |
| - 'always' | |
| "@typescript-eslint/no-floating-promises": 2 | |
| prettier/prettier: 2 | |
| eqeqeq: 2 # Refer https://eslint.org/docs/rules/eqeqeq | |
| no-console: 2 # Refer https://eslint.org/docs/rules/no-console | |
| "@typescript-eslint/no-explicit-any": 2 | |
| # As we've enabled strict mode with noUnusedLocals & noUnusedParameters in tsconfig | |
| "@typescript-eslint/no-unused-vars": 0 | |
| max-lines: | |
| - error | |
| - max: 300 | |
| skipBlankLines: true | |
| skipComments: true | |
| max-statements: | |
| - error | |
| - 10 | |
| - ignoreTopLevelFunctions: true | |
| max-len: | |
| - error | |
| - code: 80 | |
| tabWidth: 4 | |
| comments: 65 | |
| ignoreUrls: true | |
| ignoreStrings: true | |
| ignoreComments: true | |
| ignoreTrailingComments: true | |
| ignoreTemplateLiterals: true | |
| max-depth: | |
| - error | |
| - 4 | |
| max-lines-per-function: | |
| - error | |
| - max: 50 | |
| IIFEs: false | |
| skipComments: true | |
| skipBlankLines: true | |
| max-nested-callbacks: | |
| - error | |
| - max: 10 | |
| max-params: | |
| - error | |
| - max: 3 | |
| complexity: | |
| - error | |
| - 2 | |
| curly: | |
| - error | |
| - all | |
| no-unneeded-ternary: 2 # Refer https://eslint.org/docs/rules/no-unneeded-ternary | |
| no-nested-ternary: 2 # Refer https://eslint.org/docs/rules/no-nested-ternary | |
| camelcase: # Refer https://eslint.org/docs/rules/camelcase | |
| - error | |
| - properties: always | |
| ignoreDestructuring: false | |
| ignoreImports: false | |
| ignoreGlobals: false | |
| allow: | |
| - '' | |
| "@typescript-eslint/naming-convention": | |
| - error | |
| - selector: variable | |
| format: | |
| - camelCase | |
| - selector: memberLike | |
| modifiers: | |
| - private, | |
| format: | |
| - camelCase | |
| leadingUnderscore: "require" | |
| - trailingUnderscore: 'forbid' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment