-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
128 lines (128 loc) · 4.44 KB
/
index.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
module.exports = {
root: true,
env: {
es2022: true,
jest: true,
},
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
"eslint-plugin-jest",
"import",
"jest",
"json",
"node",
"prettier",
"simple-import-sort",
"sonarjs",
"sort-destructure-keys",
"typescript-sort-keys",
"unicorn",
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:jest/recommended",
"plugin:json/recommended-legacy",
"plugin:node/recommended",
"plugin:prettier/recommended",
"plugin:sonarjs/recommended-legacy",
"plugin:typescript-sort-keys/recommended",
"plugin:unicorn/recommended",
],
parserOptions: {
ecmaVersion: "latest",
project: "./tsconfig.json",
sourceType: "module",
},
overrides: [
{
files: ["test/**"],
plugins: ["jest"],
rules: {
// this turns the original rule off *only* for test files, for jest compatibility
"@typescript-eslint/unbound-method": "off",
"jest/unbound-method": "error",
},
},
],
rules: {
"import/default": "off",
"import/named": "off",
"import/namespace": "off",
"import/no-default-export": "error",
"import/no-extraneous-dependencies": [
"error",
{ devDependencies: ["test/**"] },
],
"import/prefer-default-export": "off",
"jest/no-jest-import": "off",
"json/*": "error",
"node/no-unpublished-import": [
"error",
{
allowModules: ["@jest/globals", "nock"],
},
],
"node/no-unsupported-features/es-syntax": "off",
"node/no-missing-import": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"sort-destructure-keys/sort-destructure-keys": "error",
// Noisy rule - we may have helpers/methods that we mark as @deprecated but aren't planning to remove in the near future. This rule also significantly adds to eslint running time, which slows down both local development and CI.
"sonarjs/deprecation": "off",
// This rule is not helpful in TypeScript files, and in JavaScript we often return different types from functions, so this is not a strictness level we want to enforce.
"sonarjs/function-return-type": "off",
// We may want to catch errors but not use the error object directly, just trigger error handling fallbacks within the catch block.
"sonarjs/no-ignored-exceptions": "off",
"sonarjs/no-nested-functions": ["warn", { threshold: 5 }],
"sonarjs/no-small-switch": "off",
// Overlaps with @typescript-eslint/prefer-nullish-coalescing
"sonarjs/prefer-nullish-coalescing": "off",
// Overlaps with @typescript-eslint/no-unused-vars
"sonarjs/sonar-no-unused-vars": "off",
// Overlaps with @typescript-eslint/prefer-optional-chain
"sonarjs/sonar-prefer-optional-chain": "off",
// Useful for guarding against prop mutation in React, but too much of a lift as very rarely do we apply readonly/ReadonlyArray<T> to type definitions
"sonarjs/sonar-prefer-read-only-props": "off",
// Noisy rule: if we wanted stricter linting of TODOs, we could use unicorn/expiring-todo-comments
"sonarjs/todo-tag": "off",
// A useful rule to consider for libraries to better document (and export) type definitions, but noisy in app usages (especially around redux type definitions)
"sonarjs/use-type-alias": "off",
/**
* {@link https://typescript-eslint.io/rules/consistent-type-imports | TypeScript ESLint: consistent-type-imports docs}
*/
"@typescript-eslint/consistent-type-imports": [
"error",
{
disallowTypeAnnotations: true,
fixStyle: "inline-type-imports",
prefer: "type-imports",
},
],
/** Prefers `import type {}` syntax over `import { type }` if all imports are type-only */
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
// Allow to name unused vars with _
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/unbound-method": "error",
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
},
},
};