Commit graph

3577 commits

Author SHA1 Message Date
IWANABETHATGUY
d49fb160e3 feat(oxc_codegen): support generate range leading comments (#4898)
1. Support print range leading comments for specific expr or stmt
2024-08-15 04:20:48 +00:00
overlookmotel
9c700ed509
docs(transformer): add README including style guide (#4899)
Add a README to `oxc_transformer` crate, including a "style guide" for
writing transforms. As discussed in #4881.
2024-08-15 10:52:14 +08:00
overlookmotel
f88cbcd4ab feat(transformer): add BoundIdentifier::new_uid_in_current_scope method (#4903)
Add method `BoundIdentifier::new_uid_in_current_scope` as a shortcut.
2024-08-14 18:55:27 +00:00
overlookmotel
786bf07e45 refactor(index): shorten code and correct comment (#4905)
Style nit + comment correction. Plain `Box` is used everywhere else in this file, no need to fully specify `alloc::boxed::Box`.
2024-08-14 17:55:25 +00:00
overlookmotel
a6967b30f3 refactor(allocator): correct code comment (#4904)
Correct code comment in `Box::unbox`.
2024-08-14 17:44:54 +00:00
overlookmotel
452187a3ca refactor(transformer): rename BoundIdentifier::new_uid_in_root_scope (#4902)
Just renaming the method.
2024-08-14 17:37:25 +00:00
overlookmotel
1e6d0fe7dd
feat(transformer): add methods to BoundIdentifier (#4897)
`BoundIdentifier` helper previously only had methods to create a
read-only `IdentifierReference`. Add methods to also create write-only
or read-write `IdentifierReference`s.
2024-08-15 00:12:20 +08:00
heygsc
97e38cd493
feat(linter): add fixer for unicorn/prefer-optional-catch-binding (#4867) 2024-08-14 08:17:11 -04:00
overlookmotel
707a01f438 refactor(transformer): re-order BoundIdentifier methods (#4896)
Pure refactor, no real changes. Just re-order method definitions.
2024-08-14 12:06:18 +00:00
overlookmotel
117dff2c47 refactor(transformer): improve comments for BoundIdentifier helper (#4895)
Add more comments for `BindingIdentifier` helper, and correct comments which were inaccurate.
2024-08-14 11:52:26 +00:00
keita hino
93ae1c78b8
feat(linter): eslint-plugin-react jsx-props-no-spread-multi (#4866)
partof: https://github.com/oxc-project/oxc/issues/1022

docs:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md
code:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/jsx-props-no-spread-multi.js
test:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/tests/lib/rules/jsx-props-no-spread-multi.js

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-08-14 12:44:46 +01:00
DonIsaac
ea1e64a1f3 refactor(semantic): make SemanticBuilder opaque (#4851)
change visibility of building-related methods and properties of SemanticBuilder
from `pub` to `pub(crate)`.
2024-08-14 08:15:20 +00:00
Boshen
21f576252a fix(codegen): minify large numbers (#4889) 2024-08-14 06:52:17 +00:00
mysteryven
4d28d037e6 feat(task/website): support render subschemas.all_of (#4800)
To solve unexpected snapshot update in #4742  : https://github.com/oxc-project/oxc/pull/4742/files#diff-4c1a03dc03cfd00f9eaecb5c66b61f4e57272c6262253f0dc82ea1b71223bac2
2024-08-14 06:12:03 +00:00
Boshen
e8de4bde41 fix(codegen): fix whitespace issue when minifying x in new Error() (#4886) 2024-08-14 04:29:17 +00:00
rzvxa
c164bb8b64 chore(deps): remove static_assertions dependency. (#4883) 2024-08-14 02:18:06 +00:00
Boshen
81fd6379e8 fix(minifier): do not fold 0 && (module.exports = {}) for cjs-module-lexer (#4878) 2024-08-13 12:54:59 +00:00
overlookmotel
48a1c32ed3 refactor(syntax): inline trivial bitflags methods (#4877)
Add `#[inline]` to trivial bitflags methods. Very likely this makes no difference within Oxc, as we compile with LTO enabled, but for external consumers of Oxc who don't use LTO, this will enable cross-crate inlining.
2024-08-13 12:43:09 +00:00
Boshen
879a271d47 fix(minifier): do not join require calls for cjs-module-lexer (#4875) 2024-08-13 12:21:37 +00:00
rzvxa
5fd170140e refactor(sourcemap): lower the msrv. (#4873)
Related to https://github.com/oxc-project/oxc/pull/4864#issuecomment-2285908919
https://releases.rs/docs/1.80.0/#stabilized-apis
2024-08-13 10:52:34 +00:00
Boshen
a2269625cc fix(codegen): print TSNonNullExpression (#4869) 2024-08-13 08:47:07 +00:00
Boshen
3da33d3647 fix(codegen): missing parenthesis for PrivateInExpression (#4865) 2024-08-13 06:54:26 +00:00
IWANABETHATGUY
1808529a0c
fix(codegen): dedupe pure annotation comments (#4862)
Close https://github.com/oxc-project/oxc/issues/4843
2024-08-13 13:53:28 +08:00
Boshen
1bdde2c117 fix(parser): detect @flow in `/** @flow */ comment (#4861)
Discovered in https://github.com/oxc-project/monitor-oxc

There are files with

```
/**
 * @flow
 */
```

https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__mocks__/JSXAttributeMock.js#L1

So I changed the logic to checking the first comment instead.
2024-08-13 05:43:48 +00:00
heygsc
a105df3adf
chore(linter): fix comment (#4860) 2024-08-12 23:44:49 -04:00
DonIsaac
a08d7a7f94 fix(linter/jsx-a11y): reduce false negatives for html-has-lang (#4855) 2024-08-13 03:31:33 +00:00
DonIsaac
13c7b1b9d2 feat(linter/jsx-a11y): add fixer for aria-unsupported-elements (#4854) 2024-08-13 03:31:31 +00:00
DonIsaac
56f033c556 refactor(linter): improve diagnostics for several jsx-a11y rules (#4853) 2024-08-13 03:31:29 +00:00
DonIsaac
a6195a6a77 feat(linter/jsx-a11y): add fixer for anchor-has-content (#4852)
Add a conditional fix that removes `aria-hidden` from an anchor's child if there
is only a single child. This PR also fixes a false positive on hidden anchors.
It should report visible anchors with hidden content, not hidden anchors.
2024-08-13 03:31:27 +00:00
DonIsaac
a81ce3a3c7 fix(linter/no-unused-vars): do not delete function expressions when fixing (#4848)
`VariableDeclarator` fixer will no longer delete declarations that are initialized to function expressions.

```ts
// none of these get deleted
const unusedArrow = () => {}
const unusedAnon = function() {}
const unusedNamed = function foo() {}

// matches fixer behavior for function declarations
function unusedDecl() {}
```
2024-08-13 02:31:34 +00:00
DonIsaac
c53c210efc refactor(linter/no-unused-vars): split fixer logic into multiple files (#4847) 2024-08-13 02:31:33 +00:00
overlookmotel
c0b26f4df4
fix(ast): do not include scope_id fields in JSON AST (#4858)
Exclude `scope_id` fields from JSON AST (as produced by `oxc-parser` NPM
package). I neglected to flag them `#[serde(skip)]` when I added these
fields.
2024-08-13 10:23:32 +08:00
DonIsaac
0a01a4729a docs(semantic): improve documentation (#4850) 2024-08-13 02:14:07 +00:00
rzvxa
8e8fcd0584 refactor(ast_tools): rename oxc_ast_codegen to oxc_ast_tools. (#4846)
This PR renames the `oxc_ast_codegen` crate to `oxc_ast_tools`, It improves the readability and organization of the codebase by giving the crate a name that better reflects its purpose and contents.

It also improves the error message in CI.
2024-08-12 14:33:58 +00:00
heygsc
0a23610d9a
feat(linter): add fixer for unicorn/prefer-array-flat-map (#4844) 2024-08-12 08:35:27 -04:00
oxc-bot
977b74af2d
Release crates v0.24.2 (#4841)
## [0.24.2] - 2024-08-12

### Features

- 8e10e25 allocator: Introduce `Address` (#4810) (overlookmotel)

### Bug Fixes

- 62f759c transformer/typescript: Generated assignment for constructor
arguments with access modifiers should be injected to the top of the
constructor (#4808) (Dunqing)

### Performance

- 504ac0b minifier: `InjectGlobalVariables` only add to
`replaced_dot_defines` once for each (#4803) (overlookmotel)
- 35f2742 minifier: Avoid repeated `Atom` creation in
`InjectGlobalVariables` (#4802) (overlookmotel)

### Documentation

- 8827659 ast: More doc comments for JSX nodes (#4830) (DonIsaac)
- 559baa5 parser: Clean up doc regarding performance; remove conformance
(Boshen)

### Refactor

- 0ea697b ast, ast_codegen: `CloneIn` implementations now initialize
semantic related cells with `Default` value. (#4819) (rzvxa)
- ecfa124 ast_codegen: Add line break to generated code (#4829)
(overlookmotel)
- 096ac7b linter: Clean up jsx-a11y/anchor-is-valid (#4831) (DonIsaac)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-12 16:02:07 +08:00
Boshen
fae8a62a62 fix(minifier): temporarily bail constant folding for tagged template (#4842)
closes #4341
2024-08-12 07:38:25 +00:00
Boshen
559baa5602
docs(parser): clean up doc regarding performance; remove conformance
conformance is removed due to needing to keep it updated.
2024-08-12 14:02:09 +08:00
oxc-bot
972492cc4d
Release oxlint v0.7.1 (#4835)
## [0.7.1] - 2024-08-12

### Features

- 3d40528 linter: Add fix emoji to rules table and doc pages (#4715)
(DonIsaac)
- d2734f3 linter: Start fixer for no-unused-vars (#4718) (DonIsaac)
- 070ae53 linter: Add fixer for unicorn prefer-string-replace-all
(#4801) (camc314)
- b3c3125 linter: Overhaul unicorn/no-useless-spread (#4791) (DonIsaac)
- 5992b75 linter: Implement `eslint-plugin-promise/no-return-in-finally,
prefer-await-to-then` rule (#4318) (Jelle van der Waa)
- b259f47 linter: Add fixer for unicorn/no-length-as-slice-end (#4780)
(heygsc)
- abd83fa linter: Add fixer for jsx_ally/no_aria_hidden_on_focusable
(#4772) (heygsc)
- b20e335 linter: Add fixer for eslint/no-eq-null (#4758) (heygsc)
- 2f6c3b9 linter: Add fixer for eslint/no-compare-neg-zero (#4748)
(heygsc)
- eaddc8f linter: Add fixer for eslint/func_names (#4714) (DonIsaac)
- 80557a9 linter: Add fixer for eslint/for-direction (#4679) (heygsc)
- c3c5766 linter/eslint-plugin-promise: Implement valid-params (#4598)
(Jelle van der Waa)
- c509a21 linter/eslint-plugin-vitest: Implement prefer-to-be-falsy
(#4770) (dalaoshu)
- 41f861f linter/eslint-plugin-vitest: Implement prefer-to-be-truthy
(#4755) (dalaoshu)
- cc922f4 vscode: Provide config's schema to oxlint config files (#4826)
(Don Isaac)
- f629514 website: Auto-generate rule docs pages (#4640) (DonIsaac)

### Bug Fixes

- b22ed45 linter: Improve prefer_namespace_keyword rule (#4751) (Burlin)
- db68a6c linter: Fixer for eslint/for-direction (#4727) (heygsc)
- 6273994 linter: Block in eslint/no_cond_assign (#4721) (heygsc)
- b9d6aa5 linter: Fix false positives in no-confusing-non-null-assertion
(#4665) (Renée)
- cbf08d2 linter: Skip no-multi-str on jsx attributes (#4666) (heygsc)
- a6f9f96 linter: No unused errors should be warnings (Boshen)
- 7345bc9 linter/func-names: Handle ts accessibility when reporting
missing names (#4713) (DonIsaac)

### Performance

- d191823 linter: Optmize allocations in jest fn parsing (#4787) (lucab)
- e3abdfa linter: Reduce String allocations and clones (#4673)
(DonIsaac)

### Documentation

- 4b7dfd6 linter: Correct docs for no-unused-vars (#4716) (Don Isaac)

### Refactor

- 096ac7b linter: Clean up jsx-a11y/anchor-is-valid (#4831) (DonIsaac)
- 15a0fd4 linter: Use Option to reduce nested level in
`eslint/getter-return` (#4814) (IWANABETHATGUY)
- 63f274c linter: Simplify NoObjCalls resolution logic (#4765) (lucab)
- 6708680 linter: Replace Windows-style line breaks with Unix-style in
test fixture (#4768) (overlookmotel)
- e285903 linter: Clean up eslint/func_names (#4710) (DonIsaac)

### Testing

- 8f2a566 linter: Ensure rule docs have valid syntax (#4644) (DonIsaac)
- 4dd29db linter: Add fixer test for unicorn/no-zero-fractions (#4783)
(heygsc)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-12 13:36:37 +08:00
Boshen
505d39ba0a
chore: bump deps 2024-08-12 10:12:34 +08:00
Don Isaac
cc922f4c89
feat(vscode): provide config's schema to oxlint config files (#4826)
Updates the VSCode plugin client to automatically provide our
auto-generated
JSON schema to `\.?oxlint(rc)?(\.json)?` files.
2024-08-12 09:15:47 +08:00
DonIsaac
096ac7bee5 refactor(linter): clean up jsx-a11y/anchor-is-valid (#4831) 2024-08-12 01:11:54 +00:00
DonIsaac
8827659a84 docs(ast): more doc comments for JSX nodes (#4830) 2024-08-12 01:11:54 +00:00
overlookmotel
ecfa1247b7 refactor(ast_codegen): add line break to generated code (#4829)
Follow-on after #4819. Style nit. Add a line break after `#![allow(...)]`.
2024-08-11 19:36:24 +00:00
rzvxa
0ea697b4e9 refactor(ast, ast_codegen): CloneIn implementations now initialize semantic related cells with Default value. (#4819)
closes #4809
2024-08-11 19:10:56 +00:00
DonIsaac
8862f0680e chore(linter): update docs for declare_oxc_lint! (#4825) 2024-08-11 15:27:54 +00:00
camc314
4e818a434c feat(linter) support arrow functions in oxc only used in recursion (#4816) 2024-08-11 12:50:48 +00:00
overlookmotel
8e10e25ded feat(allocator): introduce Address (#4810)
Closes #4807.

Introduce `Address`. `Address` can be obtained from a `Box<T>` and can act as a unique identifier for an AST node in arena.

NB: It will also be unique across 2 ASTs in different allocators as long as neither allocator is dropped.
2024-08-11 03:31:45 +00:00
DonIsaac
3d40528588 feat(linter): add fix emoji to rules table and doc pages (#4715)
Rules table:
<img width="898" alt="image" src="https://github.com/user-attachments/assets/353052aa-0af3-4c09-8441-ff79f4561ca0">

Doc pages:
<img width="918" alt="image" src="https://github.com/user-attachments/assets/cb43cb2d-15ff-41e6-8523-145cfbc3f484">
2024-08-10 22:50:47 +00:00
IWANABETHATGUY
15a0fd4f7e
refactor(linter): use Option to reduce nested level in eslint/getter-return (#4814)
1. Simplify `is_wanted_node`
2024-08-10 16:44:30 -04:00