Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import { fileURLToPath } from "node:url";
import cloudflare from "@cloudflare/oxlint-config";import { recommended } from "@effect/tsgo/oxlint-presets";import { defineConfig } from "oxlint";import type { DummyRuleMap, OxlintConfig } from "oxlint";
// @cloudflare/oxlint-config without its root-only options, which only the default export adds.const { options: presetOptions, ...preset } = cloudflare;
// The anti-slop rules the preset does not carry. Absolute paths resolve the same from every// package config that spreads `base`.const antiSlop = fileURLToPath(import.meta.resolve("@jfalava/ts-standard/oxlint"));
const antiSlopRules: DummyRuleMap = { "anti-slop/no-module-mocking": "error", "anti-slop/require-safety-comment-for-type-assertion": "error",};
// Packages whose package.json lists `effect` add this plugin and its rules, and no others do:// its rules match code shape and would report code that is not Effect.export const antiSlopEffect = { jsPlugin: { name: "anti-slop-effect", specifier: fileURLToPath(import.meta.resolve("@jfalava/ts-standard/oxlint/effect")), }, 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 plugins: NonNullable<OxlintConfig["plugins"]> = [ ...(preset.plugins ?? []), ...(recommended.plugins ?? []), "typescript", "unicorn", "oxc", "import",];
// Preset rules turned off for good, each with its reason.const policyRules: DummyRuleMap = { // 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", // Vitest's expect takes a failure message as its second argument, as in manifold. "vitest/valid-expect": ["error", { maxArgs: 2 }],};
// Rules that fail when first turned on go here as `"<rule>": "off", // <findings>` until each// finding is fixed or disabled at its line with a reason. The map ends empty.const pendingRules: DummyRuleMap = {};
// The shared base for package configs. Packages spread it; `extends` would drop env and overrides.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: { ...preset.env, builtin: true }, ignorePatterns: ["**/dist/**"], rules: { ...preset.rules, ...recommended.rules, ...antiSlopRules, ...policyRules, ...pendingRules, },});
// Root-only options. Package lint scripts pass `--type-aware --type-check` and// `--report-unused-disable-directives-severity=error` on the command line instead.export default defineConfig({ ...base, options: { ...presetOptions, typeAware: true, typeCheck: true, },});