Something went wrong. Try again.
Long-term memory for AI chat companions
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178import cloudflare from "@cloudflare/oxlint-config";import { recommended } from "@effect/tsgo/oxlint-presets";import { defineConfig } from "oxlint";import type { DummyRule, DummyRuleMap, OxlintConfig } from "oxlint";
// @cloudflare/oxlint-config without its root-only options, which the default export adds.const { options: presetOptions, ...preset } = cloudflare;
// The anti-slop rules the preset does not carry, published by @jfalava/ts-standard. Absolute// paths, as the preset uses, resolve the same from every workspace config.const antiSlop = new URL(import.meta.resolve("@jfalava/ts-standard/oxlint")).pathname;
// Agent-tool directories can appear anywhere; never lint them as source.// Patterns resolve relative to each consuming config's directory.export const agentIgnores = [ ".agent/**", ".agents/**", ".amp/**", ".claude/**", ".codex/**", ".cursor/**", ".opencode/**",];
const builtinRules: DummyRuleMap = { "typescript/no-explicit-any": "error", "typescript/no-unsafe-assignment": "error", "typescript/no-unsafe-call": "error", "typescript/no-unsafe-member-access": "error", "typescript/no-unsafe-return": "error", "typescript/no-implied-eval": "error", "no-unused-vars": [ "error", { vars: "all", args: "after-used", caughtErrors: "all", ignoreRestSiblings: false, varsIgnorePattern: "^_", argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_", }, ], "no-debugger": "error", "no-eval": "error", "no-var": "error", "prefer-const": "error", eqeqeq: ["error", "always", { null: "ignore" }], "import/no-duplicates": "error", "import/no-cycle": "error", "import/no-self-import": "error", // Workers and scripts report through console.error; console.log stays out. "no-console": ["error", { allow: ["warn", "error", "info"] }],};
const antiSlopRules: DummyRuleMap = { "anti-slop/no-module-mocking": "error", "anti-slop/require-safety-comment-for-type-assertion": "error",};
// Workspaces with a direct `effect` dependency add this plugin and its rules.const antiSlopEffect = { jsPlugin: { name: "anti-slop-effect", specifier: new URL(import.meta.resolve("@jfalava/ts-standard/oxlint/effect")).pathname, }, rules: { "anti-slop-effect/no-manual-effect-error-tag": "error", "anti-slop-effect/no-manual-tag-comparison": "error", "anti-slop-effect/no-manual-tagged-construction": "error", "anti-slop-effect/no-service-constructor-imports": "error", "anti-slop-effect/prefer-effect-match": "error", } satisfies DummyRuleMap,};
// Preset rules left as this repo had them, or turned off for good.const policyRules: DummyRuleMap = { // Off as before the preset; not widened yet. "typescript/no-non-null-assertion": "off", "typescript/no-unsafe-type-assertion": "off", // Taste: `T[]` and `Array<T>` are both fine. "typescript/array-type": "off", // Effect idioms: `import * as Schema`, Data.TaggedError classes checked with instanceof, and // generator callbacks declared next to their Effect.gen. "import/no-namespace": "off", "@nkzw/no-instanceof": "off", "unicorn/consistent-function-scoping": "off", "array-callback-return": "off",};
// @cloudflare/oxlint-config rules that fail today, with their finding counts.// Off until each is fixed or kept off with a reason (its migrate-oxlint-config skill).const pendingRules: DummyRuleMap = {};
const rules: DummyRuleMap = { ...preset.rules, ...recommended.rules, ...builtinRules, ...antiSlopRules, ...policyRules, ...pendingRules,};
// The preset relaxes these in test files; tests stay as strict as the rest of the code.const testStrictRules = [ "typescript/no-explicit-any", "typescript/no-non-null-assertion", "typescript/no-unsafe-argument", "typescript/no-unsafe-assignment", "typescript/no-unsafe-member-access", "typescript/only-throw-error",].map((rule): [string, DummyRule] => [rule, rules[rule] ?? "off"]);
const plugins: NonNullable<OxlintConfig["plugins"]> = [ ...(preset.plugins ?? []), ...(recommended.plugins ?? []), "eslint", "typescript", "unicorn", "oxc", "import", "promise",];
// Shared base for every workspace config: @cloudflare/oxlint-config, the @effect/tsgo// recommended preset, the anti-slop plugins and this repo's rules, which win where// they overlap. Options-free because oxlint accepts `options` only in the root config;// workspaces spread this and pass `--type-aware --type-check` on the command line. Object// spread, not oxlint `extends`, which drops env, globals and overrides from the parent.export const base = defineConfig({ ...preset, plugins: plugins.filter((plugin, index) => plugins.indexOf(plugin) === index), jsPlugins: [...(preset.jsPlugins ?? []), { name: "anti-slop", specifier: antiSlop }], categories: { correctness: "error", }, env: { es2024: true, }, overrides: [ ...(preset.overrides ?? []), { files: [ "**/*.{test,spec,integration,e2e}.{ts,tsx,mts,cts}", "**/__tests__/**/*.{ts,tsx,mts,cts}", ], rules: { ...Object.fromEntries(testStrictRules), // A correctness rule, so it ran in tests before the preset turned it off there. "typescript/unbound-method": "error", }, }, ], rules,});
// Default config for the one-level-deep workspaces.export const workspaceConfig = defineConfig({ ...base, ignorePatterns: [...agentIgnores, "dist/**", "*.d.ts", "**/*.d.ts"],});
// workspaceConfig plus the Effect rules, for workspaces with a direct `effect` dependency.export const effectWorkspaceConfig = defineConfig({ ...workspaceConfig, jsPlugins: [...(base.jsPlugins ?? []), antiSlopEffect.jsPlugin], rules: { ...rules, ...antiSlopEffect.rules },});
export default defineConfig({ ...base, options: { ...presetOptions, typeAware: true, typeCheck: true, },});