@jandragsbaek/oxlint-plugin 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +113 -2
- package/dist/index.d.mts +3993 -0
- package/dist/index.mjs +3276 -0
- package/dist/presets.d.mts +31 -0
- package/dist/presets.mjs +141 -0
- package/package.json +68 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 T3 Tools Inc.
|
|
4
|
+
Copyright (c) 2026 Jan Dragsbaek
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @jandragsbaek/oxlint-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Oxlint rules and presets, learned in real projects and shared between them. The rules keep
|
|
4
|
+
tests deterministic, Effect code idiomatic, React code honest about its effects, and comments
|
|
5
|
+
and suppressions worth reading.
|
|
6
|
+
|
|
7
|
+
The rules started in [Glose](https://github.com/jandragsbaek/glose) and are adapted from
|
|
8
|
+
[T3 Code](https://github.com/pingdotgg/t3code) under its MIT license.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm add -D @jandragsbaek/oxlint-plugin
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Use
|
|
17
|
+
|
|
18
|
+
Each preset is an Oxlint config object. Put the ones a project needs in `extends`. They load
|
|
19
|
+
the plugin themselves, so `jsPlugins` stays empty.
|
|
20
|
+
|
|
21
|
+
With [Vite+](https://viteplus.dev), in `vite.config.ts`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { effect, react, recommended, tests } from "@jandragsbaek/oxlint-plugin/presets";
|
|
25
|
+
import { defineConfig } from "vite-plus";
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
lint: {
|
|
29
|
+
extends: [recommended, tests, effect, react],
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
With plain Oxlint, in `oxlint.config.ts`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { recommended, tests } from "@jandragsbaek/oxlint-plugin/presets";
|
|
38
|
+
import { defineConfig } from "oxlint";
|
|
39
|
+
|
|
40
|
+
export default defineConfig({ extends: [recommended, tests] });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Later entries override earlier ones, and the project's own `rules` and `overrides` override
|
|
44
|
+
them all.
|
|
45
|
+
|
|
46
|
+
### Presets
|
|
47
|
+
|
|
48
|
+
| Preset | For |
|
|
49
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `recommended` | Any TypeScript project. Built-in rule choices, plus `namespace-node-imports`, `no-low-value-comments`, `no-unscoped-has`, `require-suppression-reason`. |
|
|
51
|
+
| `tests` | Projects with Vitest tests. The rules read the filename and check only test files. |
|
|
52
|
+
| `effect` | Projects on [Effect](https://effect.website). `prefer-effect-fn` is off in test files. |
|
|
53
|
+
| `react` | React projects. Strict hook and render rules, and `no-unreasoned-state-sync`. |
|
|
54
|
+
| `reactCompiler({ files })` | Files the React Compiler compiles. The compiler owns memoization. Use with `react`. |
|
|
55
|
+
| `productCopy({ files })` | Code that holds text users or agents read: no em dashes. |
|
|
56
|
+
| `uiText({ files, message })` | Interface code with i18n catalogs: no inline JSX text. `message` tells the reader where the catalogs are. |
|
|
57
|
+
|
|
58
|
+
The presets that take `files` skip test files. `excludeFiles` skips more. Glose's setup:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
extends: [
|
|
62
|
+
recommended,
|
|
63
|
+
tests,
|
|
64
|
+
effect,
|
|
65
|
+
react,
|
|
66
|
+
reactCompiler({ files: ["apps/web/src/**/*.{ts,tsx}"] }),
|
|
67
|
+
productCopy({ files: ["apps/*/src/**", "packages/*/src/**"] }),
|
|
68
|
+
uiText({
|
|
69
|
+
files: ["apps/web/src/**"],
|
|
70
|
+
message: "Move this text to apps/web/src/i18n and read it with useT().",
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Rules
|
|
76
|
+
|
|
77
|
+
All rules have the `jandragsbaek/` prefix.
|
|
78
|
+
|
|
79
|
+
| Rule | Rejects |
|
|
80
|
+
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
|
|
81
|
+
| `namespace-node-imports` | Node built-ins imported other than as a namespace with the canonical name (`import * as NodeFS from "node:fs"`). |
|
|
82
|
+
| `no-dom-test-environment` | Per-file Vitest environment pragmas and DOM emulator imports (jsdom, happy-dom). |
|
|
83
|
+
| `no-em-dash-copy` | Em dashes in strings and JSX text. |
|
|
84
|
+
| `no-hookless-use-function` | `use*` functions that call no hook; the React Compiler skips them. |
|
|
85
|
+
| `no-inline-schema-compile` | Effect Schema decoders and encoders compiled inside function bodies. |
|
|
86
|
+
| `no-low-value-comments` | Comments that repeat the code, divide sections, or narrate tests. |
|
|
87
|
+
| `no-manual-effect-runtime-in-tests` | Effect runtimes made or run by hand in tests; use `@effect/vitest`. |
|
|
88
|
+
| `no-manual-memo` | `useMemo`, `useCallback` and memo directives where the React Compiler memoizes. |
|
|
89
|
+
| `no-polling-loop-in-tests` | Test loops that spin on ticks until a condition holds. |
|
|
90
|
+
| `no-real-time-wait-in-tests` | Real-clock waits in tests. |
|
|
91
|
+
| `no-test-in-loop` | Tests declared in a `for` loop; use `.each`. |
|
|
92
|
+
| `no-test-timeout-or-unreasoned-skip` | Per-test timeouts and retries, and skipped or focused tests with no tracking issue. |
|
|
93
|
+
| `no-unreasoned-state-sync` | Every React effect hook, until a suppression above it says what it keeps in step. |
|
|
94
|
+
| `no-unscoped-has` | Tailwind `has-[...]` variants not anchored to a class, attribute, id or tag. |
|
|
95
|
+
| `no-untranslated-ui-text` | JSX text and user-facing attributes that are not read from a catalog. |
|
|
96
|
+
| `no-wall-clock-in-tests` | `Date.now()`, `new Date()`, `performance.now()` and `process.hrtime` in tests. |
|
|
97
|
+
| `prefer-catch-tags` | `Effect.catchTag`; use `Effect.catchTags`. |
|
|
98
|
+
| `prefer-effect-fn` | Functions that return `Effect.gen`; use `Effect.fn`. |
|
|
99
|
+
| `require-suppression-reason` | Lint and type-checker suppressions with no reason. |
|
|
100
|
+
|
|
101
|
+
## Add a rule
|
|
102
|
+
|
|
103
|
+
A rule learned in a project goes here, so every project gets it.
|
|
104
|
+
|
|
105
|
+
1. Add `src/rules/<name>.ts` and `src/rules/<name>.test.ts`. The tests run real Oxlint on
|
|
106
|
+
fixture files.
|
|
107
|
+
2. Register the rule in `src/index.ts`, and turn it on in a preset in `src/presets.ts`.
|
|
108
|
+
3. Add it to the table above.
|
|
109
|
+
4. `pnpm check` runs what CI runs: format, lint, typecheck, tests and the package build.
|
|
110
|
+
|
|
111
|
+
## Release
|
|
112
|
+
|
|
113
|
+
Bump `version` in `package.json`, then push a `v<version>` tag. The Release workflow publishes
|
|
114
|
+
to npm with provenance, through npm trusted publishing (no token).
|