Building the Regex here is slow. We can take advantage of the fact that we know what the inputs should look like and parse the number directly.
Cumulatively, this makes linting the RadixUIAdoptionSection.tsx ~7% faster:
```
hyperfine --warmup 100 --shell=none --runs 3000 './oxlint-main -W all --silent ./RadixUIAdoptionSection.jsx' './oxlint-num-separators -W all --silent ./RadixUIAdoptionSection.jsx'
Benchmark 1: ./oxlint-main -W all --silent ./RadixUIAdoptionSection.jsx
Benchmark 1: ./oxlint-main -W all --silent ./RadixUIAdoptionSection.jsx
Time (mean ± σ): 4.1 ms ± 0.1 ms [User: 1.8 ms, System: 1.4 ms]
Range (min … max): 3.8 ms … 4.7 ms 3000 runs
Benchmark 2: ./oxlint-num-separators -W all --silent ./RadixUIAdoptionSection.jsx
Time (mean ± σ): 3.8 ms ± 0.1 ms [User: 1.5 ms, System: 1.4 ms]
Range (min … max): 3.5 ms … 4.5 ms 3000 runs
Summary
./oxlint-num-separators -W all --silent ./RadixUIAdoptionSection.jsx ran
1.08 ± 0.05 times faster than ./oxlint-main -W all --silent ./RadixUIAdoptionSection.jsx
```
Initializing these `Regex`s, even if lazily, is relatively slow on a per-file basis. We can implement these much faster as simple iterators over characters.
Unfortunately, we cannot assume `babelHelpers` is a global var. Obviously, the transform won't work correctly if it's not, but at least `SymbolTable` will be consistent with the AST.
Refactor `HelperLoader` common transform to split up public and internal methods. Move `add_imports` function to be a method of `HelperLoaderStore`, so `impl Traverse for HelperLoader` is as minimal as possible.
This is for consistency with the other common transforms.
Make `ImportKind` private implementation detail of `ModuleImports` common transform. Provide `add_default_import` and `add_named_import` methods instead.
Follow-on after #6434.
Store `BoundIdentifier` in `ImportKind`, rather than storing `name` and `symbol_id` separately. Pure refactor - just allows shortening some code.
Breaking change. `Codegen::into_source_text` consume `Codegen`, instead of taking the `CodeBuffer` and substituting an empty one.
Keeping the `Codegen` alive seems unintuitive, as its state is then out of sync. Consuming the `CodeBuffer` is also marginally cheaper.
Updates regex flag extraction logic to handle no-substitution template literals, allowing cases like this to be correctly reported:
```js
let r = new RegExp('\\u{0}', `u`);
```
### Overview
This PR refactors `only-used-in-recursion` codebase to make the
implementation of #5530 easier.
The diff isn't displaying cleanly, so it might be better to review it
commit by commit when looking at the changes.
### Key changes
1. Extracted diagnostic logic into `craete_diagnostic` function:
3bf00152e9359d26dccc75bc7ae9fb03970fc409
2. Removed redundant check in `is_function_maybe_reassigned`:
a133ec63d12562bbcd4030fd5e4e7245380e5ced
3. Simplified `is_argument_only_used_in_recursion` by removing nesting:
6e6bd0495374528ec20458cb95247a8f88b1b260
I'm seeing lots of bug reports for oxlint & the VSCode extension that
are not using the "linter bug report" template. This PR adds a notice to
our default bug report template that redirects people to the correct
place.
Closes#6525.
Allows `\1`, `\2`, etc. when referencing a capturing group.
Examples of now-allowed patterns:
```js
// both of these have a capture group with an index of 1
const r = /([a-z]+)\1/;
const r = /\1([a-z]+)/;
```
Examples of still-banned patterns:
```js
/([a-z])\0/; //out of range: capture groups are 1-indexed
/([a-z])\2/; // there's only one capture group here
```
I thought I was being clever, but too clever = stupid.
The dummy code designed to flag when our MSRV is bumped and supports `NonNull::add` would fail to compile on Rust versions below 1.80.0. Precisely because of the condition this code is testing - it's not supported!
Fix this by skipping compilation unless running clippy.