forked from ONEARMY/community-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.json
165 lines (164 loc) · 5.25 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"prettier",
"unicorn",
"import",
"simple-import-sort",
"sort-class-members",
"vitest"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:import/recommended",
"plugin:import/typescript",
"prettier" // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-alert": "error",
"sort-class-members/sort-class-members": [
"error",
{
"order": [
"[static-properties]",
"[static-methods]",
"[properties]",
"[conventional-private-properties]",
"constructor",
"[methods]",
"[conventional-private-methods]"
],
"accessorPairPositioning": "getThenSet"
}
],
"import/no-duplicates": "error",
"import/no-unresolved": [
"error",
{
"ignore": ["^src/", "^oa-([a-z]+)/", "^oa-components", "^oa-themes"]
}
],
"import/newline-after-import": "error",
"import/no-named-as-default": "off",
"max-classes-per-file": "error",
"no-useless-escape": "error",
"react/display-name": "error",
"react/jsx-no-target-blank": "warn",
// https://github.com/standard/eslint-config-standard-with-typescript/issues/248
"react/no-deprecated": "warn",
"react/prefer-stateless-function": "error",
"react/no-unescaped-entities": "off",
// as of v17 no longer required
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"simple-import-sort/imports": [
"error",
{
"groups": [
// Side effect imports that probably shouldn't be there anyway.
["^\\u0000"],
// Packages `react` related packages come first.
["^react", "^@?\\w"],
// Internal packages.
["^(@|components)(/.*|$)"],
// Relative imports. Put same-folder imports and `.` last.
[
"^\\.\\.(?!/?$)",
"^\\.\\./?$",
"^\\./(?=.*/)(?!/?$)",
"^\\.(?!/?$)",
"^\\./?$"
],
// Type imports seperated out.
[
"^node:.*\\u0000$",
"^@?\\w.*\\u0000$",
"^[^.].*\\u0000$",
"^\\..*\\u0000$"
],
// Style imports.
["^.+\\.?(css)$"]
]
}
],
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"React.FC": "`React.FC/React.FunctionComponent is deprecated and should be avoided. Consider using a function declaration instead`"
}
}
],
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports"
}
],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/interface-name-prefix": "off",
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
// NOTE - typings throughout the platform are fairly inconsistent, hence the wide range of rules
// 2023-02-17 - Disable as lint check now blocking build (warnings treated as error)
"@typescript-eslint/naming-convention": [
"off"
// {
// "selector": "default",
// "format": ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"],
// "leadingUnderscore": "allow"
// },
// {
// "selector": "classMethod",
// "format": ["camelCase"],
// "leadingUnderscore": "allow"
// }
],
// Filenames - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
"unicorn/filename-case": [
"error",
{
"cases": {
"camelCase": true,
"pascalCase": true
},
"ignore": ["vite-env.d.ts", "service-worker.ts"]
}
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-restricted-imports": [
"error",
{
"paths": [
// Prevent import of theme-ui link (prefer react-router link as prevents page reload nav)
{
"name": "theme-ui",
"importNames": ["Link"],
"message": "Please import 'ExternalLink' from 'oa-components' or 'Link' from 'react-router-dom' instead"
},
// Prevent importing components from workspace absolute path (prefer workspace name)
{
"name": "packages/components/dist",
"message": "Please import from 'oa-components' instead"
}
]
}
]
}
}