mirror of
https://github.com/Tencent/teamai-cli.git
synced 2026-10-02 03:14:40 +08:00
* ci(lint): enable type-aware linting with no-floating-promises and no-misused-promises tsc does not report a promise nobody awaits or an async callback handed to an API that ignores its result. In a CLI that is an error nobody sees. oxlint's --type-aware mode checks both through oxlint-tsgolint. - package.json: add oxlint-tsgolint 7.0.2003 (oxlint 1.85.0 needs >=7.0.2001) and pass --type-aware to `npm run lint`. The package ships prebuilt binaries as optional dependencies with no install script, so CI's `npm ci --ignore-scripts` needs no change. - .oxlintrc.json: turn on typescript/no-floating-promises and typescript/no-misused-promises. Under src/__tests__/**, no-misused-promises skips checksVoidReturn.arguments: vi.spyOn(fse, ...) types the spy from fs-extra's last overload, the callback one that returns void, so every correct async mockImplementation is flagged. - --type-aware also turns on oxlint's default type-aware rules. The ones with hits on main stay off, since each is its own evaluation under #836. The rest of the defaults have no hits and stay on. Fixes, all behavior-neutral: - dashboard.ts: the SSE debounce and the PID check become named async functions called with `void`; both already catch everything they throw. The HTTP handler becomes handleRequest, and createServer catches its rejection, logs it and answers 500. - import-repo-list.ts: track in-flight imports in a Set, so the unused array splice returned is gone. - scripts/mock-teamai-server.mjs: same handler wrapper as the dashboard, so a malformed JSON body answers 500 instead of an unhandled rejection. - ai-client.test.ts: schedule the mock process events with queueMicrotask. Refs #836. * ci(lint): turn on typescript/no-useless-default-assignment 1 prod hit, type-only: syncTeamUpdatesToLocal's last parameter was `placedRules: Record<string, string> | undefined = undefined`; it is now `placedRules?: Record<string, string>`. Refs #836. * ci(lint): list only the type-aware rules that would otherwise run as off consistent-return, no-unnecessary-boolean-literal-compare, no-unnecessary-type-arguments, no-unnecessary-type-assertion, no-unnecessary-type-conversion, no-unnecessary-type-parameters and no-unsafe-type-assertion are not default rules, so listing them as off changed nothing. The config keeps off only the nine default type-aware rules that --type-aware would turn on. `oxlint --type-aware --print-config` gives the same set of active rules before and after. Refs #836.
36 lines
1005 B
JSON
36 lines
1005 B
JSON
{
|
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
"rules": {
|
|
"no-unused-vars": [
|
|
"warn",
|
|
{
|
|
"argsIgnorePattern": "^_",
|
|
"varsIgnorePattern": "^_",
|
|
"ignoreRestSiblings": true
|
|
}
|
|
],
|
|
"typescript/no-floating-promises": "warn",
|
|
"typescript/no-misused-promises": "warn",
|
|
"typescript/no-base-to-string": "off",
|
|
"typescript/no-duplicate-type-constituents": "off",
|
|
"typescript/no-implied-eval": "off",
|
|
"typescript/no-meaningless-void-operator": "off",
|
|
"typescript/no-redundant-type-constituents": "off",
|
|
"typescript/await-thenable": "off",
|
|
"typescript/require-array-sort-compare": "off",
|
|
"typescript/restrict-template-expressions": "off",
|
|
"typescript/unbound-method": "off"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"files": ["src/__tests__/**"],
|
|
"rules": {
|
|
"typescript/no-misused-promises": [
|
|
"warn",
|
|
{ "checksVoidReturn": { "arguments": false } }
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|