@timmo001/oxlint-rules 0.4.0 → 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 +39 -3
- package/dist/cli.js +436 -57
- package/dist/configs/recommended-effect.js +472 -97
- package/dist/configs/recommended.js +336 -16
- package/dist/effect/index.js +95 -11
- package/dist/generic/index.js +331 -15
- package/package.json +3 -1
- 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 +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
|
@@ -79,15 +79,46 @@ The recommended configs disable
|
|
|
79
79
|
`timmo/prefer-types-over-assertions`. The upstream rule remains available for
|
|
80
80
|
explicit use.
|
|
81
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`.
|
|
89
|
+
|
|
82
90
|
### `timmo`
|
|
83
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.
|
|
84
105
|
- `prefer-event-parameter-type`: reports assertions on a handler parameter's
|
|
85
|
-
`target` or `
|
|
86
|
-
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.
|
|
87
117
|
- `prefer-types-over-assertions`: reports non-`const` TypeScript assertions,
|
|
88
118
|
even when preceded by a `SAFETY:` comment. Type values where they enter the
|
|
89
119
|
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.
|
|
120
|
+
returns `null` when the element is missing or has the wrong type. Assertions
|
|
121
|
+
that `prefer-event-parameter-type` reports are skipped here.
|
|
91
122
|
|
|
92
123
|
### `timmo-effect`
|
|
93
124
|
|
|
@@ -96,6 +127,11 @@ explicit use.
|
|
|
96
127
|
form. It leaves ordinary async polling, nested callback boundaries,
|
|
97
128
|
non-Effect generators, and `try/finally` cleanup alone. The rule is
|
|
98
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.
|
|
99
135
|
|
|
100
136
|
## Development
|
|
101
137
|
|