Something went wrong. Try again.
Something went wrong. Try again.
machine-memory oxlint.config.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257import 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/**", ".claude/**", ".codex/**", ".continue/**", ".cursor/**", ".gemini/**", ".opencode/**", ".pi/**", ".roo/**", ".windsurf/**",];
const antiSlopRules: DummyRuleMap = { "oxc/no-accumulating-spread": "error", "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,};
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", "no-unused-vars": [ "error", { vars: "all", args: "after-used", caughtErrors: "all", ignoreRestSiblings: false, varsIgnorePattern: "^_", argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_", }, ], "no-undef": "error", "no-unreachable": "error", "no-dupe-keys": "error", "no-dupe-class-members": "error", "no-fallthrough": "error", // Type imports stay separate, as consistent-type-specifier-style requires. "no-duplicate-imports": ["error", { allowSeparateTypeImports: true }], "no-implied-eval": "error", "no-eval": "error", "no-debugger": "error", "no-console": [ "error", { allow: ["warn", "error", "info"], }, ], "no-with": "error", "no-proto": "error", "no-new-wrappers": "error", "no-iterator": "error", "no-labels": "error", "no-var": "error", "no-shadow": [ "error", { hoist: "functions", builtinGlobals: true, }, ], "no-param-reassign": "error", "no-extend-native": "error", "no-func-assign": "error", "no-empty-function": "error", "no-extra-bind": "error", "no-useless-constructor": "error", "no-unused-expressions": "error", eqeqeq: [ "error", "always", { null: "ignore", }, ], curly: ["error", "all"], "no-implicit-coercion": [ "error", { boolean: true, number: true, string: true, disallowTemplateShorthand: true, }, ], "prefer-const": [ "error", { destructuring: "all", }, ], "prefer-arrow-callback": "error", complexity: ["error", 12], "max-depth": ["error", 4], "max-params": ["error", 5], "max-statements": ["error", 20], "import/no-duplicates": "error", "import/no-mutable-exports": "error", // Vitest's expect takes a failure message as its second argument. "vitest/valid-expect": ["error", { maxArgs: 2 }],};
// 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",};
const rules: DummyRuleMap = { ...preset.rules, ...recommended.rules, // tsconfig.base.json owns the Effect diagnostic policy and turns these off // (see the reasons there); the preset would report them again as warnings. "effecttsgo/any-unknown-in-error-context": "off", "effecttsgo/schema-class-missing-brand": "off", ...builtinRules, ...antiSlopRules, ...policyRules,};
// 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", "react", "typescript", "unicorn", "oxc", "import", "promise",];
// Strict application base: type-aware linting over @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.export const base = defineConfig({ ...preset, plugins: plugins.filter((plugin, index) => plugins.indexOf(plugin) === index), jsPlugins: [ ...(preset.jsPlugins ?? []), { name: "anti-slop", specifier: antiSlop }, ], // The preset turns oxlint's correctness category off. categories: { correctness: "error" }, env: { node: true, browser: false, es2022: true, }, globals: { Bun: "readonly", }, 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", }, }, { files: ["*.test.ts"], rules: { "no-shadow": "off", "max-statements": "off", }, }, ], rules,});
// Default config for the one-level-deep TypeScript workspaces. Object spread// instead of oxlint `extends`, which drops env/globals/overrides.export const workspaceConfig = defineConfig({ ...base, ignorePatterns: [...agentIgnores, "*.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, },});