@neralabs/rerail-pack-typescript 0.1.1 → 0.1.3

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.
Files changed (27) hide show
  1. package/README.md +179 -2
  2. package/licenses/eslint-plugin-vitest/UPSTREAM.md +7 -0
  3. package/licenses/typescript-eslint/UPSTREAM.md +1277 -1
  4. package/pack.json +7 -10
  5. package/package.json +1 -1
  6. package/rules/typescript-eslint-ban-tslint-comment.json +7 -4
  7. package/rules/typescript-eslint-consistent-type-definitions.json +1 -1
  8. package/rules/typescript-eslint-default-param-last.json +3 -3
  9. package/rules/typescript-eslint-no-array-constructor.json +6 -3
  10. package/rules/typescript-eslint-no-confusing-non-null-assertion.json +9 -6
  11. package/rules/typescript-eslint-no-dupe-class-members.json +1 -1
  12. package/rules/typescript-eslint-no-duplicate-enum-values.json +3 -7
  13. package/rules/typescript-eslint-no-empty-function.json +1 -1
  14. package/rules/typescript-eslint-no-extra-non-null-assertion.json +6 -3
  15. package/rules/typescript-eslint-no-import-type-side-effects.json +9 -6
  16. package/rules/typescript-eslint-no-namespace.json +3 -7
  17. package/rules/typescript-eslint-no-non-null-asserted-optional-chain.json +6 -3
  18. package/rules/typescript-eslint-no-non-null-assertion.json +5 -9
  19. package/rules/typescript-eslint-no-unnecessary-type-constraint.json +6 -3
  20. package/rules/typescript-eslint-no-unsafe-function-type.json +3 -7
  21. package/rules/typescript-eslint-no-unused-expressions.json +1 -1
  22. package/rules/typescript-eslint-no-useless-empty-export.json +3 -3
  23. package/rules/typescript-eslint-prefer-as-const.json +3 -7
  24. package/rules/typescript-eslint-prefer-enum-initializers.json +3 -3
  25. package/rules/typescript-eslint-prefer-literal-enum-member.json +1 -1
  26. package/rules/typescript-eslint-prefer-namespace-keyword.json +6 -3
  27. package/rules/typescript-eslint-no-wrapper-object-types.json +0 -628
package/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # Rerail rule pack: TypeScript
2
2
 
3
- 22 code rules for TypeScript, ported from typescript-eslint 8.70.1 (on ESLint 10.11.0), each with its default
3
+ 21 code rules for TypeScript, ported from typescript-eslint 8.70.1 (on ESLint 10.11.0), each with its default
4
4
  options. 11 start off (`"on": false`): no approved typescript-eslint configuration turns them on, so they are
5
5
  experimental. Each is scored against the tool's own findings on the tool's test fixtures and on a pinned corpus
6
6
  (vscode), through the engine's production workspace path, with every disagreement declared in `divergences.json`
7
7
  (none today). ESLint's core rules are in the [JavaScript pack](../javascript/README.md).
8
8
 
9
+ Every typescript-eslint rule runs on `.ts`, `.tsx`, `.mts` and `.cts` files only, and the vscode corpus is scored on
10
+ its TypeScript files only (`exclude` in `conformance.json`). On JavaScript a port steers CommonJS files away from
11
+ `require` (`no-require-imports` on `jest.config.js`), and with both packs added a port with an ESLint core twin would
12
+ report the same violation as the twin, which runs on JavaScript files only.
13
+
9
14
  It is checked by `npx vitest run test/engine/catalog/packs.test.ts -t "pack typescript"`, against the
10
15
  [pack structure and validation contract](../../docs/pack-format.md).
11
16
 
@@ -17,7 +22,7 @@ It is checked by `npx vitest run test/engine/catalog/packs.test.ts -t "pack type
17
22
  | `divergences.json` | Declared disagreements with the tools |
18
23
  | `upstream/<tool>/` | The tool's copied tests (`fixtures/`) and its recordings (`fixtures.expected.json`, `corpus-vscode.expected.json`); `upstream/eslint-plugin-vitest/UPSTREAM.md` lists the fixtures Rerail wrote (`fixtures/*/rerail-*`), which the recorder holds and records like the copied ones |
19
24
  | `upstream/generate.mjs` | typescript-eslint's recorder; `upstream/eslint-plugin-vitest/generate.mjs` records @vitest/eslint-plugin |
20
- | `candidates/rules/` | Ports still being evaluated, never shipped: typescript-eslint and @vitest/eslint-plugin 1.6.27 ports that fail a V1 validation gate or rerail's pack contract. Each but `prefer-optional-chain` (it requires type information, which the recordings do not have) and `no-explicit-any` (the fixtures recording does not cover it yet) is listed in `conformance.json`, scored and reported on the fixtures, never gated; the vscode recording covers the shipped rules only. The three `vitest-*.json` documents are generated: edit `scripts/generate/packs/typescript-vitest-policies.mjs`, not the JSON, and run `node scripts/generate/packs/typescript-vitest-policies.mjs` from the repository root |
25
+ | `candidates/rules/` | Ports still being evaluated, never shipped: typescript-eslint and @vitest/eslint-plugin 1.6.27 ports that fail a rule gate ([docs/port-readiness.md](../../docs/port-readiness.md)) or rerail's pack contract. Each but `prefer-optional-chain` (it requires type information, which the recordings do not have) and `no-explicit-any` (the fixtures recording does not cover it yet) is listed in `conformance.json`, scored and reported on the fixtures, never gated; the vscode recording covers the shipped rules only. The three `vitest-*.json` documents are generated: edit `scripts/generate/packs/typescript-vitest-policies.mjs`, not the JSON, and run `node scripts/generate/packs/typescript-vitest-policies.mjs` from the repository root |
21
26
  | `licenses/<tool>/` | The tool's licence and `UPSTREAM.md`, listing every copied file |
22
27
 
23
28
  Re-recording runs offline against the pinned tool versions (the recorder's header lists them):
@@ -33,3 +38,175 @@ Scoring one rule with every false positive and false negative printed:
33
38
  ```sh
34
39
  node --import tsx conformance/languages/cli.ts --pack typescript --rule typescript-eslint-no-namespace --fixtures
35
40
  ```
41
+
42
+ ## Rule details
43
+
44
+ What each rule matches beyond its one-line description: exact matching, edge cases, upstream settings and known divergences.
45
+
46
+ ### `typescript-eslint-adjacent-overload-signatures`
47
+
48
+ Reports a function, method, call or construct signature whose name was already declared earlier in the same body when the member just before it is not an overload of the same name. Method names are compared as typescript-eslint's getNameFromMember does: literal and identifier keys by static name, a computed identifier by its name, and other computed keys by their source text.
49
+
50
+ ### `typescript-eslint-ban-ts-comment`
51
+
52
+ Matches TypeScript's directive regexes on comment text (block comments: last line only); description length counts approximate grapheme clusters. Defaults as upstream: @ts-expect-error allowed with a description of at least 3 characters, @ts-ignore and @ts-nocheck banned, @ts-check allowed.
53
+
54
+ ### `typescript-eslint-ban-tslint-comment`
55
+
56
+ Flags comments whose value matches TSLint's enable/disable directive regex; the fix deletes the comment.
57
+
58
+ ### `typescript-eslint-class-literal-property-style`
59
+
60
+ Default option `fields`. Flags getters (not `override`) whose first statement returns a literal, unless the class body has a setter of the same member name (typescript-eslint's getStaticMemberAccessValue: computed keys folded, constant bindings followed, `#a` same as `a`). A getter whose computed name has no static value is reported; a setter with none never pairs. The message tells the agent to check for subclasses that override the getter as an accessor, which a field would break (TS2611); the rule cannot see other classes, so it reports these getters as upstream does (NER-1785).
61
+
62
+ ### `typescript-eslint-class-methods-use-this`
63
+
64
+ Flags a non-static, non-constructor class method, or a class field initialized with a function or arrow, whose own body never uses `this` or `super`. Nested functions, static blocks and nested class field initializers have their own `this`; arrows share it. Default options.
65
+
66
+ ### `typescript-eslint-consistent-generic-constructors`
67
+
68
+ Covers variable declarators, class fields and parameter defaults initialized with `new Name(...)`, default mode `constructor`; typed-array built-ins are excepted. The fix rebuilds the declaration from its parts, so whitespace and comments inside it are not kept, and a declaration with modifiers is not fixed. typescript-eslint skips the constructor-mode report when the `isolatedDeclarations` parser option is set; Rerail has no such fact, so the port reports it and its message says to keep the annotation under isolatedDeclarations (TS9010, NER-1786).
69
+
70
+ ### `typescript-eslint-consistent-type-definitions`
71
+
72
+ Default option `interface`: flags type aliases whose type is an object literal type (through any parentheses) and fixes them to interfaces.
73
+
74
+ ### `typescript-eslint-default-param-last`
75
+
76
+ Identical to the ESLint base port. Only functions with a body; a trailing rest parameter does not count as required.
77
+
78
+ ### `typescript-eslint-explicit-function-return-type`
79
+
80
+ Allowances with defaults: typed function expressions, higher-order functions and direct const assertions in arrows on; expressions, IIFEs, void-started concise arrows, functions without type parameters and allowed names off. Reports at the function head.
81
+
82
+ ### `typescript-eslint-explicit-member-accessibility`
83
+
84
+ Reports from the first token after a member's decorators.
85
+
86
+ ### `typescript-eslint-max-params`
87
+
88
+ Extends ESLint's max-params; default max 3, countThis `except-void`. Counts parameters of functions, methods, arrows, declared functions and function types; the message names the function as getFunctionNameWithKind does.
89
+
90
+ ### `typescript-eslint-member-ordering`
91
+
92
+ Default options only: a member is flagged when an earlier member of the same body belongs to a group ranked later in typescript-eslint's default member-type order.
93
+
94
+ ### `typescript-eslint-method-signature-style`
95
+
96
+ Default option `property`. Fixes to a function property except inside a module declaration, when the return type mentions `this`, or when the key is overloaded (typescript-eslint's merged-overload fix is not reproduced).
97
+
98
+ ### `typescript-eslint-no-array-constructor`
99
+
100
+ Exempt: exactly one argument, or type arguments. No scope check (typescript-eslint does not resolve `Array` either). Calls with comments inside the argument list get no fix.
101
+
102
+ ### `typescript-eslint-no-dupe-class-members`
103
+
104
+ ESLint's base rule over non-computed members only, ignoring overload signatures; compares static names within the same staticness; a getter may pair with a setter.
105
+
106
+ ### `typescript-eslint-no-duplicate-enum-values`
107
+
108
+ Initializers considered: string, number or static template literal under any chain of unary + and -; compared by Object.is; NaN and other initializers ignored. Default options (typescript-eslint 8.70.1).
109
+
110
+ ### `typescript-eslint-no-dynamic-delete`
111
+
112
+ String, number and negated number literal keys are allowed.
113
+
114
+ ### `typescript-eslint-no-empty-function`
115
+
116
+ A body with a comment is not empty; constructors with parameter properties are exempt. Default options (allow: []).
117
+
118
+ ### `typescript-eslint-no-extra-non-null-assertion`
119
+
120
+ Parentheses are transparent, as in ESTree.
121
+
122
+ ### `typescript-eslint-no-extraneous-class`
123
+
124
+ Only classes without `extends`; a constructor with parameter properties does not count as constructor-only.
125
+
126
+ ### `typescript-eslint-no-inferrable-types`
127
+
128
+ Types covered: bigint, boolean, number, null, string, symbol, RegExp, undefined. The fix removes the annotation.
129
+
130
+ ### `typescript-eslint-no-invalid-this`
131
+
132
+ Standalone port (extends ESLint's no-invalid-this). Flags `this` whose nearest non-arrow function scope is the module top level or a function ESLint's isDefaultThisBinding treats as called without a receiver. Strictness and the global `this` come from the case's language options: a script's top level and a non-strict function's `this` are valid.
133
+
134
+ ### `typescript-eslint-no-invalid-void-type`
135
+
136
+ Port of typescript-eslint `no-invalid-void-type`. void is allowed as a return type (and as the annotation of non-identifier bindings, mirroring the rule's grandparent test); in a union whose members are all void, never, or generics with a void argument; in a union inside a function or method implementation that has overload signatures of the same name (an anonymous `export default function` has them when the module has an `export default function` signature; method names compared like getStaticMemberAccessValue, two names without a static value treated as equal); and, with allowInGenericTypeArguments (default true), as a generic type argument outside a call or as a type parameter default.
137
+
138
+ ### `typescript-eslint-no-misused-new`
139
+
140
+ Reports a bodiless class method named `new` returning its own class, an interface construct signature returning its own interface, and a `constructor` method signature in an interface or type literal.
141
+
142
+ ### `typescript-eslint-no-namespace`
143
+
144
+ typescript-eslint 8.70.1, default options. allowDefinitionFiles is fixed at its default (true): files matched by isDefinitionFile (`\.d\.(ts|cts|mts|.*\.ts)$`) are not checked. Not flagged: `declare global`, `global {}` inside `declare module 'name'`, and `declare module 'name'`. Declared namespaces are flagged (allowDeclarations default false).
145
+
146
+ ### `typescript-eslint-no-non-null-assertion`
147
+
148
+ typescript-eslint 8.70.1, default options. Where tree-sitter misparses a prefix operator applied to an assertion (`!x!` as `(!x)!`), the finding starts at the real operand.
149
+
150
+ ### `typescript-eslint-no-non-null-asserted-optional-chain`
151
+
152
+ A parenthesized optional chain that is non-null asserted (`(x?.y)!`) is reported at the chain.
153
+
154
+ ### `typescript-eslint-no-redeclare`
155
+
156
+ Flags each definition after the first in the same scope; with builtinGlobals, definitions of a configured or `/* global */`-declared global.
157
+
158
+ ### `typescript-eslint-no-require-imports`
159
+
160
+ `require(...)` is not flagged when a declaration of `require` is in scope. Default options: allow [], allowAsImport false.
161
+
162
+ ### `typescript-eslint-no-unsafe-function-type`
163
+
164
+ typescript-eslint 8.70.1, default options. Flags `Function` as a type reference, in class implements, or interface extends, only when the name resolves to no file-local type binding.
165
+
166
+ ### `typescript-eslint-no-unused-expressions`
167
+
168
+ Unwraps parentheses and TS `as` / `<T>` / `!` / instantiation wrappers; allowed: call, new, assignment, update, await, yield, import(), void, delete; directive prologue strings exempt. tree-sitter reads `e as A.B.C` and `e satisfies A.B.C` (type name with two or more dots) as a member access on `e as A.B` / `e satisfies A.B`; such a member access is treated as the `as` (unwrapped) or `satisfies` (never flagged, as upstream).
169
+
170
+ ### `typescript-eslint-no-unused-vars`
171
+
172
+ Reported where ESLint reports (last write from the variable's own function, else its first definition). Usedness, exports, `/* exported */` comments and report anchors come from the engine's per-variable references (`binds`, `resolves.write: "last"`); options filter on them. An unused `/* global */` name with no declaration is reported at the name in the first comment that declares it (M12a eslintDirective parse; first three names of a comment).
173
+
174
+ ### `typescript-eslint-no-useless-constructor`
175
+
176
+ Exempt: private/protected constructors, `public` constructors in derived classes, parameter properties and decorated parameters. Flags an empty-body constructor in a class without extends, or one whose body is only `super(...)` passing parameters through unchanged (ESLint isPassingThrough for any number of simple parameters: positional name match, spread of a rest parameter, or one spread of `arguments`).
177
+
178
+ ### `typescript-eslint-no-wrapper-object-types`
179
+
180
+ typescript-eslint 8.70.1, default options. Flags BigInt/Boolean/Number/Object/String/Symbol in type references, implements and interface extends only when the name resolves to no file-local type binding. Type references are auto-fixed to the lowercase primitive.
181
+
182
+ ### `typescript-eslint-parameter-properties`
183
+
184
+ Default options, `class-property` mode: flags constructor parameter properties whose modifiers are not in the (empty) allow list.
185
+
186
+ ### `typescript-eslint-prefer-as-const`
187
+
188
+ typescript-eslint 8.70.1, default options. Flags a literal type that repeats the raw text of the literal it asserts (`x as 'a'`, `<'a'>x`) or annotates (`let v: 'a' = 'a'`, class fields); assertions are auto-fixed to `const`.
189
+
190
+ ### `typescript-eslint-prefer-function-type`
191
+
192
+ Applies to a type literal, or an interface with no supertype other than Function, whose only member is a call or construct signature with a return type; in such an interface the first `this` type (outside nested literals) is reported instead. Fixes cover call signatures without comments; checks are split by fix shape.
193
+
194
+ ### `typescript-eslint-prefer-literal-enum-member`
195
+
196
+ Allowed initializers: a literal, a template literal without substitutions, or a signed literal; allowBitwiseExpressions option additionally allows bitwise expressions.
197
+
198
+ ### `typescript-eslint-prefer-namespace-keyword`
199
+
200
+ Only `module Name {}` with an identifier name; reports the whole declaration (from `declare` when present) and fixes the keyword.
201
+
202
+ ### `typescript-eslint-unified-signatures`
203
+
204
+ Compares each overload with every earlier overload of the same name in the same container, pairing parameters by position for any number of parameters, requiring equal return types and type parameters. Not ported: the outer type-parameter usage test and message line numbers. With three or more overloads of a name, the message names the line of the other overload ESLint picks (M12a `line` transform).
205
+
206
+ ### `vitest-no-disabled-tests`
207
+
208
+ Disabled forms: `.skip`, `xit`, `xtest`, `xdescribe`, a test with no function, `pending()`.
209
+
210
+ ### `typescript-eslint-no-explicit-any`
211
+
212
+ Port of typescript-eslint's `no-explicit-any` rule (https://typescript-eslint.io/rules/no-explicit-any). Flags every `any` type (default options: no fix; the rule only suggests). Options (`ignoreRestArgs`, `fixToUnknown`) are declared in the `options` define with the rule's defaults; a variant is a config patch.
@@ -101,3 +101,10 @@ Paths are relative to the pack directory, `packs/typescript/`.
101
101
  | `upstream/eslint-plugin-vitest/fixtures/no-focused-tests/018.test.ts` | `tests/no-focused-tests.test.ts` | derived |
102
102
  | `upstream/eslint-plugin-vitest/fixtures/no-focused-tests/019.test.ts` | `tests/no-focused-tests.test.ts` | derived |
103
103
  | `upstream/eslint-plugin-vitest/fixtures/no-focused-tests/020.test.ts` | `tests/no-focused-tests.test.ts` | derived |
104
+
105
+ > `recording.json` is a port readiness recording, and no file of this pack, so it is recorded here rather than in the
106
+ > table above: the tool-pack's `recording.lock` names it and a GitHub release holds the bytes (docs/port-readiness.md).
107
+ > It carries excerpts of this upstream's tests (`tests/*.test.ts`: the `code` of each RuleTester case), redistributed
108
+ > under the licence above, together with Rerail's Apache-2.0; the LICENSE beside this file is this upstream's own, at
109
+ > the pinned commit.
110
+