openclaw/test/scripts/oxlint-config.test.ts
Peter Steinberger 6e067f7662
Some checks are pending
CI / security-fast (push) Blocked by required conditions
CI / pnpm-store-warmup (push) Blocked by required conditions
CI / build-artifacts (push) Blocked by required conditions
CI / native-i18n (push) Blocked by required conditions
CI / checks-ui (push) Blocked by required conditions
CI / control-ui-i18n (push) Blocked by required conditions
CI / (push) Blocked by required conditions
CI / QA Smoke CI (profile 1/2) (push) Blocked by required conditions
CI / QA Smoke CI (profile 2/2) (push) Blocked by required conditions
CI / -1 (push) Blocked by required conditions
CI / -2 (push) Blocked by required conditions
CI / checks-node-compat-node22 (push) Blocked by required conditions
CI / -3 (push) Blocked by required conditions
CI / check-bundled-channel-config-metadata (push) Blocked by required conditions
CI / check-dependencies (push) Blocked by required conditions
CI / check-guards (push) Blocked by required conditions
CI / check-lint (push) Blocked by required conditions
CI / check-prod-types (push) Blocked by required conditions
CI / check-shrinkwrap (push) Blocked by required conditions
CI / check-test-types (push) Blocked by required conditions
CI / check-additional-boundaries-a (push) Blocked by required conditions
CI / check-additional-boundaries-bcd (push) Blocked by required conditions
CI / check-additional-extension-package-boundary (push) Blocked by required conditions
CI / check-additional-runtime-topology-architecture (push) Blocked by required conditions
CI / check-session-accessor-boundary (push) Blocked by required conditions
CI / check-session-transcript-reader-boundary (push) Blocked by required conditions
CI / check-sqlite-session-flip-proof (push) Blocked by required conditions
CI / check-sqlite-session-schema-baseline (push) Blocked by required conditions
CI / check-docs (push) Blocked by required conditions
CI / skills-python (push) Blocked by required conditions
CI / -4 (push) Blocked by required conditions
CI / -5 (push) Blocked by required conditions
CI / macos-swift (push) Blocked by required conditions
CI / ios-build (push) Blocked by required conditions
CI / -6 (push) Blocked by required conditions
CI / preflight (push) Blocked by required conditions
CI / runner-admission (push) Waiting to run
Control UI Locale Refresh / Refresh tr (push) Blocked by required conditions
Control UI Locale Refresh / Refresh uk (push) Blocked by required conditions
Control UI Locale Refresh / Refresh vi (push) Blocked by required conditions
Control UI Locale Refresh / Refresh zh-CN (push) Blocked by required conditions
Control UI Locale Refresh / Refresh zh-TW (push) Blocked by required conditions
Control UI Locale Refresh / Commit control UI locale refresh (push) Blocked by required conditions
Control UI Locale Refresh / resolve-base (push) Waiting to run
Control UI Locale Refresh / Verify generated PR App permissions (push) Blocked by required conditions
Control UI Locale Refresh / Refresh ar (push) Blocked by required conditions
Control UI Locale Refresh / Refresh de (push) Blocked by required conditions
Control UI Locale Refresh / Refresh es (push) Blocked by required conditions
Control UI Locale Refresh / Refresh fa (push) Blocked by required conditions
Native App Locale Refresh / Refresh native pl (push) Blocked by required conditions
Native App Locale Refresh / Refresh native pt-BR (push) Blocked by required conditions
Native App Locale Refresh / Refresh native ru (push) Blocked by required conditions
Native App Locale Refresh / Refresh native sv (push) Blocked by required conditions
Native App Locale Refresh / Refresh native es (push) Blocked by required conditions
Native App Locale Refresh / Refresh native fa (push) Blocked by required conditions
Native App Locale Refresh / Refresh native fr (push) Blocked by required conditions
CI / ci-timings-summary (push) Blocked by required conditions
ClawSweeper Dispatch / dispatch (push) Waiting to run
CodeQL / Security High (actions) (push) Waiting to run
CodeQL / Security High (channel-runtime-boundary) (push) Waiting to run
CodeQL / Security High (core-auth-secrets) (push) Waiting to run
CodeQL / Security High (mcp-process-tool-boundary) (push) Waiting to run
CodeQL / Security High (network-ssrf-boundary) (push) Waiting to run
CodeQL / Security High (plugin-trust-boundary) (push) Waiting to run
CodeQL / Security High (process-exec-boundary) (push) Waiting to run
Control UI Locale Refresh / Refresh nl (push) Blocked by required conditions
Control UI Locale Refresh / Refresh pl (push) Blocked by required conditions
Control UI Locale Refresh / Refresh pt-BR (push) Blocked by required conditions
Control UI Locale Refresh / Refresh ru (push) Blocked by required conditions
Control UI Locale Refresh / Refresh th (push) Blocked by required conditions
Control UI Locale Refresh / Refresh fr (push) Blocked by required conditions
Control UI Locale Refresh / Refresh hi (push) Blocked by required conditions
Control UI Locale Refresh / Refresh id (push) Blocked by required conditions
Control UI Locale Refresh / Refresh it (push) Blocked by required conditions
Control UI Locale Refresh / Refresh ja-JP (push) Blocked by required conditions
Control UI Locale Refresh / Refresh ko (push) Blocked by required conditions
Docs Sync Publish Repo / sync-publish-repo (push) Waiting to run
Docs / docs (push) Waiting to run
Native App Locale Refresh / Refresh native th (push) Blocked by required conditions
Native App Locale Refresh / Refresh native tr (push) Blocked by required conditions
Native App Locale Refresh / Refresh native uk (push) Blocked by required conditions
Native App Locale Refresh / Refresh native vi (push) Blocked by required conditions
Native App Locale Refresh / Refresh native zh-CN (push) Blocked by required conditions
Native App Locale Refresh / Refresh native zh-TW (push) Blocked by required conditions
Native App Locale Refresh / Commit native locale refresh (push) Blocked by required conditions
Native App Locale Refresh / resolve-base (push) Waiting to run
Native App Locale Refresh / Verify generated PR App permissions (push) Blocked by required conditions
Native App Locale Refresh / Refresh native ar (push) Blocked by required conditions
Native App Locale Refresh / Refresh native de (push) Blocked by required conditions
Plugin Init Scaffold Validation / Validate provider scaffold (push) Waiting to run
Workflow Sanity / no-tabs (push) Waiting to run
Workflow Sanity / actionlint (push) Waiting to run
Workflow Sanity / generated-doc-baselines (push) Waiting to run
Native App Locale Refresh / Refresh native hi (push) Blocked by required conditions
Native App Locale Refresh / Refresh native id (push) Blocked by required conditions
Native App Locale Refresh / Refresh native it (push) Blocked by required conditions
Native App Locale Refresh / Refresh native ja-JP (push) Blocked by required conditions
Native App Locale Refresh / Refresh native ko (push) Blocked by required conditions
Native App Locale Refresh / Refresh native nl (push) Blocked by required conditions
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Waiting to run
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Blocked by required conditions
Plugin NPM Release / preview_plugins_npm (push) Waiting to run
Plugin NPM Release / Validate release publish approval (push) Blocked by required conditions
Plugin NPM Release / preview_plugin_pack (push) Blocked by required conditions
Plugin NPM Release / Preflight plugin npm package () (push) Blocked by required conditions
Plugin NPM Release / publish_plugins_npm (push) Blocked by required conditions
Plugin NPM Release / verify_plugins_npm (push) Blocked by required conditions
Website Installer Sync / static (push) Waiting to run
Website Installer Sync / linux-docker (push) Waiting to run
Website Installer Sync / macos-installer (push) Waiting to run
Website Installer Sync / windows-installer (push) Waiting to run
Website Installer Sync / sync-website (push) Blocked by required conditions
test: restore moving-main quality gates (#106972)
* test(agents): preserve caught abort cause

* refactor(browser): privatize route handler type

* test(lint): cover browser route override
2026-07-13 19:06:30 -07:00

239 lines
7.4 KiB
TypeScript

// Oxlint Config tests cover oxlint config script behavior.
import fs from "node:fs";
import JSON5 from "json5";
import { describe, expect, it } from "vitest";
type OxlintConfig = {
ignorePatterns?: string[];
overrides?: Array<{ files?: string[]; rules?: Record<string, unknown> }>;
rules?: Record<string, unknown>;
};
type OxlintTsconfig = {
include?: string[];
exclude?: string[];
};
const ZERO_BASELINE_RULES = [
"eslint/no-div-regex",
"eslint/no-constructor-return",
"eslint/no-extra-label",
"eslint/no-lone-blocks",
"eslint/no-multi-str",
"eslint/no-proto",
"eslint/no-regex-spaces",
"eslint/no-sequences",
"eslint/no-self-compare",
"eslint/no-var",
"eslint/no-param-reassign",
"eslint/no-implicit-coercion",
"eslint/no-useless-rename",
"eslint/no-useless-return",
"eslint/no-new-wrappers",
"eslint/no-else-return",
"eslint/no-lonely-if",
"eslint/no-case-declarations",
"eslint/object-shorthand",
"eslint/prefer-exponentiation-operator",
"eslint/prefer-const",
"eslint/prefer-numeric-literals",
"eslint/prefer-object-has-own",
"eslint/radix",
"eslint/unicode-bom",
"eslint/yoda",
"import/no-absolute-path",
"import/first",
"import/no-empty-named-blocks",
"import/no-duplicates",
"import/no-self-import",
"node/no-exports-assign",
"promise/no-new-statics",
"typescript/adjacent-overload-signatures",
"typescript/ban-tslint-comment",
"typescript/no-import-type-side-effects",
"typescript/no-inferrable-types",
"typescript/no-non-null-asserted-nullish-coalescing",
"typescript/no-unnecessary-qualifier",
"typescript/prefer-find",
"typescript/prefer-for-of",
"typescript/prefer-function-type",
"typescript/prefer-includes",
"typescript/prefer-reduce-type-parameter",
"typescript/prefer-return-this-type",
"unicorn/consistent-date-clone",
"unicorn/consistent-empty-array-spread",
"unicorn/no-console-spaces",
"unicorn/no-length-as-slice-end",
"unicorn/no-instanceof-array",
"unicorn/no-negation-in-equality-check",
"unicorn/no-new-buffer",
"unicorn/no-typeof-undefined",
"unicorn/no-unreadable-array-destructuring",
"unicorn/no-useless-error-capture-stack-trace",
"unicorn/no-zero-fractions",
"unicorn/prefer-array-flat",
"unicorn/prefer-array-some",
"unicorn/prefer-dom-node-text-content",
"unicorn/prefer-keyboard-event-key",
"unicorn/prefer-math-min-max",
"unicorn/prefer-negative-index",
"unicorn/prefer-node-protocol",
"unicorn/prefer-number-properties",
"unicorn/prefer-optional-catch-binding",
"unicorn/prefer-prototype-methods",
"unicorn/prefer-regexp-test",
"unicorn/prefer-set-has",
"unicorn/prefer-structured-clone",
"unicorn/prefer-string-slice",
"unicorn/require-array-join-separator",
"unicorn/require-number-to-fixed-digits-argument",
"unicorn/throw-new-error",
"vitest/no-import-node-test",
"vitest/consistent-vitest-vi",
"vitest/prefer-called-once",
"vitest/prefer-called-times",
"vitest/prefer-expect-type-of",
];
function readJson(path: string): unknown {
return JSON5.parse(fs.readFileSync(path, "utf8"));
}
describe("oxlint config", () => {
it("includes bundled extensions in type-aware lint coverage", () => {
const tsconfig = readJson("config/tsconfig/oxlint.json") as OxlintTsconfig;
expect(tsconfig.include).toContain("../../extensions/**/*");
expect(tsconfig.exclude ?? []).not.toContain("../../extensions");
});
it("includes scripts in root type-aware lint coverage", () => {
const tsconfig = readJson("config/tsconfig/oxlint.json") as OxlintTsconfig;
expect(tsconfig.include).toContain("../../scripts/**/*");
});
it("has a discoverable scripts tsconfig for type-aware linting", () => {
const tsconfig = readJson("scripts/tsconfig.json") as OxlintTsconfig;
expect(tsconfig.include).toContain("**/*.ts");
expect(tsconfig.exclude ?? []).not.toContain("**/*.ts");
});
it("has a discoverable test tsconfig for type-aware linting", () => {
const tsconfig = readJson("test/tsconfig.json") as OxlintTsconfig;
expect(tsconfig.include).toContain("**/*.ts");
expect(tsconfig.exclude ?? []).not.toContain("**/*.ts");
});
it("does not ignore the bundled extensions tree", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;
expect(config.ignorePatterns ?? []).not.toContain("extensions/");
});
it("keeps generated and vendored extension outputs ignored", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;
const ignorePatterns = config.ignorePatterns ?? [];
expect(ignorePatterns).toEqual([
"dist/",
"dist-runtime/",
"docs/_layouts/",
"**/a2ui.bundle.js",
"extensions/diffs/assets/viewer-runtime.js",
"extensions/diffs-language-pack/assets/viewer-runtime.js",
"node_modules/",
"patches/",
"pnpm-lock.yaml",
"skills/**",
"src/auto-reply/reply/export-html/template.js",
"vendor/",
"**/.cache/**",
"**/.openclaw-runtime-deps-copy-*/**",
"**/build/**",
"**/coverage/**",
"**/dist/**",
"**/dist-runtime/**",
"**/node_modules/**",
]);
});
it("keeps lint overrides limited to the indexed-access and test-file policies", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;
expect(config.overrides).toEqual([
{
files: ["extensions/browser/src/browser/routes/*.ts"],
rules: {
"oxc/no-async-endpoint-handlers": "off",
},
},
{
files: [
"packages/markdown-core/**/*.ts",
"packages/net-policy/**/*.ts",
"packages/media-understanding-common/**/*.ts",
"packages/terminal-core/**/*.ts",
"packages/normalization-core/**/*.ts",
"packages/model-catalog-core/**/*.ts",
"packages/web-content-core/**/*.ts",
"packages/agent-core/**/*.ts",
"packages/acp-core/**/*.ts",
"packages/ai/**/*.ts",
"packages/gateway-client/**/*.ts",
"packages/gateway-protocol/**/*.ts",
"packages/llm-core/**/*.ts",
"packages/media-core/**/*.ts",
"packages/media-generation-core/**/*.ts",
"packages/plugin-package-contract/**/*.ts",
"packages/sdk/**/*.ts",
],
rules: {
"typescript/no-non-null-assertion": "error",
},
},
{
files: [
"**/*.test.ts",
"**/*.test.tsx",
"**/*.e2e.test.ts",
"**/*.live.test.ts",
"**/*test-harness.ts",
"**/*test-helpers.ts",
"**/*test-support.ts",
],
rules: {
"typescript/no-explicit-any": "off",
},
},
]);
});
it("enables strict empty object type lint with named single-extends interfaces allowed", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;
expect(config.rules?.["typescript/no-empty-object-type"]).toEqual([
"error",
{ allowInterfaces: "with-single-extends" },
]);
});
it("enables exhaustive switch linting", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;
expect(config.rules?.["typescript/switch-exhaustiveness-check"]).toEqual([
"error",
{ considerDefaultExhaustiveForUnions: true },
]);
});
it("enables clean zero-baseline lint rules", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;
for (const rule of ZERO_BASELINE_RULES) {
expect(config.rules?.[rule]).toBe("error");
}
});
});