@neralabs/rerail-pack-react 0.1.3 → 0.1.5
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
|
@@ -29,13 +29,16 @@ The pack follows the [pack structure and validation contract](../../docs/pack-fo
|
|
|
29
29
|
| `licenses/<project>/` | The upstream licence and `UPSTREAM.md`, listing every copied file and extracted case |
|
|
30
30
|
| `candidates/` | Ports still being evaluated, scored but never shipped: the code-rule documents (`rules/`, written by `build.mjs` from `specs.mjs`, except the hand-written `react-no-array-index-key.json`); `probes/` holds the hand-labelled React fact probes |
|
|
31
31
|
|
|
32
|
-
Re-recording
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
Re-recording is a maintainer deriving the pack's test data from its pins and archiving it
|
|
33
|
+
([CONTRIBUTING.md](../../CONTRIBUTING.md#pack-test-data)); it is never committed. The recipe
|
|
34
|
+
(`scripts/pack-data/recipes/react.ts`) runs each plugin's `generate.mjs` against the pinned tools (eslint 9.39.5,
|
|
35
|
+
@typescript-eslint/parser 8.70.1, typescript 5.9.3), the plugins' upstream checkouts and the corpus. The fixtures
|
|
36
|
+
Rerail wrote (`UPSTREAM.md`) are authored: a change to them goes in your pull request with `git add -f`.
|
|
35
37
|
|
|
36
38
|
```sh
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
npm run fixtures:derive -- --pack react # both plugins
|
|
40
|
+
npm run fixtures:derive -- --pack react --tool eslint-plugin-react-hooks # one
|
|
41
|
+
npm run fixtures:push -- --pack react --tool eslint-plugin-react-hooks # on your own branch: archive it and rewrite its test-data.lock
|
|
39
42
|
```
|
|
40
43
|
|
|
41
44
|
Rewriting the rule documents and `conformance.json` after editing `candidates/specs.mjs`, then scoring one rule with
|
|
@@ -45,3 +48,87 @@ every false positive and false negative printed:
|
|
|
45
48
|
node candidates/build.mjs
|
|
46
49
|
node --import tsx conformance/languages/cli.ts --pack react --rule react-jsx-key --fixtures
|
|
47
50
|
```
|
|
51
|
+
|
|
52
|
+
## Rule details
|
|
53
|
+
|
|
54
|
+
What each rule matches beyond its one-line description: exact matching, edge cases, upstream settings and known divergences.
|
|
55
|
+
|
|
56
|
+
### `react-button-has-type`
|
|
57
|
+
|
|
58
|
+
Port of eslint-plugin-react 7.37.5 react/button-has-type with button, submit and reset allowed. Reports a `<button>` with no `type` attribute (looked up case-insensitively, as jsx-ast-utils getProp does) or whose first `type` value is not a literal button/submit/reset. Each leaf of a conditional `type` is checked, and a non-literal leaf is reported at itself. The same applies to `React.createElement('button', props)` with the default pragma.
|
|
59
|
+
|
|
60
|
+
### `react-hooks-exhaustive-deps`
|
|
61
|
+
|
|
62
|
+
Port of eslint-plugin-react-hooks 7.1.1 react-hooks/exhaustive-deps, missing-dependency report only (no unnecessary/duplicate-dependency reports). Checks the dependency array literal of useEffect, useLayoutEffect, useInsertionEffect, useCallback and useMemo (bare or as `React.*`) when the inline callback reads a name bound in the calling function (outside the callback) that no dependency's root names. useState/useReducer setters and dispatchers, useRef, useEffectEvent and useTransition results count as stable and need not be listed.
|
|
63
|
+
|
|
64
|
+
### `react-hooks-rules-of-hooks`
|
|
65
|
+
|
|
66
|
+
Port of eslint-plugin-react-hooks 7.1.1 react-hooks/rules-of-hooks. A hook call (`use`, `useX`, `Namespace.useX`) is reported at its callee when it runs, in a component or hook (a function named `X…`/`useX`, or the callback of memo/forwardRef), conditionally (if/conditional/logical/switch/catch/default branch, or after an earlier return); in a class method or field; in another named function; at the top level; in an anonymous callback inside a component or hook; in a loop; in an async component or hook; and `use` inside try/catch. ESLint's code-path analysis is approximated syntactically.
|
|
67
|
+
|
|
68
|
+
### `react-jsx-key`
|
|
69
|
+
|
|
70
|
+
Port of eslint-plugin-react 7.37.5 react/jsx-key, default options. Reports an element (not a fragment) without `key` that is an array literal's element, or that a `.map(fn)` / `.from(x, fn)` callback returns: the arrow's body, a branch of its conditional body, the right side of its logical body, or a return statement directly in the callback body or in nested if/else branches. Never reported inside `React.Children.toArray(...)` / `Children.toArray(...)`.
|
|
71
|
+
|
|
72
|
+
### `react-jsx-no-comment-textnodes`
|
|
73
|
+
|
|
74
|
+
Port of eslint-plugin-react 7.37.5 react/jsx-no-comment-textnodes: JSX text with a line that starts (after whitespace) with `//` or `/*`.
|
|
75
|
+
|
|
76
|
+
### `react-jsx-no-duplicate-props`
|
|
77
|
+
|
|
78
|
+
Port of eslint-plugin-react 7.37.5 react/jsx-no-duplicate-props, case-sensitive. Namespaced attribute names and spreads are skipped.
|
|
79
|
+
|
|
80
|
+
### `react-jsx-no-target-blank`
|
|
81
|
+
|
|
82
|
+
Port of eslint-plugin-react 7.37.5 react/jsx-no-target-blank with default options (links only, enforceDynamicLinks always, allowReferrer false). Reports an `<a>` whose last `target` is possibly `_blank` (a string, or a conditional with a `_blank` branch), with an external last `href` string (`scheme:` or `//`) or any `href` expression, and whose last `rel` does not give `noreferrer` on every value it may take (a string, the first quasi of a template, both branches of a conditional, or, when target and rel test the same name, the branch on which target is `_blank`).
|
|
83
|
+
|
|
84
|
+
### `react-jsx-no-undef`
|
|
85
|
+
|
|
86
|
+
Port of eslint-plugin-react 7.37.5 react/jsx-no-undef (allowGlobals: false, module code). Checks a non-DOM JSX tag name, or the root of a member tag name, against file-local bindings; globals, even configured ones, do not count in a module.
|
|
87
|
+
|
|
88
|
+
### `react-no-children-prop`
|
|
89
|
+
|
|
90
|
+
Port of eslint-plugin-react 7.37.5 react/no-children-prop (allowFunctions: false): a `children` JSX attribute, and a createElement call (default pragma) whose second argument is an object literal with a `children` key.
|
|
91
|
+
|
|
92
|
+
### `react-no-danger`
|
|
93
|
+
|
|
94
|
+
Port of eslint-plugin-react 7.37.5 react/no-danger, default options. Only DOM elements (tag name starting lower-case, per jsx-ast-utils elementType) are checked; custom components receiving the prop are not reported.
|
|
95
|
+
|
|
96
|
+
### `react-no-danger-with-children`
|
|
97
|
+
|
|
98
|
+
Port of eslint-plugin-react 7.37.5 react/no-danger-with-children. Children means a first child that is not a line break, or a `children` prop. Props are also read through `{...name}` spreads of a variable initialised with an object literal. For `x.createElement(type, props, ...)`, props may be an object literal or a variable initialised with one, and children is a third argument or a `children` prop.
|
|
99
|
+
|
|
100
|
+
### `react-no-direct-mutation-state`
|
|
101
|
+
|
|
102
|
+
Port of eslint-plugin-react 7.37.5 react/no-direct-mutation-state. Reports an assignment or update whose target is a member chain rooted at `this.state`, inside a class component (nearest class extends Component / PureComponent / React.Component / React.PureComponent) or a function that is a property of the object passed to createReactClass. In a constructor it is reported only when inside a call. Reported at `this`. Function components (the plugin's Components.detect stateless detection) are not modelled.
|
|
103
|
+
|
|
104
|
+
### `react-no-find-dom-node`
|
|
105
|
+
|
|
106
|
+
Port of eslint-plugin-react 7.37.5 react/no-find-dom-node: any call whose callee is `findDOMNode` or a member `.findDOMNode`.
|
|
107
|
+
|
|
108
|
+
### `react-no-is-mounted`
|
|
109
|
+
|
|
110
|
+
Port of eslint-plugin-react 7.37.5 react/no-is-mounted: `this.isMounted()` inside an object property or a method (ESTree Property / MethodDefinition ancestor).
|
|
111
|
+
|
|
112
|
+
### `react-no-render-return-value`
|
|
113
|
+
|
|
114
|
+
Port of eslint-plugin-react 7.37.5 react/no-render-return-value (latest React). The value counts as used when the call's parent (parentheses aside) is a declarator, a property, a return, an arrow body or an assignment.
|
|
115
|
+
|
|
116
|
+
### `react-no-string-refs`
|
|
117
|
+
|
|
118
|
+
Port of eslint-plugin-react 7.37.5 react/no-string-refs (latest React, noTemplateLiterals: false): a `ref` attribute whose value is a string literal, bare or in braces. Template literals are not reported. From React 18.3 on the plugin no longer reports `this.refs` reads, so neither does the port.
|
|
119
|
+
|
|
120
|
+
### `react-no-unescaped-entities`
|
|
121
|
+
|
|
122
|
+
Port of eslint-plugin-react 7.37.5 react/no-unescaped-entities (forbids >, ", ', }). One finding per such character, but only on the first line of a JSX text node (the k-th check holds where that line has at least k of them; ESLint reports each character at its own column). Characters on a text node's later lines are not reported, because a finding is anchored at a node and a text node has no node per line.
|
|
123
|
+
|
|
124
|
+
### `react-react-in-jsx-scope`
|
|
125
|
+
|
|
126
|
+
Port of eslint-plugin-react 7.37.5 react/react-in-jsx-scope (pragma React). A JSX opening element or fragment is reported when no `React` binding is visible: none declared at the top level (import, var/let/const, function), in an enclosing block's own declarations, or as an enclosing function's parameter.
|
|
127
|
+
|
|
128
|
+
### `react-self-closing-comp`
|
|
129
|
+
|
|
130
|
+
Port of eslint-plugin-react 7.37.5 react/self-closing-comp (component: true, html: true). Reports an element with a closing tag and no children except whitespace that contains a line break (a same-line space is text and is not reported). Namespaced tags only when lower-case (DOM).
|
|
131
|
+
|
|
132
|
+
### `react-void-dom-elements-no-children`
|
|
133
|
+
|
|
134
|
+
Port of eslint-plugin-react 7.37.5 react/void-dom-elements-no-children. Void elements: area, base, br, col, embed, hr, img, input, keygen, link, menuitem, meta, param, source, track, wbr. Reports children, a `children` attribute or a `dangerouslySetInnerHTML` attribute (one report each); the same through createElement with an object-literal props argument.
|
|
@@ -2534,8 +2534,8 @@ Paths are relative to the pack directory, `packs/react/`. `<file> valid[i]` / `i
|
|
|
2534
2534
|
| `upstream/eslint-plugin-react/fixtures/void-dom-elements-no-children/f87a7db315a4.tsx` | `tests/lib/rules/void-dom-elements-no-children.js` | derived |
|
|
2535
2535
|
|
|
2536
2536
|
> `recording.json` is a port readiness recording, and no file of this pack, so it is recorded here rather than in the
|
|
2537
|
-
> table above: the tool-pack's `recording.lock` names it
|
|
2538
|
-
> It carries excerpts of this upstream's tests (`tests/lib/rules/*.js`: the `code` of each
|
|
2539
|
-
> redistributed under the licence above, together with Rerail's Apache-2.0;
|
|
2540
|
-
> upstream's own, at the pinned commit.
|
|
2537
|
+
> table above: the tool-pack's `recording.lock` names it by its sha256, and the bytes are an object in S3, not a file in
|
|
2538
|
+
> git (docs/port-readiness.md). It carries excerpts of this upstream's tests (`tests/lib/rules/*.js`: the `code` of each
|
|
2539
|
+
> RuleTester case), redistributed under the licence above, together with Rerail's Apache-2.0; `LICENSE` beside this file
|
|
2540
|
+
> is this upstream's own, at the pinned commit.
|
|
2541
2541
|
|
|
@@ -462,8 +462,9 @@ Paths are relative to the pack directory, `packs/react/`. `<file> valid[i]` / `i
|
|
|
462
462
|
| `upstream/eslint-plugin-react-hooks/fixtures/ESLintRulesOfHooks-test/fa4449ccccf7.js` | `packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js` | derived |
|
|
463
463
|
|
|
464
464
|
> `recording.json` is a port readiness recording, and no file of this pack, so it is recorded here rather than in the
|
|
465
|
-
> table above: the tool-pack's `recording.lock` names it
|
|
466
|
-
> It carries excerpts of this upstream's tests
|
|
467
|
-
> `code` of each RuleTester case), redistributed
|
|
468
|
-
> beside this file is this upstream's own, at the
|
|
465
|
+
> table above: the tool-pack's `recording.lock` names it by its sha256, and the bytes are an object in S3, not a file in
|
|
466
|
+
> git (docs/port-readiness.md). It carries excerpts of this upstream's tests
|
|
467
|
+
> (`packages/eslint-plugin-react-hooks/__tests__/ESLint*-test.js`: the `code` of each RuleTester case), redistributed
|
|
468
|
+
> under the licence above, together with Rerail's Apache-2.0; `LICENSE` beside this file is this upstream's own, at the
|
|
469
|
+
> pinned commit.
|
|
469
470
|
|
package/package.json
CHANGED