@timmo001/oxlint-rules 0.3.6 → 0.5.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 +49 -4
- package/dist/cli.js +462 -55
- package/dist/configs/recommended-effect.js +498 -95
- package/dist/configs/recommended.js +362 -14
- package/dist/effect/index.js +95 -11
- package/dist/generic/index.js +356 -13
- package/package.json +8 -6
- package/src/effect/index.ts +2 -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 +11 -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 +39 -0
- 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
|
@@ -74,12 +74,51 @@ replace an existing destination unless `--force` is passed.
|
|
|
74
74
|
### `anti-slop` and `anti-slop-effect`
|
|
75
75
|
|
|
76
76
|
See the upstream [rule documentation](https://github.com/dmmulroy/anti-slop#rules).
|
|
77
|
+
The recommended configs disable
|
|
78
|
+
`anti-slop/require-safety-comment-for-type-assertion` in favour of
|
|
79
|
+
`timmo/prefer-types-over-assertions`. The upstream rule remains available for
|
|
80
|
+
explicit use.
|
|
81
|
+
|
|
82
|
+
### Oxlint built-in rules
|
|
83
|
+
|
|
84
|
+
The recommended configs also enable `typescript/no-non-null-assertion`,
|
|
85
|
+
`typescript/no-unnecessary-type-arguments`,
|
|
86
|
+
`typescript/no-unnecessary-type-assertion`, and
|
|
87
|
+
`typescript/no-unnecessary-type-parameters`. The last three are type-aware, so
|
|
88
|
+
they only run when the consumer enables `typeAware`.
|
|
77
89
|
|
|
78
90
|
### `timmo`
|
|
79
91
|
|
|
92
|
+
- `no-explicit-inferable-type-predicate`: reports explicit `x is T` predicates on
|
|
93
|
+
non-exported functions whose whole body is a null or `undefined` exclusion, a
|
|
94
|
+
`typeof` comparison, or an `instanceof` check. TypeScript 5.5 and later infer
|
|
95
|
+
those predicates, and an explicit predicate is never checked against the
|
|
96
|
+
body. Methods, exported functions, and `asserts` predicates are left alone.
|
|
97
|
+
- `no-unchecked-query-selector-type`: reports type arguments on
|
|
98
|
+
`querySelector`, `querySelectorAll`, and `closest`, which cast the result
|
|
99
|
+
without checking it. Check the element with `instanceof`, use a checked lookup
|
|
100
|
+
helper, or query a tag name so TypeScript infers the type. Static render-root
|
|
101
|
+
queries in Lit elements are left to `prefer-lit-query-decorators`.
|
|
102
|
+
- `no-untyped-custom-event`: reports `CustomEvent` used as a type without a
|
|
103
|
+
detail type, which leaves `detail` as `any`. Reuse the project's typed event
|
|
104
|
+
helper or add one.
|
|
80
105
|
- `prefer-event-parameter-type`: reports assertions on a handler parameter's
|
|
81
|
-
`target` or `
|
|
82
|
-
instead so every use sees the same
|
|
106
|
+
`target`, `currentTarget`, or `detail` (including nested `detail` members).
|
|
107
|
+
Express the type in the function signature instead so every use sees the same
|
|
108
|
+
contract.
|
|
109
|
+
- `prefer-lit-query-decorators`: follows eslint-plugin-lit's
|
|
110
|
+
[`prefer-query-decorators`](https://github.com/43081j/eslint-plugin-lit/blob/master/docs/rules/prefer-query-decorators.md),
|
|
111
|
+
including its options and `settings.lit.elementBaseClasses`. It also catches
|
|
112
|
+
non-null, optional, and asserted render roots such as
|
|
113
|
+
`this.shadowRoot!.querySelector(...)`, and resolves `this` so nested classes
|
|
114
|
+
and plain functions are not reported. Only static selectors are reported,
|
|
115
|
+
because a query decorator cannot express a selector built at runtime. Turn
|
|
116
|
+
off `lit/prefer-query-decorators` when using this rule.
|
|
117
|
+
- `prefer-types-over-assertions`: reports non-`const` TypeScript assertions,
|
|
118
|
+
even when preceded by a `SAFETY:` comment. Type values where they enter the
|
|
119
|
+
code, for example in function parameters or a checked DOM lookup helper that
|
|
120
|
+
returns `null` when the element is missing or has the wrong type. Assertions
|
|
121
|
+
that `prefer-event-parameter-type` reports are skipped here.
|
|
83
122
|
|
|
84
123
|
### `timmo-effect`
|
|
85
124
|
|
|
@@ -88,6 +127,11 @@ See the upstream [rule documentation](https://github.com/dmmulroy/anti-slop#rule
|
|
|
88
127
|
form. It leaves ordinary async polling, nested callback boundaries,
|
|
89
128
|
non-Effect generators, and `try/finally` cleanup alone. The rule is
|
|
90
129
|
diagnostic-only because catch bodies cannot be rewritten safely in general.
|
|
130
|
+
- `prefer-platform-services`: in modules that import `effect`, `effect/*`, or
|
|
131
|
+
`@effect/*`, reports Node `child_process` and `fs` imports and Bun's `spawn`,
|
|
132
|
+
`spawnSync`, `$`, `file`, and `write`. Use `ChildProcessSpawner` from
|
|
133
|
+
`effect/process` and the `FileSystem` service so cleanup, interruption, typed
|
|
134
|
+
failures, and test layers apply. `fetch` is not reported.
|
|
91
135
|
|
|
92
136
|
## Development
|
|
93
137
|
|
|
@@ -104,8 +148,9 @@ bunx jsr@0.14.3 publish --dry-run --allow-dirty
|
|
|
104
148
|
|
|
105
149
|
`bun run lint` builds the local plugins before linting all maintained code,
|
|
106
150
|
including tests, tooling, the root config and packaged skill scripts. The root
|
|
107
|
-
config extends the local `recommended-effect` source config, enabling
|
|
108
|
-
|
|
151
|
+
config extends the local `recommended-effect` source config, enabling registered
|
|
152
|
+
rules in `anti-slop`, `timmo`, `anti-slop-effect` and `timmo-effect` except for
|
|
153
|
+
the upstream safety-comment requirement described above.
|
|
109
154
|
Plugin imports resolve through this package's exports to the fresh `dist` build.
|
|
110
155
|
|
|
111
156
|
Lint disables nested configs so the vendored submodule's config cannot override
|