-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy patheslint.config.js
209 lines (202 loc) · 6.63 KB
/
eslint.config.js
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import eslint from "@eslint/js"
import eslintPluginJest from "eslint-plugin-jest"
import eslintPluginUnicorn from "eslint-plugin-unicorn"
import tseslint from "typescript-eslint"
import { sonarjs } from "./eslint.compat.js"
const unsafe = [
"src/playbackstrategy/modifiers/samsungmaple.js",
"src/playbackstrategy/modifiers/samsungstreaming.js",
"src/playbackstrategy/modifiers/samsungstreaming2015.js",
"src/playbackstrategy/legacyplayeradapter.js",
]
const namingConvention = [
{
selector: "default",
format: ["camelCase"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: ["function"],
modifiers: ["exported"],
format: ["camelCase", "PascalCase"],
},
{
selector: "import",
format: ["camelCase", "PascalCase"],
},
{
selector: "property",
format: ["camelCase", "UPPER_CASE"],
},
{
selector: ["enumMember"],
format: ["camelCase", "UPPER_CASE"],
},
{
selector: "variable",
format: ["camelCase", "PascalCase", "UPPER_CASE"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
{
selector: "property",
modifiers: ["requiresQuotes"],
format: null, // Format rules disabled
},
]
export default tseslint.config(
{
ignores: [...unsafe],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...sonarjs.configs.recommended,
eslintPluginUnicorn.configs["flat/recommended"],
],
languageOptions: {
ecmaVersion: 5,
sourceType: "module",
parser: tseslint.parser,
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
linterOptions: {
reportUnusedDisableDirectives: "error",
},
rules: {
// Discuss these!
"sonarjs/cognitive-complexity": "off",
"unicorn/consistent-function-scoping": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/catch-error-name": "off",
// STYLE
// Sorted alphabetically
"arrow-body-style": ["error", "as-needed"],
"curly": ["error", "multi-line"],
"default-param-last": "error",
"id-length": ["error", { min: 2, exceptions: ["_"] }],
"max-nested-callbacks": ["error", 3],
"new-cap": ["error", { newIsCap: true, capIsNew: false }],
"no-else-return": "error",
"no-floating-decimal": "error",
"no-multi-str": "error",
"no-var": "error",
"object-shorthand": "error",
"one-var": ["error", { initialized: "never" }],
"prefer-arrow-callback": "error",
"prefer-const": ["error", { destructuring: "all", ignoreReadBeforeAssign: true }],
"prefer-template": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"yoda": ["error", "never"],
"unicorn/no-null": "off",
"unicorn/switch-case-braces": ["error", "avoid"],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/naming-convention": ["error", ...namingConvention],
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
"@typescript-eslint/switch-exhaustiveness-check": [
"error",
{ allowDefaultCaseForExhaustiveSwitch: false, requireDefaultForNonUnion: true },
],
// PROBLEMS
// Sorted alphabetically
"array-callback-return": "error",
"default-case-last": "error",
"eqeqeq": ["error", "allow-null"],
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-caller": "error",
"no-console": "error",
"no-constant-binary-expression": "error",
"no-constructor-return": "error",
"no-debugger": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-implied-eval": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
"no-proto": "error",
"no-return-assign": "error",
"no-sequences": "error",
"no-unneeded-ternary": "error",
"no-unreachable-loop": "error",
"no-unused-private-class-members": "error",
"no-useless-call": "error",
"no-useless-return": "error",
"no-use-before-define": ["error", "nofunc"],
"no-with": "error",
"use-isnan": "error",
"wrap-iife": ["error", "any"],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/prefer-promise-reject-errors": "error",
"@typescript-eslint/prefer-return-this-type": "error",
"@typescript-eslint/return-await": "error",
// TV COMPATIBILITY – features that aren't fully supported
// Sorted alphabetically
"unicorn/no-array-for-each": "off",
"unicorn/no-for-loop": "off",
"unicorn/numeric-separators-style": "off",
"unicorn/prefer-array-flat": "off",
"unicorn/prefer-at": "off",
"unicorn/prefer-dom-node-append": "off",
"unicorn/prefer-dom-node-remove": "off",
"unicorn/prefer-includes": "off",
"unicorn/prefer-math-trunc": "off",
"unicorn/prefer-number-properties": "off",
"unicorn/prefer-optional-catch-binding": "off",
"unicorn/prefer-string-replace-all": "off",
// HAS ISSUES
"sonarjs/no-duplicate-string": "off",
"unicorn/no-array-callback-reference": "off",
"unicorn/no-array-method-this-argument": "off",
},
},
{
// Overrides for all JavaScript files
files: ["**/*.{js,cjs,mjs}"],
ignores: [...unsafe],
// Turn off type-aware linting
extends: [tseslint.configs.disableTypeChecked, ...tseslint.configs.recommended],
},
{
// Overrides for all tests
files: ["**/*.test.{js,cjs,mjs,ts,cts,mts}"],
rules: {
"max-nested-callbacks": "off",
"sonarjs/no-identical-functions": "off",
"unicorn/consistent-function-scoping": "off",
},
},
{
// Overrides for Jest unit tests
files: ["src/**/*.test.{js,cjs,mjs,ts,cts,mts}"],
extends: [eslintPluginJest.configs["flat/recommended"], eslintPluginJest.configs["flat/style"]],
rules: {
"jest/prefer-each": "error",
"jest/prefer-spy-on": "error",
},
}
)