Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions docs/user-guide/shared-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,36 @@ Three settings describe your project, not a rule, so they are declared once unde

## The settings

- **`entryFiles`**: the files allowed to run Effects and import adapters.
- used by:
- [`run-only-in-runner`](rules/run-only-in-runner.md)
- [`adapter-import-boundary`](rules/adapter-import-boundary.md)
- default: `**/main.ts`, `**/cli.ts`, `**/bin/**`. `index.ts` is excluded on purpose: it is usually a barrel, and exempting it would let adapters reach the rest of the application through re-exports.
- **`testFiles`**: the test files, exempt from the rules that tests legitimately break and the only files `prefer-effect-vitest` checks.
- used by:
- [`run-only-in-runner`](rules/run-only-in-runner.md), [`adapter-import-boundary`](rules/adapter-import-boundary.md), [`no-effect-promise`](rules/no-effect-promise.md), [`provide-named-layer`](rules/provide-named-layer.md), [`no-provide-on-definition`](rules/no-provide-on-definition.md), [`split-success-path-from-error-handling`](rules/split-success-path-from-error-handling.md), [`all-errors-handled-at-boundary`](rules/all-errors-handled-at-boundary.md), [`anti-slop-no-service-constructor-imports`](rules/anti-slop-no-service-constructor-imports.md): skip test files
- [`no-throw-or-primitive-failure`](rules/no-throw-or-primitive-failure.md): skips only primitive failures there
- [`single-style-per-function`](rules/single-style-per-function.md): treats their helpers like tests
- [`prefer-effect-vitest`](rules/prefer-effect-vitest.md): checks only them
- default: `**/*.test.*`, `**/*.spec.*`, `**/__tests__/**`, `**/test/**`, `**/tests/**`. A helper directory such as `src/testing/` does not count as tests: it is support code.
- **`discriminants`**: the fields that discriminate a closed union.
- used by:
- [`no-manual-discriminant-comparison`](rules/no-manual-discriminant-comparison.md)
- [`no-manual-discriminant-construction`](rules/no-manual-discriminant-construction.md)
- default: `_tag`. Add the fields your unions discriminate on, such as `type` or `kind`.
| Setting | Default | Used by |
| -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `entryFiles`: the files allowed to run Effects and import adapters | `**/main.ts`, `**/cli.ts`, `**/bin/**` | [`run-only-in-runner`](rules/run-only-in-runner.md), [`adapter-import-boundary`](rules/adapter-import-boundary.md) |
| `testFiles`: the test files, exempt from the rules that tests legitimately break | `**/*.test.*`, `**/*.spec.*`, `**/__tests__/**`, `**/test/**`, `**/tests/**` | [`run-only-in-runner`](rules/run-only-in-runner.md), [`adapter-import-boundary`](rules/adapter-import-boundary.md), [`no-effect-promise`](rules/no-effect-promise.md), [`provide-named-layer`](rules/provide-named-layer.md), [`no-provide-on-definition`](rules/no-provide-on-definition.md), [`split-success-path-from-error-handling`](rules/split-success-path-from-error-handling.md), [`all-errors-handled-at-boundary`](rules/all-errors-handled-at-boundary.md), [`anti-slop-no-service-constructor-imports`](rules/anti-slop-no-service-constructor-imports.md), [`no-throw-or-primitive-failure`](rules/no-throw-or-primitive-failure.md), [`single-style-per-function`](rules/single-style-per-function.md), [`prefer-effect-vitest`](rules/prefer-effect-vitest.md) |
| `discriminants`: the fields that discriminate a closed union | `_tag` | [`no-manual-discriminant-comparison`](rules/no-manual-discriminant-comparison.md), [`no-manual-discriminant-construction`](rules/no-manual-discriminant-construction.md) |

The default `entryFiles` leave out `index.ts` on purpose: it is usually a barrel, and exempting it would let adapters reach the rest of the application through re-exports.

Most rules skip `testFiles` entirely. Three use them differently: [`no-throw-or-primitive-failure`](rules/no-throw-or-primitive-failure.md) skips only primitive failures there, [`single-style-per-function`](rules/single-style-per-function.md) treats their helpers like tests, and [`prefer-effect-vitest`](rules/prefer-effect-vitest.md) checks only them. A helper directory such as `src/testing/` does not count as tests: it is support code.

Add to `discriminants` the fields your unions discriminate on, such as `type` or `kind`.

File globs are matched against the path relative to oxlint's working directory, with `/` on every platform.

## Setting a value

Set one only where its default does not fit: it **replaces** the default instead of extending it. An unknown key or a value that is not an array of strings stops the lint with an error, so a typo is never silently ignored.
Set one only where its default does not fit: it **replaces** the default instead of extending it. To extend a default in a TypeScript config, spread the one the package exports: `defaultEntryFiles`, `defaultTestFiles` or `defaultDiscriminants`. A JSON config cannot import them: copy the default from the table above. An unknown key or a value that is not an array of strings stops the lint with an error, so a typo is never silently ignored.

```ts
import { defaultTestFiles } from "@doubleloop-io/oxlint-plugin-effect"
import dlEffectAll from "@doubleloop-io/oxlint-plugin-effect/presets/all"
import { defineConfig } from "oxlint"

export default defineConfig({
extends: [dlEffectAll],
settings: {
"dl-effect": { entryFiles: ["apps/web/src/app/**/route.ts", "apps/web/src/runtime.ts"] },
"dl-effect": {
entryFiles: ["apps/web/src/app/**/route.ts", "apps/web/src/runtime.ts"],
testFiles: [...defaultTestFiles, "e2e/**"],
},
},
})
```
Expand All @@ -47,13 +45,21 @@ export default defineConfig({
{
"extends": ["./node_modules/@doubleloop-io/oxlint-plugin-effect/dist/presets/all.json"],
"settings": {
"dl-effect": { "entryFiles": ["apps/web/src/app/**/route.ts", "apps/web/src/runtime.ts"] }
"dl-effect": {
"entryFiles": ["apps/web/src/app/**/route.ts", "apps/web/src/runtime.ts"],
"testFiles": [
"**/*.test.*",
"**/*.spec.*",
"**/__tests__/**",
"**/test/**",
"**/tests/**",
"e2e/**"
]
}
}
}
```

The package exports the defaults as `defaultEntryFiles`, `defaultTestFiles` and `defaultDiscriminants`: spread them to extend a default (`testFiles: [...defaultTestFiles, "e2e/**"]`).

## Where settings go

Settings belong to the config that lints: oxlint does not inherit them from a preset in `extends`, and rejects them in `overrides`. For a value that differs by group of files, use `overrides` on the rules instead.
Loading