DonIsaac
85d52201b4
docs(span): enhance Span documentation ( #6707 )
...
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-21 14:32:55 +00:00
Don Isaac
d4a2529439
test(span): add Span::is_empty unit tests ( #6706 )
2024-10-20 15:39:14 -04:00
overlookmotel
85e69a11ef
refactor(ast_tools): add line breaks to generated code for ESTree derive ( #6680 )
...
Follow-on after #6404 . Style nit. Add line breaks to generated code, to make it easier to read.
2024-10-19 19:50:13 +00:00
overlookmotel
ad8e293197
refactor(ast_tools): shorten generated code for impl Serialize ( #6684 )
...
Follow-on after #6404 . Shorten generated code for `impl Serialize`.
2024-10-19 19:50:12 +00:00
overlookmotel
9ba2b0e3a3
refactor(ast_tools): move #[allow] attrs to top of generated files ( #6679 )
...
Follow-on after #6404 . Shorten generated code for `impl Serialize` by moving `#[allow]` attrs to top of file.
2024-10-19 19:50:12 +00:00
ottomated
e310e52ca2
feat(parser): Generate Serialize impls in ast_tools ( #6404 )
...
Beginning of #6347 . Instead of using serde-derive, we generate
`Serialize` impls manually.
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-10-19 09:38:44 +01:00
overlookmotel
9e9fa9e741
docs(span): enable lint warnings on missing docs ( #6617 )
...
This attribute was added in #6610 , but then removed again in #6612 . I assume removing it was an accident.
2024-10-15 23:55:49 +00:00
DonIsaac
de22b81b83
docs(data-structures): enable lint warnings on missing docs, and add missing doc comments ( #6612 )
...
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-15 22:50:47 +00:00
DonIsaac
28b1b4efe2
chore(span): enable lint warnings on missing docs ( #6610 )
...
Part of https://github.com/oxc-project/backlog/issues/130
2024-10-15 22:50:44 +00:00
DonIsaac
3faee66400
refactor(span): remove unused ContentHash::content_hash_slice ( #6609 )
...
I've replaced it with impls on `Vec<'a, T>`. I'm hoping this removes some bloat in final binaries.
2024-10-15 22:50:42 +00:00
Boshen
6a194f9086
docs(span): document validity of ModuleKind::Unambiguous ( #6423 )
...
relates #6249
2024-10-10 14:59:41 +00:00
Boshen
fd6798ffbc
fix(parser): remove unintended pub Kind ( #6109 )
2024-09-27 12:44:40 +00:00
Boshen
a07f03aab3
feat(transformer): sync Program::source_type after transform ( #5887 )
...
closes #5552
2024-09-19 14:41:07 +00:00
DonIsaac
a5f2e9ac04
feat(span): impl From<Atom<'a>> for Atom ( #5809 )
2024-09-17 05:46:16 +00:00
Boshen
f49e6ebd41
fix(span): treat .js as module file (reverts the previous breaking change) ( #5612 )
...
As it turns out it's not ideal to treat `.js` as `script` in today's world anymore.
This makes https://github.com/oxc-project/oxlint-ecosystem-ci pass again.
2024-09-08 15:14:04 +00:00
overlookmotel
b3cbd56520
feat(span): format_compact_str! macro ( #5610 )
...
Add `format_compact_str!` macro to create a `CompactStr`, like `format!`.
2024-09-08 14:15:05 +00:00
overlookmotel
3d190a5728
refactor(span): move CompactStr into separate file ( #5609 )
...
Pure refactor. Split `atom.rs` into 2 files.
2024-09-08 14:15:04 +00:00
Boshen
4a8aec1605
feat(span)!: change SourceType::js to SourceType::cjs and SourceType::mjs ( #5606 )
2024-09-08 14:11:02 +00:00
Boshen
553262842c
refactor(span): put types and impl in the same mod file
2024-09-08 14:00:25 +08:00
Boshen
603817bef9
feat(oxc)!: add SourceType::Unambiguous; parse .js as unambiguous ( #5557 )
...
See https://babel.dev/docs/options#misc-options for background on `unambiguous`
Once `SourceType::Unambiguous` is parsed, it will correctly set the returned `Program::source_type` to either `module` or `script`.
2024-09-07 10:48:58 +00:00
Boshen
28b934ca74
fix(coverage): apply always_strict to test262 and typescript per the specifcation ( #5555 )
...
This also removes the confusing `SourceType::always_strict` field.
I hacked it with `SourceType::always_strict`, but what we actually want is add `'use strict'`.
This is technically a breaking change but I don't expect anyone using this outside of oxc.
The snapshot has a large diff due to every single line shifting by 1 row :-/
2024-09-06 17:14:01 +00:00
Boshen
1bed5ce2a5
chore: run cargo +nightly fmt to sort imports ( #5503 )
...
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
overlookmotel
3f204a9af5
docs(span): update docs about ContentEq Vec comparison speed ( #5478 )
...
Update the docs for `impl ContentEq for Vec` to state in what circumstances `PartialEq` is faster. See https://github.com/oxc-project/oxc/pull/5427#discussion_r1744290058 .
2024-09-05 15:34:17 +00:00
overlookmotel
94a6ac63cf
refactor(span): use Hasher from std ( #5476 )
...
Use `std:#️⃣ :Hasher` instead of `core:#️⃣ :Hasher`.
I don't actually know if importing `core` as well as `std` has any compile time perf impact, but as we're using `std` anyway, we may as well use it for everything.
Import into the `auto_impl_content_hash` module to make the macro a little easier to read.
2024-09-05 14:18:01 +00:00
rzvxa
9f6e0ed099
refactor(ast): simplify ContentEq trait definition. ( #5468 )
...
Addresses the concerns brought up in #5427
2024-09-05 05:36:51 +00:00
rzvxa
90facd3657
feat(ast): add ContentHash trait; remove noop Hash implementation from Span ( #5451 )
...
closes #5283
Also removes the noop Hash implementation on `Span` in favor of a real implementation.
2024-09-05 07:20:04 +03:30
rzvxa
23285f431d
feat(ast): add ContentEq trait. ( #5427 )
...
Part of #5283
2024-09-04 11:53:50 +00:00
Boshen
1b20ceb70c
feat(span): add CompactStr::to_compact_string method ( #5385 )
...
For cases where we want to get the inner string and mutate it.
2024-09-01 10:49:39 +00:00
DonIsaac
f81e8a126e
feat(linter): add oxc/no-async-endpoint-handlers ( #5364 )
...
Adds `no-async-endpoint-handlers` rules, which bans async functions used as endpoint handlers in Express applications. These do not get caught by Express' error handler, causing the server to crash with an unhandled process rejection error.
```js
app.use(async (req, res) => {
const foo = await api.getFoo(req.query) // server panics if this function rejects
return res.json(foo)
})
```
I could not find this rule implemented in any ESLint plugin, but this is a problem I see quite often and I'm tired of dealing with it. I've added it to `oxc` for now, but we should consider adding an `express` or `api` plugin in the future.
2024-08-31 16:59:52 +00:00
DonIsaac
5a137f0985
feat(span/source-type): add SourceType factory methods ( #5242 )
2024-08-27 01:19:54 +00:00
DonIsaac
94f60e7748
refactor(span/source-type): make SourceType factories const ( #5241 )
...
I found myself wanting this while writing `no-unused-vars` and while using oxc
in some downstream personal projects.
2024-08-27 01:19:53 +00:00
DonIsaac
f5e05db302
feat(span/source-type): impl Display and Error for UnknownExtension ( #5240 )
2024-08-27 01:19:52 +00:00
DonIsaac
a6bb3b1b98
fix(span/source-type): consider .cjs and .cts files as ModuleKind::Script ( #5239 )
...
- fix: `SourceType::from_path` considers `.cjs` and `.cts` as modules, not scripts
- docs: improve rusdoc for `SourceType::from_path`
- test: add unit tests for `SourceType::from_path`
2024-08-27 01:19:52 +00:00
overlookmotel
770652327d
refactor(span): clarify Atom conversion methods lifetimes ( #4978 )
...
Rename lifetimes on `FromIn` impls for `Atom`s to make it clear where the lifetime of the `Atom` comes from the allocator's lifetime.
2024-08-19 11:53:01 +00:00
overlookmotel
90d0b2ba65
refactor(allocator, ast, span, ast_tools): use allocator as var name for Allocator ( #4900 )
...
We mostly use `allocator` as var name for an `Allocator`, but in some places used the shorter name `alloc`. Use `allocator` everywhere for consistency.
2024-08-15 10:49:11 +00:00
DonIsaac
096ac7bee5
refactor(linter): clean up jsx-a11y/anchor-is-valid ( #4831 )
2024-08-12 01:11:54 +00:00
DonIsaac
b3c3125138
feat(linter): overhaul unicorn/no-useless-spread ( #4791 )
...
I got tired of seeing useless spreads on ternaries and `arr.reduce()` within my company's internal codebase so I overhauled this rule.
## Changes
- add fixer for object spreads
```js
const before = { a, ...{ b, c }, d }
const after = { a, b, c, d } // fixer does not dedupe spaces before `b`
```
- recursively check for useless clones on complex expressions. This rule now catches and auto-fixes the following cases:
```js
// ternaries when both branches create a new array or object
const obj = { ...(foo ? { a: 1 } : { b: 2 }) }
// recursive, so this can support complex cases
const arr = [ ...(foo ? a.map(fn) : bar ? Array.from(iter) : await Promise.all(bar)) ]
// reduce functions where the initial accumulator creates a new object or array
const obj = { ...(arr.reduce(fn, {}) }
```
2024-08-10 04:50:09 +00:00
rzvxa
2e63618462
feat(span): implement CloneIn for the AST-related items. ( #4729 )
...
Follow-on after #4276 , related to #4284 .
2024-08-07 17:28:54 +00:00
overlookmotel
07607d3e94
feat(ast_codegen, span): process Span through ast_codegen ( #4703 )
...
Add `#[ast]` attr to `Span`.
Due to how AST codegen works, this necessitates putting the type def in a separate file. https://github.com/oxc-project/oxc/pull/4696#issuecomment-2271781995
2024-08-06 18:22:22 +00:00
overlookmotel
e1429e5ef1
refactor(span): reduce #[cfg_attr] boilerplate in type defs ( #4702 )
...
Similar to #4375 and #4698 . #4696 added `#[ast]` attribute to types in `oxc_span`, so these types can use `#[serde]` attrs without the `#[cfg_attr(feature = "serialize", ...)]` guard.
2024-08-06 18:00:07 +00:00
rzvxa
125c5fd8ed
feat(ast_codegen, span): process SourceType through ast_codegen. ( #4696 )
2024-08-06 17:42:12 +00:00
DonIsaac
6ff200d072
perf(linter): change react rules and utils to use Cow and CompactStr instead of String ( #4603 )
2024-08-03 21:26:08 +00:00
overlookmotel
54047e021c
feat(ast): GetSpanMut trait ( #4609 )
...
Closes #4606 .
Introduce `GetSpanMut` trait and implement it on all AST node types.
This has to be a separate trait, rather than adding `span_mut` method to `GetSpan` because `AstKind` implements `GetSpan`, and it only has an immutable `&` ref to AST node it contains.
2024-08-02 11:50:24 +00:00
DonIsaac
e2735ca2c5
feat(span): add contains_inclusive method ( #4491 )
...
Part of #4445 , broken into a separate PR.
2024-07-27 01:05:08 +00:00
DonIsaac
a207923af1
perf: replace some CompactStr usages with Cows ( #4377 )
...
Reduce memory allocations in semantic and linter by using `Cow<'a, str>` over `CompactStr`
2024-07-20 19:19:55 +00:00
DonIsaac
ea33f9470b
fix: impl PartialEq<str> for CompactStr ( #4352 )
...
I need this for another PR that I'm working on, but I think adding this just makes sense.
2024-07-19 16:39:10 +00:00
renovate[bot]
d3df3c20d9
chore(deps): update rust crates ( #4261 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Type | Update | Change |
|---|---|---|---|
| [compact_str](https://togithub.com/ParkMyCar/compact_str ) |
workspace.dependencies | minor | `0.7.1` -> `0.8.0` |
| [napi](https://togithub.com/napi-rs/napi-rs ) | workspace.dependencies
| patch | `3.0.0-alpha.3` -> `3.0.0-alpha` |
| [napi-derive](https://togithub.com/napi-rs/napi-rs ) |
workspace.dependencies | patch | `3.0.0-alpha.2` -> `3.0.0-alpha` |
| [oxc_resolver](https://togithub.com/oxc-project/oxc-resolver ) |
workspace.dependencies | minor | `1.9.3` -> `1.10.0` |
---
### Release Notes
<details>
<summary>ParkMyCar/compact_str (compact_str)</summary>
###
[`v0.8.0`](https://togithub.com/ParkMyCar/compact_str/blob/HEAD/CHANGELOG.md#080 )
##### July 8, 2024
#### Breaking Changes 💥
- Consolidate `CompactString::new_inline(...)` and
`CompactString::from_static_str(...)` into
`CompactString::const:new(...)`. Methods are currently marked as
deprecated and will be removed in `v0.9.0`.
- Implemented in [`Add const_new(); remove new_inline() and
from_static_str()`](https://togithub.com/ParkMyCar/compact_str/pull/336 )
- Minimum supported Rust version (MSRV) was bumped to `v1.60`
- Implemented in [`fix: MSRV check and change MSRV to
1.60`](https://togithub.com/ParkMyCar/compact_str/pull/395 )
#### Changes
- Add support for [`borsh`](https://crates.io/crates/borsh ) under an
optional feature.
- Implemented in [`Add borsh
support`](https://togithub.com/ParkMyCar/compact_str/pull/393 )
- Add additial `PartialEq` impls for `CompactString`
- Implemented in [`fix: More PartialEq
impls`](https://togithub.com/ParkMyCar/compact_str/pull/381 )
- Match alignment of internal `InlineBuffer` and `Repr`.
- Implemeneted in [`Align InlineBuffer same as
Repr`](https://togithub.com/ParkMyCar/compact_str/pull/358 )
- Fix conflict between `serde` and `no_std` features.
- Implemented in [`fix serde no-std
issue`](https://togithub.com/ParkMyCar/compact_str/pull/347 )
- Improve performance of `CompactString::is_empty`.
- Implemented in [`Simplify
is_empty()`](https://togithub.com/ParkMyCar/compact_str/pull/330 )
- Implement additional `From` impls that `std::string::String` has.
- Implemented in [`Add missing From impls that String
has`](https://togithub.com/ParkMyCar/compact_str/pull/328 )
- Implement
[`Clone::clone_from`](https://doc.rust-lang.org/std/clone/trait.Clone.html#method.clone_from )
for `CompactString`.
- Implemented in [`Impl Clone::clone_from for
CompactString`](https://togithub.com/ParkMyCar/compact_str/pull/325 )
- Make re-allocations of a heap-based `CompactString` fallible.
- Implemented in [`Make (re)allocations
fallible`](https://togithub.com/ParkMyCar/compact_str/pull/323 )
- Inline short `&'static str`s
- Implemented in [`Inline short static
strings`](https://togithub.com/ParkMyCar/compact_str/pull/321 )
- Add support for serializing a `CompactString` from
[`diesel`](https://crates.io/crates/diesel ) and
[`sqlx`](https://crates.io/crates/sqlx )
- Implemented in [`Implement diesel
compatibility`](https://togithub.com/ParkMyCar/compact_str/pull/318 )
- Implemented in [`Implement for
sqlx`](https://togithub.com/ParkMyCar/compact_str/pull/329 )
... and everything from `v0.8.0-beta`
#### Fixed Issues
- Re-enabled specialization for `String` in `trait ToCompactString` by
upgrading to `castaway v0.2.3`
- Implemented in [`deps: Upgrade to castaway
v0.2.3`](https://togithub.com/ParkMyCar/compact_str/pull/394 )
</details>
<details>
<summary>napi-rs/napi-rs (napi)</summary>
###
[`v3.0.0-alpha.7`](https://togithub.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.6...napi@3.0.0-alpha.7 )
[Compare
Source](https://togithub.com/napi-rs/napi-rs/compare/napi@3.0.0-alpha.6...napi@3.0.0-alpha.7 )
</details>
<details>
<summary>oxc-project/oxc-resolver (oxc_resolver)</summary>
###
[`v1.10.0`](https://togithub.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#1100---2024-07-11 )
[Compare
Source](https://togithub.com/oxc-project/oxc-resolver/compare/oxc_resolver-v1.9.4...oxc_resolver-v1.10.0 )
##### Added
- *(napi)* expose module type info in ResolveResult
([#​223](https://togithub.com/oxc-project/oxc_resolver/pull/223 ))
##### Fixed
- remove `#[cfg(target_os = "windows")]` logic in `canonicalize`
([#​221](https://togithub.com/oxc-project/oxc_resolver/pull/221 ))
##### Other
- update `cargo deny`
([#​222](https://togithub.com/oxc-project/oxc_resolver/pull/222 ))
- pin crate-ci/typos version
###
[`v1.9.4`](https://togithub.com/oxc-project/oxc-resolver/blob/HEAD/CHANGELOG.md#194---2024-07-10 )
[Compare
Source](https://togithub.com/oxc-project/oxc-resolver/compare/oxc_resolver-v1.9.3...oxc_resolver-v1.9.4 )
##### Other
- use custom canonicalize impl to avoid useless syscall
([#​220](https://togithub.com/oxc-project/oxc_resolver/pull/220 ))
- add symlink fixtures
([#​219](https://togithub.com/oxc-project/oxc_resolver/pull/219 ))
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.
👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions ) if
that's undesired.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/ ). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: rzvxa <rzvxa@protonmail.com>
2024-07-15 10:49:08 +08:00
rzvxa
44c7fe39ee
feat(span): add various implementations of FromIn for Atom. ( #4090 )
2024-07-08 15:32:57 +00:00
DonIsaac
2705df93b3
refactor(linter): improve diagnostic labeling ( #3960 )
2024-06-29 05:19:22 +00:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt
2024-06-19 00:48:30 +08:00