-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.json
148 lines (145 loc) · 9.28 KB
/
.eslintrc.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
"env": {
"node": true,
"es6": true
},
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module",
"project": "tsconfig.json"
},
"plugins": ["sonarjs", "@typescript-eslint"],
"extends": [
"plugin:sonarjs/recommended-legacy",
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked"
],
"rules": {
"no-shadow": ["error", { "builtinGlobals": true }], // disallow variable declarations from shadowing variables declared in the outer scope
"no-duplicate-imports": ["error", { "includeExports": true }], // disallow duplicate module imports
"no-template-curly-in-string": "error", // disallow template literal placeholder syntax in regular strings
"block-scoped-var": "error", // enforce the use of variables within the scope they are defined
"curly": ["error", "all"], // enforce consistent brace style for all control statements
"eqeqeq": "error", // equire the use of === and !==
"max-classes-per-file": ["error", 1], // enforce a maximum number of classes per file
"no-alert": "warn", // disallow the use of alert, confirm, and prompt
"no-console": "off", // disallow the use of console
"no-else-return": ["error", { "allowElseIf": false }], // disallow else blocks after return statements in if statements
"no-implicit-coercion": "error", // disallow shorthand type conversions
"no-labels": "error", // disallow labeled statements
"no-lone-blocks": "error", // disallow unnecessary nested blocks
"no-multi-spaces": "error", // disallow multiple spaces
"no-new": "error", // disallow new operators outside of assignments or comparisons
"no-new-func": "error", // disallow new operators with the Function object
"no-new-wrappers": "error", // disallow new operators with the String, Number, and Boolean objects
"no-return-await": "error", // disallow unnecessary return await
"no-self-compare": "error", // disallow comparisons where both sides are exactly the same
"no-sequences": "error", // disallow comma operators
"no-throw-literal": "error", // disallow throwing literals as exceptions
"no-unused-expressions": "error", // disallow unused expressions
"no-useless-call": "error", // disallow unnecessary calls to .call() and .apply()
"no-useless-concat": "error", // disallow unnecessary concatenation of literals or template literals
"no-useless-return": "error", // disallow redundant return statements
// "prefer-promise-reject-errors": "error", // require using Error objects as Promise rejection reasons
"radix": "error", // enforce the consistent use of the radix argument when using parseInt()
"no-undefined": "error", // disallow the use of undefined as an identifier
"array-bracket-newline": ["error", { "multiline": true }], // enforce linebreaks after opening and before closing array brackets
"comma-dangle": ["error", "always-multiline"], // require or disallow trailing commas
"comma-style": "error", // enforce consistent comma style
"eol-last": "error", // require or disallow newline at the end of files
"key-spacing": "error", // enforce consistent spacing between keys and values in object literal properties
"keyword-spacing": "error", // enforce consistent spacing before and after keywords
"new-parens": "error", // enforce or disallow parentheses when invoking a constructor with no arguments
"no-bitwise": "warn", // disallow bitwise operators
"no-lonely-if": "warn", // disallow if statements as the only statement in else blocks
"no-multiple-empty-lines": "error", // disallow multiple empty lines
"no-nested-ternary": "error", // disallow nested ternary expressions
"no-new-object": "error", // disallow Object constructors
"no-tabs": ["warn", { "allowIndentationTabs": false }], // disallow all tabs
"no-trailing-spaces": "error", // disallow trailing whitespace at the end of lines
"no-unneeded-ternary": "error", // disallow ternary operators when simpler alternatives exist
"no-whitespace-before-property": "error", // disallow whitespace before properties
"object-curly-newline": "error", // enforce consistent line breaks inside braces
"object-curly-spacing": ["error", "always"], // enforce consistent spacing inside braces
"semi-spacing": "error", // enforce consistent spacing before and after semicolons
"space-before-blocks": "error", // enforce consistent spacing before blocks
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
], // enforce consistent spacing before function definition opening parenthesis
"space-in-parens": "error", // enforce consistent spacing inside parentheses
"space-infix-ops": "error", // require spacing around infix operators
"space-unary-ops": "error", // enforce consistent spacing before or after unary operators
"spaced-comment": ["error", "always"], // enforce consistent spacing after the // or /* in a comment
"switch-colon-spacing": "error", // enforce spacing around colons of switch statements
"arrow-body-style": ["error", "as-needed"], // require braces around arrow function bodies
"arrow-parens": ["error", "always"], // require parentheses around arrow function arguments
"arrow-spacing": "error", // enforce consistent spacing before and after the arrow in arrow functions
"generator-star-spacing": ["error", "after"], // enforce consistent spacing around * operators in generator functions
"no-useless-computed-key": "error", // disallow unnecessary computed property keys in object literals
"no-useless-rename": "error", // disallow renaming import, export, and destructured assignments to the same name
"object-shorthand": ["error", "always"], // require or disallow method and property shorthand syntax for object literals
"prefer-arrow-callback": "warn", // require using arrow functions for callbacks
"prefer-destructuring": "warn", // require destructuring from arrays and/or objects
"rest-spread-spacing": ["error", "never"], // enforce spacing between rest and spread operators and their expressions
"sort-imports": "error", // enforce sorted import declarations within modules
"template-curly-spacing": "error", // require or disallow spacing around embedded expressions of template strings
// "promise/prefer-await-to-then": "error", // refer await to then() for reading Promise values,
// TODO: Waiting this rule to be fixed
// "promise/prefer-await-to-callbacks": "error", // Prefer async/await to the callback pattern
// https://github.com/xjamundx/eslint-plugin-promise/issues/175
// "optimize-regex/optimize-regex": "warn", // Optimize regex literals
"@typescript-eslint/semi": ["error", "never"], // Require or disallow semicolons instead of ASI
"@typescript-eslint/member-delimiter-style": ["error", { "multiline": { "delimiter": "none" } }], // Require a specific member delimiter style for interfaces and type literals
"@typescript-eslint/member-ordering": "warn", // Require a consistent member declaration order
"@typescript-eslint/brace-style": ["error", "1tbs"], // Enforce consistent brace style for blocks
"@typescript-eslint/indent": ["error", 2, { "SwitchCase": 1 }], // Enforce consistent indentation
"@typescript-eslint/quotes": ["error", "double", { "avoidEscape": true }], // Enforce the consistent use of either backticks, double, or single quotes
"@typescript-eslint/func-call-spacing": ["error", "never"], // Require or disallow spacing between function identifiers and their invocations
"@typescript-eslint/no-useless-constructor": "error", // Disallow unnecessary constructors
"@typescript-eslint/prefer-for-of": "warn", // Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated
"@typescript-eslint/no-unnecessary-type-arguments": "warn", // Warns if an explicitly specified type argument is the default for that type parameter
"@typescript-eslint/prefer-function-type": "warn", // Use function types instead of interfaces with call signatures
"@typescript-eslint/prefer-readonly": "warn", // Requires that private members are marked as readonly if they're never modified outside of the constructor
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "default",
"format": ["camelCase"]
},
{
"selector": "variable",
"format": ["camelCase"]
},
{
"selector": "typeLike",
"format": ["PascalCase"]
},
{
"selector": "property",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow"
}
], // Enforces naming conventions for everything across a codebase
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
"@typescript-eslint/explicit-module-boundary-types": "off", // Require explicit return and argument types on exported functions' and classes' public class methods
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_$" }],
"@typescript-eslint/no-invalid-this": "error" // disallow this keywords outside of classes or class-like objects
}
}