@ls-stack/fast-lint 0.6.0 → 0.7.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
@@ -467,6 +467,19 @@ Comments starting with `INFO:`, `TODO:`, `DOCS:`, `FIX:`, `FIXME:`, `HACK:`, `NO
467
467
  `ISSUE:`, `TEMP:`, `TEMPORARY:`, `XXX:`, `REVIEW:`, `eslint`, `cspell:` or `spell-checker:` are allowed. The rule is
468
468
  heuristic: it can miss commented code.
469
469
 
470
+ Explanation comments required by other rules (`require-type-guard-explanation`'s `type-guard-safety:` by default) are
471
+ prose, so a line comment starting with one of `explanationPrefixes`, plus the `//` lines right below it, is never
472
+ reported.
473
+
474
+ ```ts
475
+ type Options = [
476
+ {
477
+ /** Prefixes of explanation comment blocks to skip (default: `['type-guard-safety:']`; replaces the default) */
478
+ explanationPrefixes?: string[]
479
+ },
480
+ ]
481
+ ```
482
+
470
483
  ### `react-single-export`
471
484
 
472
485
  In React component files (by default `*.tsx`), a file that exports a component (a PascalCase function, arrow,
@@ -810,11 +823,13 @@ safe and why TS inference or an alternative can't be used.
810
823
  - the comment goes right before the function or before the statement, `export`, class member or object property
811
824
  holding it; consecutive `//` lines form one block, and block/JSDoc comments count too
812
825
  - an explicit predicate TypeScript (5.5+) would infer identically is reported even with a comment, with a suggestion
813
- to remove the annotation (`inferablePredicate`); only null/undefined and `typeof` checks it is sure about are
814
- reported
826
+ to remove the annotation (`inferablePredicate`); it is conservative and only reports `===`/`!==` checks against
827
+ `null`, `undefined` and string/number literals, `typeof` checks and `instanceof` (non-generic classes), combined with
828
+ `||`/`&&`, that it is sure TypeScript infers identically
815
829
  - body-less signatures (overloads, `declare function`, interface members, function types) and `asserts x` are ignored
816
- - `alternativeMsgs` appends a project-specific hint to the message of guards passed directly to `.find()` or
817
- `.filter()`, e.g. pointing to a `filterAndMap` helper
830
+ - `alternativeMsgs` appends a project-specific hint to the `missingExplanation` message, e.g. pointing to a schema
831
+ validator or a `filterAndMap` helper; the most specific one wins: `inArrayFind`/`inArrayFilter` for guards passed
832
+ directly to `.find()`/`.filter()`, then `unknownInput` for guards narrowing an `unknown` parameter, then `default`
818
833
 
819
834
  ```ts
820
835
  // Error: missingExplanation
@@ -842,9 +857,15 @@ type Options = [
842
857
  commentPrefix?: string
843
858
  /** Minimum characters of explanation after the prefix (default: 20) */
844
859
  minLength?: number
845
- /** Extra hints appended to the message of guards passed directly to `.find()`/`.filter()` */
860
+ /** Extra hints appended to the `missingExplanation` message, the most specific one wins */
846
861
  alternativeMsgs?: {
862
+ /** Every guard */
863
+ default?: string
864
+ /** Guards narrowing an `unknown` parameter (falls back to `default`) */
865
+ unknownInput?: string
866
+ /** Guards passed directly to `.find()` */
847
867
  inArrayFind?: string
868
+ /** Guards passed directly to `.filter()` */
848
869
  inArrayFilter?: string
849
870
  }
850
871
  },
Binary file
Binary file
Binary file
Binary file
Binary file
package/lib/index.d.ts CHANGED
@@ -217,10 +217,16 @@ export type NoRestrictedCommentsOptions = {
217
217
  }[]
218
218
  }
219
219
 
220
+ export type NoCommentedOutCodeOptions = {
221
+ explanationPrefixes?: string[]
222
+ }
223
+
220
224
  export type RequireTypeGuardExplanationOptions = {
221
225
  commentPrefix?: string
222
226
  minLength?: number
223
227
  alternativeMsgs?: {
228
+ default?: string
229
+ unknownInput?: string
224
230
  inArrayFind?: string
225
231
  inArrayFilter?: string
226
232
  }
@@ -261,7 +267,7 @@ type RuleOptions = {
261
267
  'no-unnecessary-iife': Record<string, never>
262
268
  'require-description': RequireDescriptionOptions
263
269
  'no-write-only-ref': Record<string, never>
264
- 'no-commented-out-code': Record<string, never>
270
+ 'no-commented-out-code': NoCommentedOutCodeOptions
265
271
  'react-single-export': ReactSingleExportOptions
266
272
  'no-unused-optional-args': NoUnusedOptionalArgsOptions
267
273
  'no-unused-type-props-in-args': NoUnusedTypePropsInArgsOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ls-stack/fast-lint",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "description": "Fast type-aware lint rules for TypeScript and React, running natively on tsrs, the Rust port of the TypeScript checker",
6
6
  "type": "module",