Skip to content

Instantly share code, notes, and snippets.

@AlbertoBasalo
Last active September 22, 2022 12:38
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 AlbertoBasalo/8b2d9679891d42554be1869e5afec244 to your computer and use it in GitHub Desktop.
Save AlbertoBasalo/8b2d9679891d42554be1869e5afec244 to your computer and use it in GitHub Desktop.
ESLint configuration for clean TypeScript
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"plugins": ["prettier", "@typescript-eslint"],
"env": {
"browser": true,
"es6": true,
"node": true
},
"globals": {},
"rules": {
"max-statements-per-line": ["warn", { "max": 1 }],
"no-nested-ternary": "warn",
"no-unneeded-ternary": "warn",
"one-var-declaration-per-line": ["warn", "always"],
"operator-assignment": ["warn", "always"],
"operator-linebreak": ["warn", "none"],
"max-depth": ["warn", 1],
"max-lines-per-function": [
"warn",
{ "max": 10, "skipBlankLines": true, "skipComments": true }
],
"max-nested-callbacks": ["warn", 1],
"max-params": ["warn", 2],
"complexity": ["warn", { "max": 5 }],
"max-lines": ["warn", 100],
"no-else-return": "warn",
"no-magic-numbers": [
"warn",
{
"detectObjects": false,
"enforceConst": true,
"ignore": [-1, 0, 1, 2, 10, 100],
"ignoreArrayIndexes": true
}
],
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "default",
"format": ["camelCase"],
"leadingUnderscore": "forbid"
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "typeParameter",
"format": ["PascalCase"],
"prefix": ["T", "K"]
},
{
"selector": "enumMember",
"format": ["UPPER_CASE"]
},
{
"selector": ["memberLike", "variableLike"],
"types": ["boolean"],
"format": ["PascalCase"],
"prefix": ["can", "did", "has", "is", "must", "needs", "should", "will"]
}
],
"arrow-parens": ["warn", "as-needed"],
"block-spacing": ["warn", "always"],
"curly": ["warn", "all"],
"no-multiple-empty-lines": ["warn", { "max": 1, "maxEOF": 1 }],
"no-unused-vars": "off",
"@typescript-eslint/explicit-member-accessibility": [
"warn",
{
"accessibility": "no-public",
"overrides": {
"parameterProperties": "explicit"
}
}
],
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-useless-constructor": "warn",
"@typescript-eslint/no-empty-function": "warn"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment