@jandragsbaek/oxlint-plugin 0.1.0 → 0.3.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/README.md +60 -33
- package/dist/index.mjs +449 -327
- package/dist/presets.d.mts +3 -15
- package/dist/presets.mjs +15 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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,
|
|
5
|
-
and
|
|
4
|
+
tests deterministic, Effect code idiomatic, React code honest about its effects, files short,
|
|
5
|
+
and code free of comments that explain it.
|
|
6
6
|
|
|
7
7
|
The rules started in [Glose](https://github.com/jandragsbaek/glose) and are adapted from
|
|
8
8
|
[T3 Code](https://github.com/pingdotgg/t3code) under its MIT license.
|
|
@@ -45,17 +45,19 @@ them all.
|
|
|
45
45
|
|
|
46
46
|
### Presets
|
|
47
47
|
|
|
48
|
-
| Preset
|
|
49
|
-
|
|
|
50
|
-
| `recommended`
|
|
51
|
-
| `tests`
|
|
52
|
-
| `effect`
|
|
53
|
-
| `react`
|
|
54
|
-
| `reactCompiler({ files })`
|
|
55
|
-
| `productCopy({ files })`
|
|
56
|
-
| `uiText({ files, message })`
|
|
48
|
+
| Preset | For |
|
|
49
|
+
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `recommended` | Any TypeScript project. Built-in rule choices, plus `max-file-lines`, `max-file-lines-hard`, `namespace-node-imports`, `no-explanatory-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
|
+
| `theming({ files, message })` | Interface code with themes: no color literals (hex, `rgb()`, `oklch()` and the like); colors come from theme tokens. `message` names the tokens. |
|
|
57
58
|
|
|
58
|
-
The presets that take `files` skip test files. `excludeFiles` skips more.
|
|
59
|
+
The presets that take `files` skip test files. `excludeFiles` skips more. Globs in `files` and
|
|
60
|
+
`excludeFiles` are relative to the config file. Glose's setup:
|
|
59
61
|
|
|
60
62
|
```ts
|
|
61
63
|
extends: [
|
|
@@ -76,27 +78,52 @@ extends: [
|
|
|
76
78
|
|
|
77
79
|
All rules have the `jandragsbaek/` prefix.
|
|
78
80
|
|
|
79
|
-
| Rule | Rejects
|
|
80
|
-
| ------------------------------------ |
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `no-
|
|
85
|
-
| `no-
|
|
86
|
-
| `no-
|
|
87
|
-
| `no-
|
|
88
|
-
| `no-
|
|
89
|
-
| `no-
|
|
90
|
-
| `no-
|
|
91
|
-
| `no-
|
|
92
|
-
| `no-
|
|
93
|
-
| `no-
|
|
94
|
-
| `no-
|
|
95
|
-
| `no-
|
|
96
|
-
| `no-
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
81
|
+
| Rule | Rejects |
|
|
82
|
+
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
83
|
+
| `max-file-lines` | Files longer than 500 lines (option `max`). A file that must stay long says why: `/* oxlint-disable jandragsbaek/max-file-lines -- <why> */`. |
|
|
84
|
+
| `max-file-lines-hard` | Files longer than 750 lines (option `max`). No disable directive silences it: split the file. |
|
|
85
|
+
| `namespace-node-imports` | Node built-ins imported other than as a namespace with the canonical name (`import * as NodeFS from "node:fs"`). |
|
|
86
|
+
| `no-dom-test-environment` | Per-file Vitest environment pragmas and DOM emulator imports (jsdom, happy-dom). |
|
|
87
|
+
| `no-em-dash-copy` | Em dashes in strings and JSX text. |
|
|
88
|
+
| `no-explanatory-comments` | Every comment except a license header at the top of the file and tool directives. See [Comments](#comments). |
|
|
89
|
+
| `no-hookless-use-function` | `use*` functions that call no hook; the React Compiler skips them. |
|
|
90
|
+
| `no-inline-schema-compile` | Effect Schema decoders and encoders compiled inside function bodies. |
|
|
91
|
+
| `no-manual-effect-runtime-in-tests` | Effect runtimes made or run by hand in tests; use `@effect/vitest`. |
|
|
92
|
+
| `no-manual-memo` | `useMemo`, `useCallback` and memo directives where the React Compiler memoizes. |
|
|
93
|
+
| `no-polling-loop-in-tests` | Test loops that spin on ticks until a condition holds. |
|
|
94
|
+
| `no-raw-color` | Color literals (hex, `rgb()`, `oklch()` and the like) in code; colors come from theme tokens. |
|
|
95
|
+
| `no-real-time-wait-in-tests` | Real-clock waits in tests. |
|
|
96
|
+
| `no-test-in-loop` | Tests declared in a `for` loop; use `.each`. |
|
|
97
|
+
| `no-test-timeout-or-unreasoned-skip` | Per-test timeouts and retries, and skipped or focused tests with no tracking issue. |
|
|
98
|
+
| `no-unreasoned-state-sync` | Every React effect hook, until a suppression above it says what it keeps in step. |
|
|
99
|
+
| `no-unscoped-has` | Tailwind `has-[...]` variants not anchored to a class, attribute, id or tag. |
|
|
100
|
+
| `no-untranslated-ui-text` | JSX text and user-facing attributes that are not read from a catalog. |
|
|
101
|
+
| `no-wall-clock-in-tests` | `Date.now()`, `new Date()`, `performance.now()` and `process.hrtime` in tests. |
|
|
102
|
+
| `prefer-catch-tags` | `Effect.catchTag`; use `Effect.catchTags`. |
|
|
103
|
+
| `prefer-effect-fn` | Functions that return `Effect.gen`; use `Effect.fn`. |
|
|
104
|
+
| `require-suppression-reason` | Lint and type-checker suppressions with no reason in the directive itself. |
|
|
105
|
+
|
|
106
|
+
### Comments
|
|
107
|
+
|
|
108
|
+
The code explains itself: names, types, small functions and tests carry what a comment would.
|
|
109
|
+
`no-explanatory-comments` allows only:
|
|
110
|
+
|
|
111
|
+
- A license header: a comment block before any code that carries a license or copyright notice
|
|
112
|
+
(`SPDX-License-Identifier`, `Copyright`, `@license`, `/*!`, an MIT or "Licensed under" notice).
|
|
113
|
+
- Tool directives, which a tool reads:
|
|
114
|
+
- lint: `oxlint-disable*`, `oxlint-enable`, `eslint-disable*`, `eslint-enable`, `biome-ignore`
|
|
115
|
+
- type checker: `@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`,
|
|
116
|
+
`/// <reference …>`, `/// <amd-module …>`, `/// <amd-dependency …>`, `@effect-diagnostics`
|
|
117
|
+
- bundler and JSX: `@__PURE__`, `@__NO_SIDE_EFFECTS__` (and their `#__` forms), `@jsx`, `@jsxFrag`,
|
|
118
|
+
`@jsxImportSource`, `@jsxRuntime`, `@vite-ignore`, `webpack*:` and `turbopack*:` magic
|
|
119
|
+
comments, `# sourceMappingURL=`, `# sourceURL=`
|
|
120
|
+
- formatter: `oxfmt-ignore`, `prettier-ignore`, `dprint-ignore`
|
|
121
|
+
- coverage: `v8 ignore`, `c8 ignore`, `istanbul ignore`, `node:coverage`
|
|
122
|
+
- tests and editors: `@vitest-environment`, `@jest-environment`, `@refresh reset`, `cspell:`,
|
|
123
|
+
and `quarantine: #<issue>` above a skipped test (read by `no-test-timeout-or-unreasoned-skip`)
|
|
124
|
+
|
|
125
|
+
Everything else fails: JSDoc, TODOs, section headers and "why" comments. A suppression's reason
|
|
126
|
+
goes in the directive, after `--`.
|
|
100
127
|
|
|
101
128
|
## Add a rule
|
|
102
129
|
|