Commit graph

6508 commits

Author SHA1 Message Date
Boshen
5d6997502b
chore(renovate): let renovate bump all npm versions because this is a pnpmm onorepo now 2024-10-28 09:10:54 +08:00
overlookmotel
7fcc4f7211 refactor(ast_tools): one function to add header to generated files (#6971)
Centralize logic for adding header to generated files.
2024-10-28 00:47:49 +00:00
overlookmotel
c7bec098fa docs(ast_tools): correct doc comments for Output (#6970) 2024-10-28 00:47:48 +00:00
overlookmotel
3aed3eb543 refactor(ast_tools): remove well_known! macro (#6957)
Remove `well_known!` macro by expanding code manually.
2024-10-28 00:47:46 +00:00
overlookmotel
54e78d9ea3 refactor(ast_tools): reduce macro usage (#6956)
Pure refactor. Expand simple macros.
2024-10-28 00:47:45 +00:00
renovate[bot]
7827bec826
chore(deps): update vscode npm packages (#6963) 2024-10-28 08:44:18 +08:00
Nicholas Rayburn
6cb1973f4a
fix(editor): Publish diagnostics on open for all run modes except disabled (#6965) 2024-10-28 08:39:47 +08:00
Nicholas Rayburn
6b619da23a
feat(editor): Listen to config file changes and trigger a didChangeConfiguration update (#6964)
Watch eslint and oxlint config files for changes. When these files
change, a `didChangeConfiguration` event will be sent to the language
server.

Ref https://github.com/oxc-project/backlog/issues/132.
2024-10-28 08:39:24 +08:00
Nicholas Rayburn
ebf37539c0
fix(editor): Fix onConfigChange to send the correct config for didChangeConfiguration notification (#6962)
This currently fails because it sends over data that the language server
isn't prepared to deserialize. This updates to send over the correct
`LanguageServerConfig` type.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-28 08:38:57 +08:00
overlookmotel
83d1f69f75 refactor(ast_tools): replace str::replace with CowUtils::cow_replace (#6954)
Obey our clippy-enforced policy to prefer `CowUtils::cow_replace`.
2024-10-28 00:23:34 +00:00
overlookmotel
ac6b3091ab refactor(ast_tools): remove repeated code in Output methods (#6953)
`generator_path.replace('\\', "/")` was repeated in each module for that generates outputs. Move it, to reduce repetition.
2024-10-28 00:23:33 +00:00
overlookmotel
2b10e5cd52 refactor(ast_tools): move logger into separate module (#6952)
Reduce the amount of code in `main.rs` by moving logger functionality to a separate module.
2024-10-28 00:23:33 +00:00
overlookmotel
06f05659c5 refactor(ast_tools): refactor writing outputs (#6951)
`write_all_to` no longer needs to be public. Remove it, and compact the code for writing files.
2024-10-27 23:56:22 +00:00
overlookmotel
6b88798253 refactor(ast_tools): generate JSON schema as Output::Raw (#6950)
Add `Output::Raw`, and use it for the JSON schema file.
2024-10-27 23:56:21 +00:00
overlookmotel
2fc6ca374f refactor(ast_tools): hardcode schema output path (#6949)
Hard-code the output file path for JSON schema file. This will allow generating it as an `Output`, same as all other generated files.
2024-10-27 23:40:57 +00:00
overlookmotel
ef2f73ebed refactor(ast_tools): rename Output::into_raw method (#6948)
Rename `Output::output` to `Output::into_raw` - more descriptive name.
2024-10-27 23:40:56 +00:00
overlookmotel
524d9c069f refactor(ast_tools): generate CI filter as Output::Yaml (#6947)
Add `Output::Yaml` and use it for generating CI filter file.
2024-10-27 19:18:10 +00:00
overlookmotel
11539e61fd
refactor(ast_tools): add CI filter file to outputs (#6946)
Generate CI filter file as a `RawOutput`, same as the rest, rather than
specific code to write it to a file.
2024-10-27 19:09:42 +00:00
overlookmotel
87db9eeeed refactor(ast_tools): simplify logging (#6945)
* Replace `logln!` macro with `log_result!` to log result of an action.
* Move logging for writing files into one place.
2024-10-27 18:53:24 +00:00
DonIsaac
f5a7134834 fix(linter/no-unused-vars): false positive for discarded reads within sequences (#6907)
Fixes a case where no-unused-vars incorectly reports a read as unused in edge
cases where a logical/binary expression is used as a conditional shorthand to
write a variable within sequence expressions.

Some code examples will make this more clear.
```js
function foo(a) {
  let x = somePropertyIWantToCheck();
  (x in a && x.hasPropA = true, console.log(a))
}
```
Since the logical expression is not in the last position within the sequence
expression list, it's getting discarded as unused. However, the right expression
(`x.hasPropA = true`) has side effects, so it _is_ being used.
2024-10-27 17:06:58 +00:00
overlookmotel
dde095c7e1 refactor(ast_tools): combine derives into generators (#6944)
`Generator`s and `Derive`s now work the same. Combine them into a single `Vec`.
2024-10-27 15:37:25 +00:00
overlookmotel
80a163e691 refactor(ast_tools): reduce repeated code (#6943)
Use one function to process all passes.
2024-10-27 15:37:24 +00:00
overlookmotel
e1b747ddd6
refactor(ast_tools): all runners produce Vec<Output> (#6942)
Standardize all the different `Runner`s to produce `Vec<Output>`.
2024-10-27 15:29:17 +00:00
overlookmotel
c83b758507 refactor(ast_tools): simplify Pass (#6941)
Pure refactor. Remove dead code and structure like the other `Runner`s.
2024-10-27 14:38:18 +00:00
Boshen
9a6a2f99c6 refactor(semantic)!: remove SymbolTable::get_symbol_id_from_span API (#6955)
closes #6867
2024-10-27 14:31:36 +00:00
overlookmotel
c4c0865cb3
refactor(ast_tools): clarify code (#6940)
Small refactor.
2024-10-27 14:30:36 +00:00
Boshen
6d97af46c7 feat(rust): use oxc-miette (#6938) 2024-10-27 13:30:20 +00:00
Boshen
d323fe89d7
chore(FUNDING.yml): add Dunqing, DonIsaac, camc314 and leaysgur 2024-10-27 15:25:12 +08:00
Dunqing
5f153aca0c refactor(transformer/react-refresh): use VarDeclarations to insert declarators (#6884) 2024-10-27 07:05:24 +00:00
Dunqing
df3b089f29 refactor(transformer/react-refresh): use StatementInjector to insert statements (#6881) 2024-10-27 07:05:24 +00:00
DonIsaac
1e2f012d3c feat(linter): add oxc/no-map-spread (#6751)
Adds a new performance rule that disallows using object and array spreads in `map` and `flatMap` to modify/merge arrays and objects.
I've currently added it to `nursery` so we can battle-harden it before making it generally available as a `perf` rule.

```ts
// needless O(n) spread on `x`, making this an O(n^2) operation
const x = arr.map(x => {
  return { ...x, foo: getFoo(x.id) }
})

// Object.assign is better here
const x = arr.map(x => {
  return Object.assign(x, { foo: getFoo(x.id) })
})
```
2024-10-26 17:41:21 +00:00
overlookmotel
fc07458280 refactor(ast): move custom types .d.ts file (#6931)
We have a few manually-defined TS types in `oxc_ast` crate. Move that `.d.ts` file out of `src` folder, and name it more descriptively.
2024-10-26 17:10:34 +00:00
overlookmotel
992699012f refactor(napi): move custom types to bottom of file (#6930)
Pure refactor. Doesn't matter much but I think it's preferable for the file not to start with the most random weird types.
2024-10-26 17:10:33 +00:00
overlookmotel
23157bde6f refactor(napi): types file in root of types package (#6929)
Move `types.d.ts` file to root of `@oxc-project/types` package. I think this is cleaner.
2024-10-26 17:10:31 +00:00
injuly
aa3222ac88
fix(oxc_language_server): gitignores now applied to their respective files (#6899) 2024-10-26 10:46:35 -04:00
tomoya yanagibashi
1c66473a8f
feat(linter): Implement eslint/prefer-object-has-own (#6905) 2024-10-26 10:45:38 -04:00
overlookmotel
345b0a6eb0 refactor(ast_tools): shorten code in Visit generator (#6928)
Remove double line-break which formatting removes anyway.
2024-10-26 14:05:23 +00:00
overlookmotel
ad40ab7874 refactor(ast_tools): remove const params for Visit generator (#6927)
This function is large, so const param here was probably making the code slower, certainly slower compile time. Use a runtime value instead.
2024-10-26 14:05:20 +00:00
overlookmotel
4cf008573e refactor(ast_tools): reorder imports in generated code (#6926)
Pure refactor.
2024-10-26 14:05:18 +00:00
overlookmotel
8101d1b2c4 refactor(ast_tools): handle paths as strings (#6925)
We were converting back and forwards between strings and `Path`s for no purpose. Just use strings.
2024-10-26 14:05:16 +00:00
overlookmotel
e4a59368f0 refactor(ast_tools): shorten code (#6924)
Pure refactor.
2024-10-26 14:05:14 +00:00
overlookmotel
73ab6fb13c refactor(ast_tools): remove temporary vec (#6923) 2024-10-26 13:14:39 +00:00
Dunqing
142da1d2ff chore(transform_conformance): reorganize react-refresh related tests (#6918)
Move all tests that are copied from [react-refresh](https://github.com/facebook/react/blob/main/packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js) to the `react-refresh` directory, and add a README to describe the source of these tests. This way we can better stay in sync with upstream.

related: https://github.com/oxc-project/oxc/pull/6884#discussion_r1816888813
2024-10-26 13:07:10 +00:00
overlookmotel
c41c013b4d refactor(ast): rename lifetime (#6922)
Rename lifetime to make clear it's for a temporary borrow, and not lifetime of the arena (which is what we conventionally use `'a` for).
2024-10-26 12:57:41 +00:00
overlookmotel
6ca01b9c35 perf(ast): reduce size of Comment (#6921)
Reduce `Comment` from 20 bytes to 16. Because `Comment` has `#[ast]` attr, it's `#[repr(C)]` which means the fields don't get re-ordered by the compiler, so it contains excess padding. Moving `attached_to: u32` field removes the padding.

I am in favour of using `oxc_ast_tools` to re-order fields the same way the compiler does, which will solve this problem for all AST types. But may as well fix this one in meantime. Unlike most AST types, field order doesn't matter for `Comment` - it is not visited, so the field order has no semantic meaning.
2024-10-26 12:40:08 +00:00
Boshen
eba417aa24
fix(npm): check in npm/parser-wasm (#6917)
closes #6914
2024-10-26 18:03:31 +08:00
oxc-bot
1ea0be1b6a
release(oxlint): v0.10.3 (#6911)
## [0.10.3] - 2024-10-26

- 90c786c regular_expression: [**BREAKING**] Support ES2025 Duplicated
named capture groups (#6847) (leaysgur)

- 8032813 regular_expression: [**BREAKING**] Migrate to new regexp
parser API (#6741) (leaysgur)

### Features

- a73c5af linter: Add fixer for `jsx-a11y/no-access-key` rule (#6781)
(Tapan Prakash)
- 2aa763c linter: Warn unmatched rule names (#6782) (Tapan Prakash)
- 0acca58 linter: Support `--print-config all` to print config file for
project (#6579) (mysteryven)

### Bug Fixes

- f49b3e2 linter: `react/iframe-missing-sandbox` ignores vanilla JS APIs
(#6872) (DonIsaac)
- 54a5032 linter: Correct false positive in `no-duplicates` (#6748)
(dalaoshu)
- a47c70e minifier: Fix remaining runtime bugs (#6855) (Boshen)

### Documentation

- 3923e63 linter: Add schema to config examples (#6838) (Dmitry
Zakharov)

### Refactor

- a148023 linter: Dereference IDs as soon as possible (#6821)
(overlookmotel)
- 423d54c rust: Remove the annoying `clippy::wildcard_imports` (#6860)
(Boshen)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-26 17:13:06 +08:00
Boshen
cb5cb6287e fix(linter): eprintln unmatched rules warning (#6916)
We can make this a hard error and bail early once stable.
2024-10-26 08:59:12 +00:00
ottomated
ce5b609514 feat(ast): remove explicit untagged marker on enums (#6915)
This assumes that any enums with exactly one field in each variant are untagged, and they're tagged otherwise.
2024-10-26 08:21:40 +00:00
Boshen
2c7ac29ece refactor(minifier): remove Tri, use Option<bool> instead (#6912) 2024-10-26 04:28:34 +00:00