@averay/codeformat 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/eslint.config.js CHANGED
@@ -1,30 +1,64 @@
1
- import { FlatCompat } from '@eslint/eslintrc';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import js from '@eslint/js';
5
- import typescript from '@typescript-eslint/eslint-plugin';
1
+ import typescriptPlugin from '@typescript-eslint/eslint-plugin';
6
2
  import typescriptParser from '@typescript-eslint/parser';
7
3
  import prettierConfig from 'eslint-config-prettier';
4
+ import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
5
+ import importPlugin from 'eslint-plugin-import';
6
+ import promisePlugin from 'eslint-plugin-promise';
7
+ import regexpPlugin from 'eslint-plugin-regexp';
8
+ import sonarjsPlugin from 'eslint-plugin-sonarjs';
9
+ import unicornPlugin from 'eslint-plugin-unicorn';
8
10
 
9
- const compat = new FlatCompat({ baseDirectory: path.dirname(fileURLToPath(import.meta.url)) });
11
+ import convertWarnsToErrors from './lib/convertWarnsToErrors.js';
12
+ import rulesetShared from './rulesets/ruleset-shared.js';
13
+ import rulesetTypescript from './rulesets/ruleset-typescript.js';
14
+
15
+ export const extensions = {
16
+ js: ['js', 'jsx', 'cjs', 'cjs', 'mjs', 'mjsx'],
17
+ ts: ['ts', 'tsx', 'cts', 'cts', 'mts', 'mtsx'],
18
+ };
10
19
 
11
20
  export default [
21
+ // JavaScript & TypeScript
12
22
  {
13
- files: ['**/*.{js,jsx,cjs,cjsx,mjs,mjsx}'],
14
- rules: js.configs.recommended.rules,
23
+ files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
24
+ plugins: {
25
+ 'eslint-comments': eslintCommentsPlugin,
26
+ import: importPlugin,
27
+ promise: promisePlugin,
28
+ regexp: regexpPlugin,
29
+ sonarjs: sonarjsPlugin,
30
+ unicorn: unicornPlugin,
31
+ },
32
+ languageOptions: {
33
+ parserOptions: {
34
+ ...importPlugin.configs.recommended.parserOptions,
35
+ },
36
+ },
37
+ settings: {
38
+ 'import/parsers': {
39
+ espree: extensions.js.map((extension) => `.${extension}`),
40
+ },
41
+ },
42
+ rules: convertWarnsToErrors(rulesetShared),
15
43
  },
44
+
45
+ // TypeScript
16
46
  {
17
- ...compat.plugins('@typescript-eslint')[0],
18
- files: ['**/*.{ts,tsx,cts,ctsx,mts,mtsx}'],
19
- languageOptions: { parser: typescriptParser },
20
- rules: {
21
- ...js.configs.recommended.rules,
22
- ...typescript.configs['eslint-recommended'].rules,
23
- ...typescript.configs.recommended.rules,
24
- ...typescript.configs['recommended-requiring-type-checking'].rules,
25
- ...typescript.configs.strict.rules,
26
- '@typescript-eslint/no-explicit-any': 'off',
47
+ files: [`**/*.{${extensions.ts.join(',')}}`],
48
+ languageOptions: {
49
+ parser: typescriptParser,
50
+ },
51
+ plugins: {
52
+ '@typescript-eslint': typescriptPlugin,
27
53
  },
54
+ settings: {
55
+ ...importPlugin.configs.typescript.settings,
56
+ 'import/parsers': {
57
+ '@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
58
+ },
59
+ },
60
+ rules: convertWarnsToErrors(rulesetTypescript),
28
61
  },
62
+
29
63
  prettierConfig,
30
64
  ];
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import eslintConfig from './eslint.config.js';
1
+ import eslintConfig, { extensions } from './eslint.config.js';
2
2
 
3
- export { default as eslintConfig } from './eslint.config.js';
3
+ export { default as eslintConfig, extensions } from './eslint.config.js';
4
4
 
5
5
  export function makeEslintConfig(options) {
6
6
  return [
7
7
  ...eslintConfig,
8
8
  {
9
- files: ['**/*.{ts,tsx,cts,ctsx,mts,mtsx}'],
9
+ files: [`**/*.{${extensions.ts.join(',')}}`],
10
10
  languageOptions: {
11
11
  parserOptions: { project: options.tsconfigPath },
12
12
  },
@@ -0,0 +1,11 @@
1
+ export default function convertWarnsToErrors(ruleset) {
2
+ const rulesetProcessed = {};
3
+ for (const [key, value] of Object.entries(ruleset)) {
4
+ const processedValue = Array.isArray(value) ? [...value] : [value];
5
+ if (processedValue[0] === 'warn' || processedValue[0] === 1) {
6
+ processedValue[0] = 'error';
7
+ }
8
+ rulesetProcessed[key] = processedValue;
9
+ }
10
+ return rulesetProcessed;
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@averay/codeformat",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "author": "Adam Averay (https://adamaveray.com.au/)",
5
5
  "homepage": "https://github.com/adamaveray/codeformat",
6
6
  "repository": {
@@ -18,24 +18,31 @@
18
18
  ".editorconfig",
19
19
  ".prettierrc.json",
20
20
  "eslint.config.js",
21
- "index.js"
21
+ "index.js",
22
+ "lib",
23
+ "rulesets"
22
24
  ],
23
25
  "scripts": {
24
- "format": "prettier --write .",
25
- "lint": "prettier --check .",
26
+ "format": "npm run format:prettier && npm run format:eslint",
27
+ "format:eslint": "eslint --fix .",
28
+ "format:prettier": "prettier --write .",
29
+ "lint": "npm run lint:prettier && npm run lint:eslint",
30
+ "lint:eslint": "eslint .",
31
+ "lint:prettier": "prettier --check .",
26
32
  "prepare": "husky install"
27
33
  },
28
- "husky": {
29
- "hooks": {
30
- "pre-push": "npm run lint"
31
- }
32
- },
33
34
  "dependencies": {
34
- "@eslint/eslintrc": "^2.0.0",
35
- "@eslint/js": "^8.35.0",
36
- "@typescript-eslint/eslint-plugin": "^5.54.0",
37
- "@typescript-eslint/parser": "^5.54.0",
38
- "eslint-config-prettier": "^8.6.0",
35
+ "@eslint/eslintrc": "^2.0.1",
36
+ "@eslint/js": "^8.36.0",
37
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
38
+ "@typescript-eslint/parser": "^5.54.1",
39
+ "eslint-config-prettier": "^8.7.0",
40
+ "eslint-plugin-eslint-comments": "^3.2.0",
41
+ "eslint-plugin-import": "^2.27.5",
42
+ "eslint-plugin-promise": "^6.1.1",
43
+ "eslint-plugin-regexp": "^1.12.0",
44
+ "eslint-plugin-sonarjs": "^0.18.0",
45
+ "eslint-plugin-unicorn": "^46.0.0",
39
46
  "prettier": "^2.8.4"
40
47
  },
41
48
  "devDependencies": {
@@ -0,0 +1,290 @@
1
+ /* eslint sort-keys: "error" -- Organise rules */
2
+
3
+ import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
4
+ import importPlugin from 'eslint-plugin-import';
5
+ import promisePlugin from 'eslint-plugin-promise';
6
+ import regexpPlugin from 'eslint-plugin-regexp';
7
+ import sonarjsPlugin from 'eslint-plugin-sonarjs';
8
+ import unicornPlugin from 'eslint-plugin-unicorn';
9
+
10
+ export default {
11
+ // eslint-disable-next-line unicorn/no-useless-spread -- Keeps the unprefixed core rules together
12
+ ...{
13
+ 'accessor-pairs': ['error', { setWithoutGet: true }],
14
+ 'array-callback-return': 'error',
15
+ 'block-scoped-var': 'error',
16
+ 'capitalized-comments': ['error', 'always', { ignoreConsecutiveComments: true }],
17
+ 'consistent-return': 'error',
18
+ 'consistent-this': ['error', '_this'],
19
+ 'constructor-super': 'error',
20
+ 'default-case': 'error',
21
+ 'default-case-last': 'error',
22
+ 'default-param-last': 'error',
23
+ 'dot-notation': 'error',
24
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
25
+ 'for-direction': 'error',
26
+ 'func-names': ['error', 'as-needed'],
27
+ 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
28
+ 'getter-return': 'error',
29
+ 'global-require': 'error',
30
+ 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
31
+ 'guard-for-in': 'error',
32
+ 'id-denylist': ['error', 'e', 'err', 'evt', 'cb'],
33
+ 'lines-between-class-members': 'error',
34
+ 'logical-assignment-operators': ['error', 'always'],
35
+ 'max-classes-per-file': ['error', 1],
36
+ 'max-statements-per-line': 'error',
37
+ 'multiline-comment-style': 'error',
38
+ 'new-cap': ['error', { properties: true }],
39
+ 'no-alert': 'error',
40
+ 'no-array-constructor': 'error',
41
+ 'no-async-promise-executor': 'error',
42
+ 'no-await-in-loop': 'error',
43
+ 'no-bitwise': 'error',
44
+ 'no-buffer-constructor': 'error',
45
+ 'no-caller': 'error',
46
+ 'no-case-declarations': 'error',
47
+ 'no-class-assign': 'error',
48
+ 'no-compare-neg-zero': 'error',
49
+ 'no-cond-assign': 'error',
50
+ 'no-const-assign': 'error',
51
+ 'no-constant-binary-expression': 'error',
52
+ 'no-constant-condition': 'error',
53
+ 'no-constructor-return': 'error',
54
+ 'no-control-regex': 'error',
55
+ 'no-debugger': 'error',
56
+ 'no-delete-var': 'error',
57
+ 'no-div-regex': 'error',
58
+ 'no-dupe-args': 'error',
59
+ 'no-dupe-class-members': 'error',
60
+ 'no-dupe-else-if': 'error',
61
+ 'no-dupe-keys': 'error',
62
+ 'no-duplicate-case': 'error',
63
+ 'no-duplicate-imports': 'error',
64
+ 'no-empty': 'error',
65
+ 'no-empty-character-class': 'error',
66
+ 'no-empty-function': 'error',
67
+ 'no-empty-pattern': 'error',
68
+ 'no-empty-static-block': 'error',
69
+ 'no-eval': 'error',
70
+ 'no-ex-assign': 'error',
71
+ 'no-extend-native': 'error',
72
+ 'no-extra-bind': 'error',
73
+ 'no-extra-boolean-cast': 'error',
74
+ 'no-extra-label': 'error',
75
+ 'no-fallthrough': 'error',
76
+ 'no-func-assign': 'error',
77
+ 'no-global-assign': 'error',
78
+ 'no-implicit-coercion': 'error',
79
+ 'no-implicit-globals': 'error',
80
+ 'no-implied-eval': 'error',
81
+ 'no-import-assign': 'error',
82
+ 'no-inner-declarations': 'error',
83
+ 'no-invalid-regexp': 'error',
84
+ 'no-invalid-this': 'error',
85
+ 'no-irregular-whitespace': 'error',
86
+ 'no-iterator': 'error',
87
+ 'no-label-var': 'error',
88
+ 'no-labels': ['error', { allowLoop: true }],
89
+ 'no-lone-blocks': 'error',
90
+ 'no-loop-func': 'error',
91
+ 'no-loss-of-precision': 'error',
92
+ 'no-magic-numbers': [
93
+ 'error',
94
+ {
95
+ detectObjects: true,
96
+ enforceConst: true,
97
+ ignore: [-1, 0, 1],
98
+ ignoreArrayIndexes: true,
99
+ ignoreClassFieldInitialValues: true,
100
+ ignoreDefaultValues: true,
101
+ },
102
+ ],
103
+ 'no-misleading-character-class': 'error',
104
+ 'no-mixed-requires': 'error',
105
+ 'no-multi-assign': 'error',
106
+ 'no-multi-str': 'error',
107
+ 'no-nested-ternary': 'error',
108
+ 'no-new': 'error',
109
+ 'no-new-func': 'error',
110
+ 'no-new-native-nonconstructor': 'error',
111
+ 'no-new-object': 'error',
112
+ 'no-new-require': 'error',
113
+ 'no-new-symbol': 'error',
114
+ 'no-new-wrappers': 'error',
115
+ 'no-nonoctal-decimal-escape': 'error',
116
+ 'no-obj-calls': 'error',
117
+ 'no-octal': 'error',
118
+ 'no-octal-escape': 'error',
119
+ 'no-path-concat': 'error',
120
+ 'no-plusplus': 'error',
121
+ 'no-process-env': 'error',
122
+ 'no-process-exit': 'error',
123
+ 'no-promise-executor-return': 'error',
124
+ 'no-proto': 'error',
125
+ 'no-prototype-builtins': 'error',
126
+ 'no-redeclare': 'error',
127
+ 'no-regex-spaces': 'error',
128
+ 'no-restricted-globals': ['error', 'event'],
129
+ 'no-restricted-syntax': ['error', 'WithStatement', "BinaryExpression[operator='in']"],
130
+ 'no-return-assign': 'error',
131
+ 'no-return-await': 'error',
132
+ 'no-script-url': 'error',
133
+ 'no-self-assign': 'error',
134
+ 'no-self-compare': 'error',
135
+ 'no-sequences': 'error',
136
+ 'no-setter-return': 'error',
137
+ 'no-shadow': ['error', { hoist: 'all' }],
138
+ 'no-shadow-restricted-names': 'error',
139
+ 'no-sparse-arrays': 'error',
140
+ 'no-template-curly-in-string': 'error',
141
+ 'no-this-before-super': 'error',
142
+ 'no-throw-literal': 'error',
143
+ 'no-undef': 'error',
144
+ 'no-undef-init': 'error',
145
+ 'no-underscore-dangle': [
146
+ 'error',
147
+ {
148
+ allow: ['_', '_this', '_1', '_2', '_3', '_4', '_5', '_6', '_7', '_8', '_9'],
149
+ allowAfterSuper: true,
150
+ allowAfterThis: true,
151
+ allowAfterThisConstructor: true,
152
+ allowFunctionParams: false,
153
+ allowInArrayDestructuring: false,
154
+ enforceInClassFields: true,
155
+ enforceInMethodNames: true,
156
+ },
157
+ ],
158
+ 'no-unmodified-loop-condition': 'error',
159
+ 'no-unneeded-ternary': 'error',
160
+ 'no-unreachable': 'error',
161
+ 'no-unreachable-loop': 'error',
162
+ 'no-unsafe-finally': 'error',
163
+ 'no-unsafe-negation': 'error',
164
+ 'no-unsafe-optional-chaining': 'error',
165
+ 'no-unused-expressions': 'error',
166
+ 'no-unused-labels': 'error',
167
+ 'no-unused-private-class-members': 'error',
168
+ 'no-unused-vars': 'error',
169
+ 'no-use-before-define': 'error',
170
+ 'no-useless-backreference': 'error',
171
+ 'no-useless-call': 'error',
172
+ 'no-useless-catch': 'error',
173
+ 'no-useless-computed-key': ['error', { enforceForClassMembers: true }],
174
+ 'no-useless-concat': 'error',
175
+ 'no-useless-constructor': 'error',
176
+ 'no-useless-escape': 'error',
177
+ 'no-useless-rename': 'error',
178
+ 'no-useless-return': 'error',
179
+ 'no-var': 'error',
180
+ 'no-void': 'error',
181
+ 'no-with': 'error',
182
+ 'object-shorthand': ['error', 'always', { avoidExplicitReturnArrows: true, avoidQuotes: true }],
183
+ 'one-var': ['error', 'never'],
184
+ 'operator-assignment': 'error',
185
+ 'padding-line-between-statements': [
186
+ 'error',
187
+ /* eslint-disable sort-keys -- Logically ordered */
188
+ { blankLine: 'always', prev: 'directive', next: '*' },
189
+ { blankLine: 'always', prev: 'function', next: 'function' },
190
+ /* eslint-enable sort-keys -- Restore */
191
+ ],
192
+ 'prefer-arrow-callback': 'error',
193
+ 'prefer-const': 'error',
194
+ 'prefer-destructuring': 'error',
195
+ 'prefer-exponentiation-operator': 'error',
196
+ 'prefer-numeric-literals': 'error',
197
+ 'prefer-object-spread': 'error',
198
+ 'prefer-promise-reject-errors': 'error',
199
+ 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
200
+ 'prefer-rest-params': 'error',
201
+ 'prefer-spread': 'error',
202
+ 'prefer-template': 'error',
203
+ radix: 'error',
204
+ 'require-atomic-updates': 'error',
205
+ 'require-unicode-regexp': 'error',
206
+ 'require-yield': 'error',
207
+ 'spaced-comment': 'error',
208
+ 'symbol-description': 'error',
209
+ 'use-isnan': 'error',
210
+ 'valid-typeof': 'error',
211
+ 'vars-on-top': 'error',
212
+ yoda: 'error',
213
+ },
214
+
215
+ ...eslintCommentsPlugin.configs.recommended.rules,
216
+ 'eslint-comments/no-unused-disable': 'error',
217
+ 'eslint-comments/require-description': 'error',
218
+
219
+ ...importPlugin.configs.recommended.rules,
220
+ 'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
221
+ 'import/first': ['error', 'absolute-first'],
222
+ 'import/newline-after-import': 'error',
223
+ 'import/no-absolute-path': 'error',
224
+ 'import/no-amd': 'error',
225
+ 'import/no-anonymous-default-export': [
226
+ 'error',
227
+ { allowArray: true, allowCallExpression: true, allowLiteral: true, allowNew: true, allowObject: true },
228
+ ],
229
+ 'import/no-commonjs': 'error',
230
+ 'import/no-cycle': ['error', { ignoreExternal: true }],
231
+ 'import/no-duplicates': ['error', { 'prefer-inline': true }],
232
+ 'import/no-dynamic-require': 'error',
233
+ 'import/no-empty-named-blocks': 'error',
234
+ 'import/no-extraneous-dependencies': 'error',
235
+ 'import/no-mutable-exports': 'error',
236
+ 'import/no-named-as-default-member': 'error',
237
+ 'import/no-named-default': 'error',
238
+ 'import/no-self-import': 'error',
239
+ 'import/no-unresolved': ['error', { caseSensitiveStrict: true }],
240
+ 'import/no-unused-modules': 'error',
241
+ 'import/no-useless-path-segments': ['error', { noUselessIndex: true }],
242
+ 'import/no-webpack-loader-syntax': 'error',
243
+ 'import/order': [
244
+ 'error',
245
+ {
246
+ alphabetize: { order: 'asc' },
247
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
248
+ 'newlines-between': 'always',
249
+ warnOnUnassignedImports: true,
250
+ },
251
+ ],
252
+ 'import/prefer-default-export': 'error',
253
+ 'import/unambiguous': 'error',
254
+
255
+ ...promisePlugin.configs.recommended.rules,
256
+ 'promise/no-multiple-resolved': 'error',
257
+
258
+ ...regexpPlugin.configs.recommended.rules,
259
+ 'regexp/hexadecimal-escape': ['error', 'never'],
260
+ 'regexp/letter-case': 'error',
261
+ 'regexp/no-empty-character-class': 'error',
262
+ 'regexp/no-extra-lookaround-assertions': 'error',
263
+ 'regexp/no-misleading-capturing-group': 'error',
264
+ 'regexp/no-misleading-unicode-character': 'error',
265
+ 'regexp/no-missing-g-flag': 'error',
266
+ 'regexp/no-octal': 'error',
267
+ 'regexp/no-standalone-backslash': 'error',
268
+ 'regexp/prefer-escape-replacement-dollar-char': 'error',
269
+ 'regexp/prefer-named-backreference': 'error',
270
+ 'regexp/prefer-named-replacement': 'error',
271
+ 'regexp/prefer-quantifier': 'error',
272
+ 'regexp/prefer-result-array-groups': 'error',
273
+ 'regexp/unicode-escape': 'error',
274
+ 'regexp/use-ignore-case': 'error',
275
+
276
+ ...sonarjsPlugin.configs.recommended.rules,
277
+ 'sonarjs/cognitive-complexity': 'off',
278
+ 'sonarjs/max-switch-cases': 'off',
279
+ 'sonarjs/no-inverted-boolean-check': 'error',
280
+ 'sonarjs/no-nested-template-literals': 'off',
281
+ 'sonarjs/no-small-switch': 'off',
282
+ 'sonarjs/prefer-immediate-return': 'off',
283
+ 'sonarjs/prefer-single-boolean-return': 'off',
284
+
285
+ ...unicornPlugin.configs.recommended.rules,
286
+ 'unicorn/filename-case': 'off',
287
+ 'unicorn/no-unsafe-regex': 'error',
288
+ 'unicorn/prefer-event-target': 'error',
289
+ 'unicorn/require-post-message-target-origin': 'error',
290
+ };
@@ -0,0 +1,183 @@
1
+ /* eslint sort-keys: "error" -- Organise rules */
2
+
3
+ import js from '@eslint/js';
4
+ import typescriptPlugin from '@typescript-eslint/eslint-plugin';
5
+ import importPlugin from 'eslint-plugin-import';
6
+
7
+ export default {
8
+ ...js.configs.recommended.rules,
9
+ ...importPlugin.configs.typescript.rules,
10
+ ...typescriptPlugin.configs['eslint-recommended'].rules,
11
+ ...typescriptPlugin.configs.recommended.rules,
12
+ ...typescriptPlugin.configs['recommended-requiring-type-checking'].rules,
13
+ ...typescriptPlugin.configs.strict.rules,
14
+
15
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
16
+ '@typescript-eslint/array-type': 'error',
17
+ '@typescript-eslint/await-thenable': 'error',
18
+ '@typescript-eslint/ban-ts-comment': 'error',
19
+ '@typescript-eslint/ban-types': 'error',
20
+ '@typescript-eslint/class-literal-property-style': 'off', // Breaks subclassed getters
21
+ '@typescript-eslint/consistent-indexed-object-style': 'error',
22
+ '@typescript-eslint/consistent-type-assertions': [
23
+ 'error',
24
+ { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' },
25
+ ],
26
+ '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
27
+ '@typescript-eslint/consistent-type-exports': ['error', { fixMixedExportsWithInlineTypeSpecifier: true }],
28
+ '@typescript-eslint/consistent-type-imports': 'error',
29
+ '@typescript-eslint/default-param-last': 'error',
30
+ '@typescript-eslint/dot-notation': 'error',
31
+ '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
32
+ '@typescript-eslint/explicit-member-accessibility': ['error', { overrides: { constructors: 'no-public' } }],
33
+ '@typescript-eslint/explicit-module-boundary-types': ['error', { allowArgumentsExplicitlyTypedAsAny: true }],
34
+ '@typescript-eslint/member-ordering': 'off',
35
+ '@typescript-eslint/method-signature-style': 'error',
36
+ '@typescript-eslint/naming-convention': [
37
+ 'error',
38
+ /* eslint-disable sort-keys -- Logically ordered */
39
+ {
40
+ selector: 'default',
41
+ format: ['camelCase'],
42
+ },
43
+ {
44
+ selector: 'variable',
45
+ modifiers: ['const'],
46
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
47
+ },
48
+ {
49
+ selector: 'variable',
50
+ modifiers: ['const'],
51
+ filter: { regex: '^_(static|\\d+)?$', match: true },
52
+ format: ['camelCase'],
53
+ leadingUnderscore: 'allow',
54
+ },
55
+ {
56
+ selector: 'parameter',
57
+ format: ['camelCase'],
58
+ leadingUnderscore: 'allow',
59
+ },
60
+ {
61
+ selector: 'property',
62
+ format: ['camelCase', 'UPPER_CASE'],
63
+ },
64
+ {
65
+ selector: 'classProperty',
66
+ modifiers: ['static'],
67
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
68
+ },
69
+ {
70
+ selector: 'enumMember',
71
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
72
+ },
73
+ {
74
+ selector: 'function',
75
+ format: ['camelCase', 'PascalCase'],
76
+ },
77
+ {
78
+ selector: 'typeLike',
79
+ format: ['PascalCase'],
80
+ },
81
+ {
82
+ selector: ['objectLiteralProperty'],
83
+ format: [],
84
+ },
85
+ {
86
+ selector: ['classProperty', 'objectLiteralMethod'],
87
+ format: ['camelCase', 'UPPER_CASE'],
88
+ },
89
+ {
90
+ selector: 'typeParameter',
91
+ format: ['PascalCase'],
92
+ custom: { regex: '^([A-Z]|T[A-Z][a-zA-Z]+|key)$', match: true },
93
+ },
94
+ /* eslint-enable sort-keys -- Logically ordered */
95
+ ],
96
+ '@typescript-eslint/no-array-constructor': 'error',
97
+ '@typescript-eslint/no-base-to-string': 'error',
98
+ '@typescript-eslint/no-confusing-non-null-assertion': 'error',
99
+ '@typescript-eslint/no-confusing-void-expression': 'error',
100
+ '@typescript-eslint/no-dupe-class-members': 'error',
101
+ '@typescript-eslint/no-duplicate-imports': 'error',
102
+ '@typescript-eslint/no-empty-function': 'error',
103
+ '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
104
+ '@typescript-eslint/no-explicit-any': 'off',
105
+ '@typescript-eslint/no-extra-non-null-assertion': 'error',
106
+ '@typescript-eslint/no-extraneous-class': 'error',
107
+ '@typescript-eslint/no-floating-promises': 'error',
108
+ '@typescript-eslint/no-for-in-array': 'error',
109
+ '@typescript-eslint/no-implied-eval': 'error',
110
+ '@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
111
+ '@typescript-eslint/no-invalid-this': 'error',
112
+ '@typescript-eslint/no-invalid-void-type': 'error',
113
+ '@typescript-eslint/no-loop-func': 'error',
114
+ '@typescript-eslint/no-loss-of-precision': 'error',
115
+ '@typescript-eslint/no-meaningless-void-operator': 'error',
116
+ '@typescript-eslint/no-misused-new': 'error',
117
+ '@typescript-eslint/no-misused-promises': 'error',
118
+ '@typescript-eslint/no-namespace': 'error',
119
+ '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
120
+ '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
121
+ '@typescript-eslint/no-non-null-assertion': 'error',
122
+ '@typescript-eslint/no-redeclare': 'error',
123
+ '@typescript-eslint/no-require-imports': 'error',
124
+ '@typescript-eslint/no-restricted-imports': 'error',
125
+ '@typescript-eslint/no-shadow': 'error',
126
+ '@typescript-eslint/no-this-alias': 'error',
127
+ '@typescript-eslint/no-throw-literal': 'error',
128
+ '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
129
+ '@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
130
+ '@typescript-eslint/no-unnecessary-qualifier': 'error',
131
+ '@typescript-eslint/no-unnecessary-type-arguments': 'error',
132
+ '@typescript-eslint/no-unnecessary-type-assertion': 'error',
133
+ '@typescript-eslint/no-unnecessary-type-constraint': 'error',
134
+ '@typescript-eslint/no-unused-expressions': 'error',
135
+ '@typescript-eslint/no-unused-vars': [
136
+ 'error',
137
+ {
138
+ argsIgnorePattern: '^_\\w*$',
139
+ caughtErrorsIgnorePattern: '^_\\w*$',
140
+ varsIgnorePattern: '^(_\\d*|React)$',
141
+ },
142
+ ],
143
+ '@typescript-eslint/no-use-before-define': 'error',
144
+ '@typescript-eslint/no-useless-constructor': 'error',
145
+ '@typescript-eslint/no-useless-empty-export': 'error',
146
+ '@typescript-eslint/no-var-requires': 'error',
147
+ '@typescript-eslint/non-nullable-type-assertion-style': 'error',
148
+ '@typescript-eslint/padding-line-between-statements': [
149
+ 'error',
150
+ /* eslint-disable sort-keys -- Logically ordered */
151
+ { blankLine: 'always', prev: 'directive', next: '*' },
152
+ { blankLine: 'always', prev: 'function', next: 'function' },
153
+ { blankLine: 'never', prev: 'interface', next: 'class' },
154
+ /* eslint-enable sort-keys -- Logically ordered */
155
+ ],
156
+ '@typescript-eslint/prefer-as-const': 'error',
157
+ '@typescript-eslint/prefer-enum-initializers': 'error',
158
+ '@typescript-eslint/prefer-for-of': 'error',
159
+ '@typescript-eslint/prefer-function-type': 'error',
160
+ '@typescript-eslint/prefer-includes': 'error',
161
+ '@typescript-eslint/prefer-literal-enum-member': 'error',
162
+ '@typescript-eslint/prefer-namespace-keyword': 'error',
163
+ '@typescript-eslint/prefer-nullish-coalescing': [
164
+ 'error',
165
+ { ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false },
166
+ ],
167
+ '@typescript-eslint/prefer-optional-chain': 'error',
168
+ '@typescript-eslint/prefer-readonly': 'error',
169
+ '@typescript-eslint/prefer-reduce-type-parameter': 'error',
170
+ '@typescript-eslint/prefer-return-this-type': 'error',
171
+ '@typescript-eslint/prefer-string-starts-ends-with': 'error',
172
+ '@typescript-eslint/prefer-ts-expect-error': 'error',
173
+ '@typescript-eslint/promise-function-async': 'error',
174
+ '@typescript-eslint/require-array-sort-compare': 'error',
175
+ '@typescript-eslint/restrict-plus-operands': 'error',
176
+ '@typescript-eslint/restrict-template-expressions': 'error',
177
+ '@typescript-eslint/return-await': 'error',
178
+ '@typescript-eslint/strict-boolean-expressions': ['error', { allowNullableString: true }],
179
+ '@typescript-eslint/switch-exhaustiveness-check': 'error',
180
+ '@typescript-eslint/triple-slash-reference': 'error',
181
+ '@typescript-eslint/unbound-method': 'off', // Does not support @autobind nor recognise binding in constructors
182
+ '@typescript-eslint/unified-signatures': 'error',
183
+ };