-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
180 lines (175 loc) · 5.34 KB
/
.eslintrc.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
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
jest: true,
},
globals: {
React: true,
JSX: true,
},
parser: "@typescript-eslint/parser",
parserOptions: { tsconfigRootDir: __dirname, project: true },
plugins: [
"@typescript-eslint",
"import",
"simple-import-sort",
"unused-imports",
"formatjs",
],
extends: [
"eslint:recommended",
"next",
"next/core-web-vitals",
"plugin:testing-library/react",
"plugin:jest-dom/recommended",
// "plugin:@typescript-eslint/recommended-type-checked",
"plugin:chai-friendly/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
// "plugin:@typescript-eslint/recommended",
"prettier",
],
settings: {
typescript: true,
node: true,
},
rules: {
"no-empty-function": "off",
"no-console": "warn",
// "@typescript-eslint/explicit-module-boundary-types": "off",
"react/display-name": "off",
"react/jsx-curly-brace-presence": [
"warn",
{ props: "never", children: "never" },
],
"@next/next/no-img-element": "off",
// "@typescript-eslint/prefer-nullish-coalescing": "off",
// "@typescript-eslint/ban-ts-comment": [
// "error",
// { "ts-expect-error": "allow-with-description" },
// ],
// "@typescript-eslint/consistent-type-definitions": ["error", "type"],
// "@typescript-eslint/no-base-to-string": ["error"],
// "@typescript-eslint/consistent-type-imports": "error",
// "@typescript-eslint/no-unnecessary-type-assertion": "off",
// "@typescript-eslint/no-misused-promises": [
// 2,
// {
// checksVoidReturn: {
// attributes: false,
// },
// },
// ],
// ********************************************************************************************************************
// https://github.com/import-js/eslint-plugin-import
// ********************************************************************************************************************
// https://formatjs.io/docs/tooling/linter
"formatjs/enforce-description": "off",
"formatjs/enforce-default-message": ["error", "literal"],
"formatjs/enforce-placeholders": "error",
"formatjs/enforce-id": [
"off",
{
idInterpolationPattern: "[sha512:contenthash:base64:6]",
idWhitelist: ["^(front|admin)..*"],
},
],
"formatjs/enforce-plural-rules": [
"error",
{
one: true,
other: true,
zero: false,
},
],
"formatjs/no-camel-case": "error",
"formatjs/no-emoji": "error",
"formatjs/no-multiple-plurals": "error",
"formatjs/no-multiple-whitespaces": "error",
"formatjs/no-offset": "error",
"formatjs/no-id": "off",
"formatjs/no-literal-string-in-jsx": [
"off",
{
// Include or exclude additional prop checks (merged with the default checks)
props: {
include: [
// check aria attributes that the screen reader announces.
["*", "aria-{label,description,details,errormessage}"],
// check placeholder and title attribute of all native DOM elements.
["[a-z]*([a-z0-9])", "(placeholder|title)"],
// check alt attribute of the img tag.
["img", "alt"],
],
// Exclude will always override include.
exclude: [
// do not check `message` of the `Foo` tag.
["Foo", "message"],
// do not check aria-label and aria-description of `Bar` tag.
["Bar", "aria-{label,description}"],
],
},
},
],
"formatjs/no-complex-selectors": [
"error",
{
limit: 10,
},
],
// ********************************************************************************************************************
//#region //*=========== Unused Import ===========
"no-unused-vars": "off",
// "@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": [
"warn",
{
vars: "all",
varsIgnorePattern: "^_i_",
args: "after-used",
argsIgnorePattern: "^_i_",
},
],
//#endregion //*======== Unused Import ===========
// ********************************************************************************************************************
//#region //*=========== Import Sort ===========
"import/no-duplicates": "error",
"import/newline-after-import": "error",
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": [
"warn",
{
groups: [
// side effect imports
["^\\u0000"],
["^.+\\.s?css$"],
// types
["\\u0000$", "^@/types"],
// packages
["^@?\\w"],
["^@/config", "^@/content"],
["^@/hooks", "^@/utils"],
["^@/components"],
["^@/containers"],
["^@/styles"],
["^@/"],
// relative paths up until 3 level
[
"^\\./?$",
"^\\.(?!/?$)",
"^\\.\\./?$",
"^\\.\\.(?!/?$)",
"^\\.\\./\\.\\./?$",
"^\\.\\./\\.\\.(?!/?$)",
"^\\.\\./\\.\\./\\.\\./?$",
"^\\.\\./\\.\\./\\.\\.(?!/?$)",
],
["^"],
],
},
],
},
};