I added the test cases from
[eslint-plugin-react/jsx-uses-vars](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/tests/lib/rules/jsx-uses-vars.js)
to a `react.rs` file in the `no_unused_vars` tests module.
After adding the new tests, they immediately passed without any source
code changes required. It would seem that the linter already supported
this rule, but now there will be tests to support it.
---------
Co-authored-by: Cameron <cameron.clark@hey.com>
Fix how options are merged with options from parent folder(s). It's much simpler than I had thought. If folder's options contains `plugins`, that overwrites `plugins` from parent options. They don't get merged.
When create a `_super` function outside class, ensure it's always strict mode. The code it contains was previously inside the class, so was strict mode.
Override some transform conformance test fixtures for class properties transform, where:
* Our output differs from Babel in cosmetic manner only.
* Our transform intentionally works differently from Babel.
* Babel's fixtures enable arrow functions transform, which malfunctions in our implementation. But we're not trying to test arrow functions transform here, so disable it.
Support overriding test fixtures in `update_fixtures.js` script.
Any files in `tasks/transform_conformance/overrides` are copied into Babel test fixtures. If `options.json` is overridden, then script runs Babel with updated options, to generate a new `output` file for the fixture.
`JsonReporter` which the custom test reporter introduced in #7715 uses does not provide error message in `message` prop, where cause of failure is failing assertions. So tests failing due to failing assertions were omitted from snapshot. Include them.
Also add count of passing tests at top of the snapshot.
Follow-on after #7697.
`transform_assignment_target` is inlined into `enter_assignment_target` visitor, so we want it to be as small as possible. Move assigning to `target` into `transform_assignment_target_impl`, which is the cold path.
The principle is that in the transformer the most important thing for performance is to optimize for the path which is "nothing to do here, exit".
Here we are only transforming `object.#prop`, but very few `AssignmentTarget`s are `object.#prop`, so 99% of the time there is nothing to do. So we want to keep that "do nothing and exit" path as fast and small as possible.
In practice, the `*target =` assignment is only a single assembly operation, so this PR is a micro-optimization. But why not? Every little helps.
Although this rule is recommended by the React team,
it does not report incorrect or wrong code for the `correctness` category.
When turned on by default, I find false positive warnings confusing,
I cannot tell whether my code is wrong or the rule implementation is
wrong - see examples in the affine repo.
```
x eslint-plugin-react-hooks(rules-of-hooks): React Hook "use" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function.
,-[packages/backend/server/src/config/affine.self.ts:80:1]
79 | /* Captcha Plugin Default Config */
80 | ,-> AFFiNE.use('captcha', {
81 | | turnstile: {},
82 | | challenge: {
83 | | bits: 20,
84 | | },
85 | `-> });
86 |
`----
```
Follow-up after #7664.
Generalize `duplicate_object` to produce however many duplicates are required. Use it in `transform_expression_to_wrap_nullish_check`.
This should be slightly more efficient, and will make it fool-proof if we expand `duplicate_object` later to handle other `Expression` types.
The `duplicate_object` is great, it has handled unbound identifiers and `this` expressions, so we can remove a lot of code. But it is still a little bit annoying because we need two `object` here, although we can use `clone_in` it needs a special logic for `Expression::Identifier`.
Follow-on after #7668. Rename `create_var*` methods to `create_uid_var*`.
Previous method name `create_var` might suggest that it creates a binding with the provided name. But actually it creates a UID with name *based on* the name provided.