|
6 | 6 | "pedantic": "warn", |
7 | 7 | "perf": "warn", |
8 | 8 | "style": "warn", |
9 | | - "restriction": "warn" |
| 9 | + "restriction": "warn", |
10 | 10 | }, |
11 | 11 | "rules": { |
12 | 12 | // oxlint core rules |
|
48 | 48 | "no-void": "off", |
49 | 49 | // normally we do not enforce numeric separator usage |
50 | 50 | "numeric-separators-style": "off", |
| 51 | + // some functions that return promise and plain values in different conditions |
| 52 | + // need an async declaration while not always using await |
| 53 | + "require-await": "off", |
51 | 54 | // we prefer to sort imports with its pkg name |
52 | 55 | "sort-imports": "off", |
53 | 56 | // object keys are not supposed to be sorted in many cases |
|
111 | 114 | { |
112 | 115 | "selector": "variable", |
113 | 116 | "filter": { "regex": "^__(?:dirname|filename)$", "match": true }, |
114 | | - "format": null |
| 117 | + "format": null, |
115 | 118 | }, |
116 | 119 | { |
117 | 120 | "selector": "variable", |
118 | | - "filter": { "regex": "^(?:_{0,2})[A-Z][A-z0-9]*(?:_[A-Z][A-z0-9]*)*$", "match": true }, |
119 | | - "format": null |
| 121 | + "filter": { |
| 122 | + "regex": "^(?:_{0,2})[A-Z][A-z0-9]*(?:_[A-Z][A-z0-9]*)*$", |
| 123 | + "match": true, |
| 124 | + }, |
| 125 | + "format": null, |
120 | 126 | }, |
121 | 127 | { |
122 | 128 | "selector": ["variable"], |
123 | 129 | "format": ["camelCase", "PascalCase", "UPPER_CASE"], |
124 | | - "leadingUnderscore": "allow" |
| 130 | + "leadingUnderscore": "allow", |
125 | 131 | }, |
126 | 132 | { |
127 | 133 | "selector": ["parameter"], |
128 | 134 | "format": ["camelCase", "PascalCase"], |
129 | | - "leadingUnderscore": "allow" |
| 135 | + "leadingUnderscore": "allow", |
130 | 136 | }, |
131 | 137 | { |
132 | 138 | "selector": ["property"], |
133 | 139 | "format": ["camelCase", "PascalCase", "UPPER_CASE"], |
134 | 140 | "leadingUnderscore": "allow", |
135 | | - "trailingUnderscore": "allow" |
| 141 | + "trailingUnderscore": "allow", |
136 | 142 | }, |
137 | 143 | { "selector": "import", "format": ["PascalCase", "camelCase"] }, |
138 | 144 | { "selector": "typeLike", "format": ["PascalCase"] }, |
139 | | - { "selector": "enumMember", "format": ["PascalCase"] } |
140 | | - ] |
| 145 | + { "selector": "enumMember", "format": ["PascalCase"] }, |
| 146 | + ], |
141 | 147 | ], |
142 | 148 | // allow non-null assertions in some cases |
143 | 149 | "typescript/strict-boolean-expressions": [ |
144 | 150 | "warn", |
145 | | - { "allowNullableString": true, "allowNullableBoolean": true } |
| 151 | + { "allowNullableString": true, "allowNullableBoolean": true }, |
146 | 152 | ], |
147 | 153 | // missing async with await will be reported by typescript itself |
148 | 154 | "typescript/promise-function-async": "off", |
|
151 | 157 | // filename should not be enforced strictly, e.g. Vue SFC files shall be PascalCased |
152 | 158 | // we shall expect a project level setting |
153 | 159 | "unicorn/filename-case": "off", |
| 160 | + // this rule introduce too many false positives |
| 161 | + "unicorn/explicit-length-check": "off", |
154 | 162 | // toReversed can introduce memory overhead, |
155 | 163 | // in some chained calls it is better to use reverse as the "reversed" array is also a temp variable. |
156 | 164 | "unicorn/no-array-reverse": "off", |
|
159 | 167 | "unicorn/no-array-sort": "off", |
160 | 168 | // Array.forEach has its use cases |
161 | 169 | "unicorn/no-array-for-each": "off", |
| 170 | + // for code simplicity we may not want to create temp variables for single use |
| 171 | + "unicorn/no-await-expression-member": "off", |
162 | 172 | // conflicts with oxfmt code style |
163 | 173 | "unicorn/no-nested-ternary": "off", |
164 | 174 | // conflicts with oxfmt code style |
|
168 | 178 | // support starts with chrome71, firefox68. safari12.1, node12 |
169 | 179 | // leaving it to warn for edge cases |
170 | 180 | "unicorn/prefer-global-this": "warn", |
| 181 | + // prefer utf-8 over utf8 |
| 182 | + "unicorn/text-encoding-identifier-case": ["error", { "withDash": true }], |
171 | 183 |
|
172 | 184 | // stylistic rules with default being tweaked |
173 | 185 | "catch-error-name": ["warn", { "name": "err" }], |
|
188 | 200 | // type generics |
189 | 201 | "T", |
190 | 202 | // parameter name for unused variables |
191 | | - "_" |
192 | | - ] |
193 | | - } |
| 203 | + "_", |
| 204 | + ], |
| 205 | + }, |
194 | 206 | ], |
195 | 207 | "max-dependencies": ["warn", { "ignoreTypeImports": true, "max": 15 }], |
196 | 208 | "max-lines": ["warn", { "max": 500, "skipBlankLines": true, "skipComments": true }], |
197 | 209 | "max-lines-per-function": [ |
198 | 210 | "warn", |
199 | | - { "max": 100, "skipBlankLines": true, "skipComments": true } |
| 211 | + { "max": 100, "skipBlankLines": true, "skipComments": true }, |
200 | 212 | ], |
201 | 213 | "max-params": ["warn", 4], |
202 | | - "max-statements": ["warn", { "max": 30 }] |
| 214 | + "max-statements": ["warn", { "max": 30 }], |
203 | 215 | }, |
204 | 216 | "overrides": [ |
205 | 217 | { |
206 | 218 | "files": ["scripts/**/*.{js,ts}", "*.config.{js,ts}"], |
207 | 219 | "plugins": ["node"], |
208 | 220 | "rules": { |
209 | 221 | // config files shall be allowed to access process.env |
210 | | - "node/no-process-env": "off" |
211 | | - } |
| 222 | + "node/no-process-env": "off", |
| 223 | + }, |
212 | 224 | }, |
213 | 225 | { |
214 | 226 | "files": ["*.{jsx,tsx}"], |
|
218 | 230 | // disable jsdoc rules in react components |
219 | 231 | "jsdoc/require-returns": "off", |
220 | 232 | // allow loose boolean expressions in react components |
221 | | - "typescript/strict-boolean-expressions": "off" |
222 | | - } |
| 233 | + "typescript/strict-boolean-expressions": "off", |
| 234 | + }, |
223 | 235 | }, |
224 | 236 | { |
225 | 237 | "files": ["*.d.ts"], |
226 | 238 | "rules": { |
227 | 239 | // to extend existing modules, import/export must not appear in declaration files at top level |
228 | 240 | "import/unambiguous": "off", |
229 | 241 | // we need `export {}` to convert a file to a module |
230 | | - "unicorn/require-module-specifiers": "off" |
231 | | - } |
| 242 | + "unicorn/require-module-specifiers": "off", |
| 243 | + }, |
232 | 244 | }, |
233 | 245 | { |
234 | | - "files": ["*.bench.{js,ts}", "*.test.{js,ts}"], |
| 246 | + "files": ["*.{bench,spec,test}.{js,ts}", "*.{spec,test}.{js,ts}", "*.{spec,test}-d.ts"], |
235 | 247 | "plugins": ["vitest"], |
236 | 248 | "rules": { |
237 | 249 | "id-length": "off", |
|
246 | 258 | "typescript/prefer-ts-expect-error": "off", |
247 | 259 | "typescript/require-array-sort-compare": "off", |
248 | 260 | "vitest/prefer-called-once": "off", |
249 | | - "unicorn/consistent-function-scoping": "off" |
250 | | - } |
251 | | - } |
252 | | - ] |
| 261 | + "vitest/consistent-test-filename": [ |
| 262 | + "warn", |
| 263 | + { "allTestPattern": "__tests__", "pattern": ".*\\.spec\\.ts$" }, |
| 264 | + ], |
| 265 | + "unicorn/consistent-function-scoping": "off", |
| 266 | + }, |
| 267 | + }, |
| 268 | + ], |
253 | 269 | } |
0 commit comments