We are currently outputting only for the default-outputter some extra
information:
3be03926e8/apps/oxlint/src/result.rs (L61-L87)
My goal is that all information will be passed to our new
DiagnosticReporter / OutputFormatter.
This will break the output format in the next PR. **Merging this PR is
the OK for me to make this change** ⚠️
The only breaking point:
`"Found {number_of_warnings} warning{} and {number_of_errors} error{}."`
will still be outputted when `max_warnings_exceeded` is true.
Because this is something the `DiagnosticReporter` should do and not the
`OutputFormatter`.
The end goal is:
- no `println!`, our `OutputFormatter` and his `DiagnosticReporter` will
return `Option<String>` and we output it the our `stdout`
- `LintResult` will only handle `ExitCode` result and nothing more
- `stdout` can be changed from outside (for the next part)
- add snapshots with a custom `stdout`
I do not know if all goals can be done easily. Last two parts should be
a bit tricky for me, never did test setups in rust.
But we do never stop to learn ;)
The `_SIZE_CHECK` assertion was ignored, because `const`s are only evaluated if they're referenced in a function which is called. Fix that by referencing the const in `UnresolvedReferencesStack::new`.
Also add more assertions to cover all the invariants.
This PR adds a `LatePeepholeOptimizations` pass for minifications that
don't interact with the fixed point loop.
While working on this I found a couple of cases where the previous fixed
point loop is not idempotent.
The $schema property was not added when the --init command was used to
create the configuration. Now, $schema is added based on the
availability of configuration_schema.json in the current working
directory.
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
While working on #8641, I found a lot of places where we unnecessarily use `ref` / `ref mut` in match arms.
In many cases, we're creating double-references (turning a `&T` into a `&&T`). The compiler should be smart enough to remove them for us, but there doesn't seem much point in explicitly creating double-references when we don't actually want them, and relying on compiler to optimize them out again.
For example, if there are 3 tests in 1 spec and all of them fail:
- 💥💥💥
After some implementation, if 1 test passes:
- 💥💥✨
However, in this case, the coverage as number does not change.
This PR visualizes these details for better mental well-being. 😃
(But in practice, specs are so detailed, there is not much opportunity
for this...)
Improve docs for `Allocator`:
1. Explain how allocator works.
2. Demonstrate how to achieve good performance by re-using `Allocator`s.
Also fix the doc test for `CloneIn`.
👋 This implements a reporter for `--format` on `oxlint` which aims to be
visually similar to
https://eslint.org/docs/latest/use/formatters/#stylish
Please note that this is my first time working with Rust and my
knowledge is very limited. I'm unlikely to understand best-practice or
best-pattern references outside of what clippy/cargo lint has already
had me change. If this needs modification, please help me out by making
code suggestions that can be merged to this PR.
Resolves#8422
---------
Co-authored-by: Cameron <cameron.clark@hey.com>
Add 2 methods for determining the size of `Allocator`:
* `capacity` returns total size of memory owned by the `Allocator` (including space not yet used).
* `used_bytes` returns total size of data so far allocated in the arena.
Add `Allocator::with_capacity` method to allow specifying initial capacity when creating `Allocator`. Also add `Allocator::new` as an alternative to `Allocator::default` (does the same thing).
Wrap `bumpalo::collections::String` in `ManuallyDrop` inside our `String` type.
This has 2 advantages:
1. Perf improvement (although it's very minor, because we don't use owned `String` type much).
2. `String`s can be stored in `Allocator` if you want to (#8570 made that impossible, if `String` is `Drop`).