@timmo001/oxlint-rules 0.4.0 → 0.6.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 +59 -5
- package/dist/cli.js +498 -55
- package/dist/configs/recommended-effect.js +539 -99
- package/dist/configs/recommended.js +336 -16
- package/dist/effect/index.js +162 -13
- package/dist/generic/index.js +331 -15
- package/package.json +12 -9
- package/skills/install-timmo-oxlint-rules/SKILL.md +18 -5
- package/src/effect/index.ts +4 -0
- package/src/effect/rules/no-raw-gh.ts +126 -0
- package/src/effect/rules/no-try-catch-in-effect-generators.ts +4 -98
- package/src/effect/rules/prefer-platform-services.ts +105 -0
- package/src/generic/index.ts +9 -0
- package/src/generic/rules/no-explicit-inferable-type-predicate.ts +146 -0
- package/src/generic/rules/no-unchecked-query-selector-type.ts +48 -0
- package/src/generic/rules/no-untyped-custom-event.ts +31 -0
- package/src/generic/rules/prefer-event-parameter-type.ts +36 -35
- package/src/generic/rules/prefer-lit-query-decorators.ts +84 -0
- package/src/generic/rules/prefer-types-over-assertions.ts +6 -5
- package/src/shared/ast.ts +31 -0
- package/src/shared/effect.ts +72 -0
- package/src/shared/json.ts +11 -0
- package/src/shared/lit.ts +219 -0
- package/src/shared/scope.ts +1 -0
package/README.md
CHANGED
|
@@ -69,6 +69,19 @@ the package configs to merge into the target Oxlint config. Effect settings
|
|
|
69
69
|
remain opt-in. It excludes tests and repository metadata, and refuses to
|
|
70
70
|
replace an existing destination unless `--force` is passed.
|
|
71
71
|
|
|
72
|
+
## Skills
|
|
73
|
+
|
|
74
|
+
[`install-timmo-oxlint-rules`](skills/install-timmo-oxlint-rules/SKILL.md)
|
|
75
|
+
guides agents through installing or copying these rules:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
npx skills add timmo001/oxlint-rules --skill install-timmo-oxlint-rules
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
[`add-oxlint-rule`](skills/add-oxlint-rule/SKILL.md) and
|
|
82
|
+
[`release-oxlint-rules`](skills/release-oxlint-rules/SKILL.md) are for
|
|
83
|
+
maintaining this package.
|
|
84
|
+
|
|
72
85
|
## Rules
|
|
73
86
|
|
|
74
87
|
### `anti-slop` and `anti-slop-effect`
|
|
@@ -79,23 +92,65 @@ The recommended configs disable
|
|
|
79
92
|
`timmo/prefer-types-over-assertions`. The upstream rule remains available for
|
|
80
93
|
explicit use.
|
|
81
94
|
|
|
95
|
+
### Oxlint built-in rules
|
|
96
|
+
|
|
97
|
+
The recommended configs also enable `typescript/no-non-null-assertion`,
|
|
98
|
+
`typescript/no-unnecessary-type-arguments`,
|
|
99
|
+
`typescript/no-unnecessary-type-assertion`, and
|
|
100
|
+
`typescript/no-unnecessary-type-parameters`. The last three are type-aware, so
|
|
101
|
+
they only run when the consumer enables `typeAware`.
|
|
102
|
+
|
|
82
103
|
### `timmo`
|
|
83
104
|
|
|
105
|
+
- `no-explicit-inferable-type-predicate`: reports explicit `x is T` predicates on
|
|
106
|
+
non-exported functions whose whole body is a null or `undefined` exclusion, a
|
|
107
|
+
`typeof` comparison, or an `instanceof` check. TypeScript 5.5 and later infer
|
|
108
|
+
those predicates, and an explicit predicate is never checked against the
|
|
109
|
+
body. Methods, exported functions, and `asserts` predicates are left alone.
|
|
110
|
+
- `no-unchecked-query-selector-type`: reports type arguments on
|
|
111
|
+
`querySelector`, `querySelectorAll`, and `closest`, which cast the result
|
|
112
|
+
without checking it. Check the element with `instanceof`, use a checked lookup
|
|
113
|
+
helper, or query a tag name so TypeScript infers the type. Static render-root
|
|
114
|
+
queries in Lit elements are left to `prefer-lit-query-decorators`.
|
|
115
|
+
- `no-untyped-custom-event`: reports `CustomEvent` used as a type without a
|
|
116
|
+
detail type, which leaves `detail` as `any`. Reuse the project's typed event
|
|
117
|
+
helper or add one.
|
|
84
118
|
- `prefer-event-parameter-type`: reports assertions on a handler parameter's
|
|
85
|
-
`target` or `
|
|
86
|
-
instead so every use sees the same
|
|
119
|
+
`target`, `currentTarget`, or `detail` (including nested `detail` members).
|
|
120
|
+
Express the type in the function signature instead so every use sees the same
|
|
121
|
+
contract.
|
|
122
|
+
- `prefer-lit-query-decorators`: follows eslint-plugin-lit's
|
|
123
|
+
[`prefer-query-decorators`](https://github.com/43081j/eslint-plugin-lit/blob/master/docs/rules/prefer-query-decorators.md),
|
|
124
|
+
including its options and `settings.lit.elementBaseClasses`. It also catches
|
|
125
|
+
non-null, optional, and asserted render roots such as
|
|
126
|
+
`this.shadowRoot!.querySelector(...)`, and resolves `this` so nested classes
|
|
127
|
+
and plain functions are not reported. Only static selectors are reported,
|
|
128
|
+
because a query decorator cannot express a selector built at runtime. Turn
|
|
129
|
+
off `lit/prefer-query-decorators` when using this rule.
|
|
87
130
|
- `prefer-types-over-assertions`: reports non-`const` TypeScript assertions,
|
|
88
131
|
even when preceded by a `SAFETY:` comment. Type values where they enter the
|
|
89
132
|
code, for example in function parameters or a checked DOM lookup helper that
|
|
90
|
-
returns `null` when the element is missing or has the wrong type.
|
|
133
|
+
returns `null` when the element is missing or has the wrong type. Assertions
|
|
134
|
+
that `prefer-event-parameter-type` reports are skipped here.
|
|
91
135
|
|
|
92
136
|
### `timmo-effect`
|
|
93
137
|
|
|
138
|
+
- `no-raw-gh`: reports the raw `execute`, `json` and `stream` methods called on
|
|
139
|
+
a `yield* Gh` binding from `@timmo001/effect-gh`, `Api.raw` from that package,
|
|
140
|
+
and any call whose first argument is `"gh"` or an array starting with `"gh"`,
|
|
141
|
+
such as `executor.run("gh", ...)` or `Bun.spawn(["gh", ...])`. Use the
|
|
142
|
+
package's typed operations, and add one to effect-gh when a command has none.
|
|
143
|
+
effect-gh's own relative imports are not reported.
|
|
94
144
|
- `no-try-catch-in-effect-generators`: diagnoses synchronous `try/catch` owned
|
|
95
145
|
by generators passed directly to `Effect.gen` or the curried `Effect.fn`
|
|
96
146
|
form. It leaves ordinary async polling, nested callback boundaries,
|
|
97
147
|
non-Effect generators, and `try/finally` cleanup alone. The rule is
|
|
98
148
|
diagnostic-only because catch bodies cannot be rewritten safely in general.
|
|
149
|
+
- `prefer-platform-services`: in modules that import `effect`, `effect/*`, or
|
|
150
|
+
`@effect/*`, reports Node `child_process` and `fs` imports and Bun's `spawn`,
|
|
151
|
+
`spawnSync`, `$`, `file`, and `write`. Use `ChildProcessSpawner` from
|
|
152
|
+
`effect/process` and the `FileSystem` service so cleanup, interruption, typed
|
|
153
|
+
failures, and test layers apply. `fetch` is not reported.
|
|
99
154
|
|
|
100
155
|
## Development
|
|
101
156
|
|
|
@@ -103,8 +158,7 @@ Initialise the upstream source and run the package checks:
|
|
|
103
158
|
|
|
104
159
|
```sh
|
|
105
160
|
git submodule update --init --recursive
|
|
106
|
-
mise run check
|
|
107
|
-
mise run build
|
|
161
|
+
mise run check ::: build
|
|
108
162
|
mise run test:package
|
|
109
163
|
npm pack --dry-run
|
|
110
164
|
bunx jsr@0.14.3 publish --dry-run --allow-dirty
|