Commit graph

114 commits

Author SHA1 Message Date
overlookmotel
7066d1cc4f feat(ast, span, syntax, regular_expression)!: remove ContentHash (#8512)
#8483 removed codegen-ed impls of `ContentHash` for AST nodes, because `ContentHash` is not useful. Complete the removal by removing `ContentHash` trait definition, and all remaining references to it.
2025-01-15 15:01:14 +00:00
overlookmotel
de5b28809a
refactor(span): rename Atom::new_const method (#8480)
#8479 introduced `Atom::r#static` method. Rename it to
`Atom::new_const`, to match `CompactStr::new_const` which does the same
thing.
2025-01-14 17:16:32 +08:00
_Kerman
9d550aacaf
feat(span): add Atom::r#static (#8479)
This allows

```rs
const TYPEOF_UNDEFINED: Atom<'static> = Atom::r#static("undefined");

#[derive(Clone, Copy)]
enum Value<'a> {
  /// Not `Atom<'a>`, which takes one more byte
  StringLiteral(&'a Atom<'a>),
  // ...
}

fn get_typeof<'a>(value: Value<'a>) -> Value<'a> {
  if ... {
    return Value::StringLiteral(&TYPEOF_UNDEFINED);
  }
}
```
2025-01-14 16:51:31 +08:00
overlookmotel
e81f34f2f6 style(span): reformat code (#8296) 2025-01-06 13:57:58 +00:00
Boshen
11c4bd8687 feat(span): implement source type {file basename}.d.{extension}.ts (#8109) 2024-12-25 12:24:34 +00:00
overlookmotel
c30a982da3 feat(span): add impl From<ArenaString> for Atom (#7973)
Add conversion method from `oxc_allocator::String` to `Atom`. This is a zero-cost conversion, because the string is already in the arena.
2024-12-18 02:25:34 +00:00
overlookmotel
3858221f45 refactor(global): sort imports (#7883)
Pure refactor. Re-order imports for clarity:

1. `std`
2. External crates
3. `oxc_*` crates
4. Current crate `use crate::...`
5. Super `use super::...`
6. Local modules

This order is from "furthest away" to "closest". This makes it clearer to see what is coming from where.

`cargo +nightly fmt` (#7877) did a lot of the work, but unfortunately `rustfmt` does not have an option to (a) put workspace crates in a separate block from external crates and (b) move `mod` statements to after `use` statements.
2024-12-14 15:07:21 +00:00
Boshen
7fb9d47460 style(rust): cargo +nightly fmt (#7877) 2024-12-14 06:03:31 +00:00
overlookmotel
8991f33fc7 feat(ast): add visit_span to Visit and VisitMut (#7816)
Add `Visit::visit_span` and `VisitMut::visit_span` methods, to facilitate #7811.

Both are no-ops by default, and marked `#[inline]`, so this produces no performance impact.
2024-12-12 13:33:12 +00:00
overlookmotel
b553d6ff9c fix(span): fix clippy warning (#7591)
Fix clippy warning. Only triggers when running clippy in `--release` mode.
2024-12-03 02:18:57 +00:00
Boshen
823353a6fc refactor(linter): clean up APIs for ModuleRecord (#7556) 2024-12-01 04:48:42 +00:00
Boshen
d942a8d41a
chore: Rust v1.83.0 changes (#7535)
This PR does not upgrade rustc. Only changes are applied.

We cannot upgrade to the lastet Rust version yet due to wasm-bindgen
breaking some generated types.

THere's also some elided lifetimes in `**/generated/**`, which requires
modification to ast tools.
2024-11-29 11:59:45 +08:00
ottomated
9725e3c2ec feat(ast_tools): Add #[estree(always_flatten)] to Span (#6935)
Part of #6347

Other changes:
- added #[estree(skip)] to thisSpan in TSThisParameter
- Flattened the span in BoundaryAssertion (regex)
2024-10-28 02:13:24 +00:00
ottomated
169fa22350 feat(ast_tools): Default enums to rename_all = "camelCase" (#6933)
Part of #6347
2024-10-28 01:39:25 +00:00
Boshen
423d54cb74 refactor(rust): remove the annoying clippy::wildcard_imports (#6860) 2024-10-24 13:57:19 +00:00
ottomated
1145341a92 feat(ast_tools): output typescript to a separate package (#6755)
Part of #6347.

Moves typescript logic from derive_estree into a new ast_tools generator.
2024-10-24 13:08:57 +00:00
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