@ls-stack/extended-lint 0.91.0 → 1.0.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 CHANGED
@@ -17,6 +17,11 @@ And then configure it in your eslint config:
17
17
  }
18
18
  ```
19
19
 
20
+ The type-aware rules `improved-no-unnecessary-condition`, `strict-casting` and `no-unnecessary-void-on-promise` were
21
+ removed from this plugin and now live only in [`@ls-stack/fast-lint`](../fast-lint), as does the deprecated
22
+ `no-unnecessary-casting` (replaced by fast-lint's `strict-casting`). The `rules-of-hooks` and
23
+ `exhaustive-deps` forks were also removed; use `eslint-plugin-react-hooks` instead.
24
+
20
25
  ## `no-unused-type-props-in-args`
21
26
 
22
27
  Checks if there are unused type props in function arguments.
@@ -132,60 +137,3 @@ function foo<T>(arg: T) {
132
137
  foo<string>('bar') // OK
133
138
  ```
134
139
 
135
- ## `rules-of-hooks`
136
-
137
- A fork of the `eslint-plugin-react-hooks` `rules-of-hooks` rule, but with the following changes:
138
-
139
- - Identifies hooks in camelCase namespaced functions (e.g. `test.useFoo()`)
140
-
141
- ## `strict-casting`
142
-
143
- Enforces safe and necessary `String()`/`Number()` casts. Replaces the deprecated `no-unnecessary-casting` rule.
144
-
145
- Checks performed:
146
-
147
- - **Unnecessary casts** (auto-fixable): casting a value that is already of the target type
148
- - **Nullish casts**: `String(value)` produces the strings `"null"`/`"undefined"`, and `Number(value)` produces `0` for `null` and `NaN` for `undefined`. A suggestion is provided to add a `?? ''`/`?? 0` fallback
149
- - **Invalid `Number()` casts**: casting a `symbol` (throws at runtime) or an object without a numeric `valueOf` (always results in `NaN`)
150
- - **`any`/`unknown` casts**: casting untyped values is unsafe, type or narrow the value before casting
151
-
152
- Bad:
153
-
154
- ```ts
155
- declare const str: string
156
- declare const nullable: string | null
157
- declare const obj: { a: string }
158
-
159
- String(str) // Error: unnecessary cast
160
- String(nullable) // Error: may produce "null"
161
- Number(obj) // Error: results in NaN
162
- ```
163
-
164
- Good:
165
-
166
- ```ts
167
- String(num)
168
- String(nullable ?? '')
169
- Number(date) // Date has a numeric valueOf
170
- ```
171
-
172
- Options:
173
-
174
- ```ts
175
- type Options = [
176
- {
177
- /** Extra functions checked for unnecessary casts */
178
- additionalCastFunctions?: { name: string; expectedType: 'string' | 'number' }[]
179
- /** Allow casting possibly nullish values (default: false) */
180
- allowNullishCasting?: boolean
181
- /** Allow symbol/object Number() casts (default: false) */
182
- allowInvalidCasting?: boolean
183
- /** Allow casting `any` values (default: false) */
184
- allowAnyCasting?: boolean
185
- /** Allow casting `unknown` values, e.g. `String(err)` in catch blocks (default: false) */
186
- allowUnknownCasting?: boolean
187
- },
188
- ]
189
- ```
190
-
191
- For `String(obj)` producing `"[object Object]"`, use `@typescript-eslint/no-base-to-string`, which covers that case well.