Skip to content

Commit c5c3c60

Browse files
authored
chore: enable e18e lint rules (#947)
Enable 13 `@e18e/eslint-plugin` rules through the existing Vite+ configuration to detect inefficient code patterns. The rules support the ES2022 target and Oxlint. Use `Object.hasOwn()` in multipart filename handling. Keep regular expressions inline in tests and mark the dynamically loaded plugin as used in Fallow. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of form data by checking for an own `httpVersion` property, avoiding reliance on potentially overridden object methods. * **Chores** * Added additional code-quality checks to the development workflow and updated dependency tracking configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 0455df0 commit c5c3c60

5 files changed

Lines changed: 71 additions & 3 deletions

File tree

‎.fallowrc.jsonc‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"$schema": "./node_modules/fallow/schema.json",
33
"entry": ["src/index.ts", "examples/*.mjs", "test/{mts/src,fixtures/ts-esm}/**/*.{ts,mts}", "test/**/*.bench.ts"],
4-
// scripts/tsrs.js selects and imports the compiler dynamically for each platform.
5-
"ignoreDependencies": ["@ts-rs/wasm", "tsrs"],
4+
"ignoreDependencies": [
5+
// Oxlint loads this plugin through lint.jsPlugins in vite.config.ts.
6+
"@e18e/eslint-plugin",
7+
// scripts/tsrs.js selects and imports the compiler dynamically for each platform.
8+
"@ts-rs/wasm",
9+
"tsrs",
10+
],
611
}

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"ylru": "^2.0.0"
6767
},
6868
"devDependencies": {
69+
"@e18e/eslint-plugin": "^0.8.1",
6970
"@eggjs/tsconfig": "^2.0.0",
7071
"@ts-rs/wasm": "0.15.0-ts7.1.0-dev.20260929",
7172
"@types/busboy": "^1.5.4",

‎pnpm-lock.yaml‎

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/FormData.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class FormData extends _FormData {
2020
// formidable and the browser add a name property
2121
// fs- and request- streams have path property
2222
filename = path.basename(options.filename || value.name || value.path);
23-
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
23+
} else if (value.readable && Object.hasOwn(value, 'httpVersion')) {
2424
// or try http response
2525
filename = path.basename(value.client._httpMessage.path || '');
2626
}

‎vite.config.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default defineConfig({
3131
},
3232
},
3333
lint: {
34+
jsPlugins: ['@e18e/eslint-plugin'],
3435
options: {
3536
typeAware: true,
3637
typeCheck: true,
@@ -48,6 +49,20 @@ export default defineConfig({
4849
perf: 'allow',
4950
},
5051
rules: {
52+
// Keep e18e rules compatible with ES2022 and Oxlint's JavaScript plugin support.
53+
'e18e/prefer-array-at': 'error',
54+
'e18e/prefer-array-fill': 'error',
55+
'e18e/prefer-includes': 'error',
56+
'e18e/prefer-nullish-coalescing': 'error',
57+
'e18e/prefer-object-has-own': 'error',
58+
'e18e/prefer-url-canparse': 'error',
59+
'e18e/prefer-array-from-map': 'error',
60+
'e18e/prefer-timer-args': 'error',
61+
'e18e/prefer-date-now': 'error',
62+
'e18e/prefer-regex-test': 'error',
63+
'e18e/prefer-array-some': 'error',
64+
'e18e/prefer-static-regex': 'error',
65+
'e18e/prefer-string-fromcharcode': 'error',
5166
'no-extend-native': 'warn',
5267
// Disable TypeScript rules
5368
'typescript/explicit-function-return-type': 'allow',
@@ -158,6 +173,14 @@ export default defineConfig({
158173
'arrow-body-style': 'allow',
159174
'prefer-destructuring': 'allow',
160175
},
176+
overrides: [
177+
{
178+
files: ['test/**'],
179+
rules: {
180+
'e18e/prefer-static-regex': 'off',
181+
},
182+
},
183+
],
161184
ignorePatterns: ['test/fixtures/ts*', 'test/mts'],
162185
},
163186
// plugins: [codspeedPlugin()],

0 commit comments

Comments
 (0)