Commit graph

5758 commits

Author SHA1 Message Date
camchenry
5ae3f364e9 perf(linter): no-fallthrough: Use string matching instead of Regex for default comment pattern (#6008)
Profiling has shown this rule to be a consistent slow point, and in particular, the Regex construction is slow.

<img width="1323" alt="Screenshot 2024-09-23 at 7 12 58 PM" src="https://github.com/user-attachments/assets/1d9b367d-eeda-4b19-b0a3-463e54ac4334">

This PR improves the situation in two ways:

1. A `Regex` is only constructed when there is a custom comment pattern (which is likely the minority of cases)
2. For the default comment pattern (when no custom pattern is passed), we now use a simple string matcher function, instead of a full-blown regex matcher. I believe this should be faster since it involves much less work, though can still allocate a `String`.
2024-09-24 01:06:00 +00:00
DonIsaac
5a0d17c9aa docs(ast): document more AST nodes (#6000) 2024-09-23 23:19:43 +00:00
DonIsaac
1abfe8f02c docs(semantic): document SymbolTable (#5998)
Re-creation of #5978, per @overlookmotel's request
2024-09-23 23:19:41 +00:00
camchenry
02d5637dbc perf(ast-tools): use FxHashMap over std::collections::HashMap (#5997) 2024-09-23 18:28:54 +00:00
overlookmotel
f02bf516cf refactor(transformer): arrow function transform: remove unnecessary assertion (#6002)
This assertion was required previously for soundness, but now `SparseStack::pop` makes it impossible for `self.this_var_stack.len()` to be 0. Being exactly 1 is not a safety invariant, only that it's not 0.
2024-09-23 18:05:31 +00:00
camchenry
2b17003e0b perf(linter, prettier, diagnostics): use FxHashMap instead of std::collections::HashMap (#5993)
Using `FxHashMap` is faster than `HashMap` in many cases, especially for hashing-heavy workloads. This change improves the performance of the linter, prettier, and diagnostics crates by using `FxHashMap` instead of `std::collections::HashMap`.
2024-09-23 16:29:05 +00:00
camchenry
b240b42eb9 fix(rulegen): handle raw string literals correctly (#5991)
Currently, we are not handling raw string literals correctly and just translating them as normal Rust string literals, which causes compile errors and also misses some cases. This PR updates it so that we detect usage of `String.raw` and translate it as a Rust raw string literal.

Before:

<img width="867" alt="Screenshot 2024-09-23 at 10 02 21 AM" src="https://github.com/user-attachments/assets/7c042537-d6c2-4141-a119-0ed846bce59d">

After:

<img width="832" alt="Screenshot 2024-09-23 at 10 01 27 AM" src="https://github.com/user-attachments/assets/759f6647-a675-42eb-b39d-c0e88f689536">
2024-09-23 16:24:19 +00:00
Boshen
4771492b6a fix(linter): fix import/no_cycle with ignoreTypes (#5995)
related https://github.com/toeverything/AFFiNE/issues/7580

`iter().all` produces `true` on an empty list.
2024-09-23 15:10:53 +00:00
overlookmotel
f5eee723fa docs(semantic): correct docs for Reference (#5992)
Correct docs. `JSXIdentifier` no longer has a reference.
2024-09-23 14:48:19 +00:00
Boshen
0a2f68756f refactor(minifier): move dce conditional expression to RemoveDeadCode (#5971)
This is aligned to closure compiler
2024-09-23 10:22:00 +00:00
overlookmotel
860f108a75 docs(transformer): add to arrow functions transform docs (#5989)
Add details of `spec` option and shorten example.
2024-09-23 09:49:39 +00:00
overlookmotel
7b90d794d1 perf(transformer): SparseStack always keep minimum 1 entry (#5962)
Optimize `SparseStack` (which was introduced in #5940). Initialize it with a single entry, and ensure the stack is never emptied. This makes `take`, `get_or_init` and `get_mut_or_init` methods infallible, since there is always an entry on the stack to read.
2024-09-23 07:52:47 +00:00
overlookmotel
28fe80a6a7 perf(transformer): logical assignment operator transform use SparseStack (#5960)
Use `SparseStack` (introduced in #5940) to store the stack of blocks which may need a `var _temp;` statement added to them. This reduces the memory required for the stack, on assumption that most blocks won't need a `var` statement.
2024-09-23 07:52:46 +00:00
overlookmotel
9f7d4b7b2b perf(transformer): exponentiation operator transform use SparseStack (#5959)
Use `SparseStack` (introduced in #5940) to store the stack of blocks which may need a `var _temp;` statement added to them. This reduces the memory required for the stack, on assumption that most blocks won't need a `var` statement.
2024-09-23 07:52:46 +00:00
overlookmotel
5dc01543fa perf(transformer): nullish coalescing operator transform use SparseStack (#5942)
Use `SparseStack` (introduced in #5940) to store the stack of blocks which may need a `var _temp;` statement added to them. This reduces the memory required for the stack, on assumption that most blocks won't need a `var` statement.
2024-09-23 07:52:45 +00:00
overlookmotel
618e89ecf7 perf(transformer): arrow function transform: reduce stack memory usage (#5940)
Arrow function transform maintains a stack for blocks which may (or may not) need a `var _this = this;` statement added to them.

This stack was `Vec<Option<BoundIdentifier>>` (24 bytes per block). Most blocks won't need a statement added, so most entries are `None`.

Introduce an abstraction `SparseStack`. This stores the stack split into 2 arrays. First array is `Vec<bool>` indicating if a statement needs to be added or not. Only if a statement *does* need to be added, then its details are pushed to a separate array `Vec<BoundIdentifier>`.

This means the memory taken up by the stack will be roughly 1 byte per block, instead of 24 bytes per block (assuming very few blocks need statements added).
2024-09-23 07:52:44 +00:00
michaelm
97a2c41192
fix(isolated-declarations): False positive for class private getter with non-inferrable return type (#5987)
Fixes a case missing from https://github.com/oxc-project/oxc/pull/5964

Co-authored-by: MichaelMitchell-at <=>
2024-09-23 15:28:29 +08:00
oxc-bot
859227e457
release(oxlint): v0.9.7 (#5988)
## [0.9.7] - 2024-09-23

### Features

- d24985e linter: Add `oxc-security/api-keys` (#5906) (DonIsaac)
- f9b44c5 linter: Add unicode sets support to `no-useless-escape` rule
(#5974) (camchenry)
- 0f19848 linter: Implement `no-unexpected-multiline` rule (#5911)
(camchenry)
- 16fe383 linter: Implement `no-extend-native` rule (#5867) (Cam
McHenry)

### Bug Fixes

- eed9ac7 linter: Include actual span size in `no-regex-spaces`
diagnostic (#5957) (camchenry)
- 40c89c2 linter: Move `promise/avoid-new` to style category (#5961)
(DonIsaac)

### Performance

- 608d637 linter: Use `aho-corasick` instead of `regex` for string
matching in `jsx-a11y/img-redundant-alt` (#5892) (camchenry)
- 3148d4b linter: Check file path after checking node kind for
`nextjs/no-head-element` (#5868) (Cam McHenry)

### Refactor

- 0a5a4a9 linter: Use parsed patterns for `unicorn/no-hex-escape`
(#5985) (camchenry)
- 2cf2edd linter: Use parsed patterns in `no-empty-character-class` rule
(#5980) (camchenry)
- a9a8e2a linter: Use regex parser in `eslint/no-regex-spaces` (#5952)
(camchenry)
- 05f592b linter: Use parsed patterns in
`unicorn/prefer-string-starts-ends-with` (#5949) (camchenry)
- 3273b64 linter: Use parsed patterns for
`unicorn/prefer-string-replace-all` rule (#5943) (camchenry)
- ba7b01f linter: Add `LinterBuilder` (#5714) (DonIsaac)
- db4f16a semantic: Call `with_trivias` before `build_with_jsdoc`
(#5875) (Boshen)
- 3d13c6d semantic: Impl `IntoIterator` for `&AstNodes` (#5873)
(DonIsaac)

### Testing

- b681c9a linter: Import test cases for `no-empty-character-class`
(#5981) (camchenry)
- 767602b linter: Add regression test for #5227 (#5975) (camchenry)

---------

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-09-23 15:10:33 +08:00
Boshen
abfca2ab90
chore: clean up .gitignore 2024-09-23 12:03:55 +08:00
Boshen
284257607a
docs(CHANGELOG): mention summarized relese PR 2024-09-23 11:50:06 +08:00
Boshen
cfb3f7a9a4
ci: fix wasm release missing wasm-pack 2024-09-23 11:45:17 +08:00
oxc-bot
b9178cc5ae
release(crates): v0.30.0 (#5986)
## [0.30.0] - 2024-09-23

- c96b712 syntax: [**BREAKING**] Remove `SymbolFlags::ArrowFunction`
(#5857) (overlookmotel)

### Features

- ae89145 ast: Revert `#[non_exhaustive]` change (#5885) (Boshen)
- e8bf30a ast: Add `Comment::real_span` (#5764) (Boshen)
- d901772 codegen: Implement minify number from terser (#5929) (Boshen)
- 9f6696a codegen: Add new lines to `TSTypeParameterDeclaration` (#5853)
(Boshen)
- bcdbba3 codegen: Print jsdoc comments that are attached to statements
and class elements (#5845) (Boshen)
- 26386da codegen: Have `with_source_text` reserve memory for code
buffer (#5823) (DonIsaac)
- 4a62703 isolated-declarations: Handle `export` in the `namespace`
correctly (#5950) (Dunqing)
- 84a5816 isolated_declarations: Add `stripInternal` (#5878) (Boshen)
- dfbde2c isolated_declarations: Print jsdoc comments (#5858) (Boshen)
- 3bf7b24 linter: Make `typescript/no-duplicate-enum-values` a
`correctness` rule (#5810) (DonIsaac)
- 9076dee minifier: Implement part of `StatementFusion` (#5936) (Boshen)
- a111bb6 oxc_wasm: Add `verbse` option to `debug_dot` (#5879)
(IWANABETHATGUY)
- 8e7556f parser: Calculate leading and trailing position for comments
(#5785) (Boshen)
- 65c337a prettier: Improve ts compatibility (#5900) (Alexander S.)
- 6d9ccdd prettier: Support TSMappedType (#5834) (Alexander S.)
- b5ac5a6 prettier: Support TSModuleDeclaration (#5813) (Alexander S.)
- 74d8714 semantic: Add help message for invalid `let x?: number`
(#5969) (DonIsaac)
- 3230ae5 semantic: Add `SemanticBuilder::with_excess_capacity` (#5762)
(overlookmotel)
- a5f2e9a span: Impl `From<Atom<'a>>` for `Atom` (#5809) (DonIsaac)
- a07f03a transformer: Sync `Program::source_type` after transform
(#5887) (Boshen)
- 635e918 traverse: `generate_uid_name` method (#5839) (overlookmotel)

### Bug Fixes

- 66e919e ast: Correct TS types for JSX (#5884) (overlookmotel)
- 0d10521 ast: Serialize `JSXMemberExpressionObject` to estree (#5883)
(overlookmotel)
- a822c9d ast: Serialize `JSXElementName` to estree (#5882) (Boshen)
- f4aefb5 codegen: Print `let[0]` as `(let)[0]` (#5947) (Boshen)
- cee9d0b codegen: Fix spacing of `for await (x of y)` (#5890) (Boshen)
- 5901d2a codegen: Various spacing issues (#5820) (Boshen)
- fd1c46c isolated-declarations: Infer failed if there are two
setter/getter methods that need to be inferred (#5967) (Dunqing)
- 6df82ee isolated-declarations: False positive for class private method
that has arguments without type annotations (#5964) (Dunqing)
- 6a9e71d isolated-declarations: Wrap TSFunctionType in parentheses if
it is inside the `TSUnionType` (#5963) (Dunqing)
- ea32d5b isolated-declarations: Should print constructor assignments
first (#5934) (Dunqing)
- 0f96b59 isolated-declarations: Missing print comments in class's
private method (#5931) (Dunqing)
- 8780c54 isolated-declarations: Do not union a undefined when the param
type is any or unknown (#5930) (Dunqing)
- f07ff14 isolated-declarations: Should not transform signature that has
type annotation (#5927) (Dunqing)
- b6a9178 isolated-declarations: Don't collect references when
`ExportNamedDeclaration` has source (#5926) (Dunqing)
- 756a571 isolated-declarations: Missing empty export when has an export
declare (#5925) (Dunqing)
- e148c80 isolated_declarations: Try fix fixtures (Boshen)
- 9b3f763 isolated_declarations: Try fix new line issue (Boshen)
- ee748b0 isolated_declarations: Fix fixture spacing (Boshen)
- 362c427 mangler,codegen: Do not mangle top level symbols (#5965)
(Boshen)
- 127c881 napi/transform: Fix jsdoc links (#5886) (Boshen)
- 6c04fa1 napi/transform: Make isolated_declaration options optional
(#5880) (Boshen)
- 42dcadf parser: Hashbang comment should not keep the end newline char
(#5844) (Boshen)
- f1551d6 semantic: `?` on variable declaration type annotations is a
syntax error (#5956) (DonIsaac)
- a23879c semantic: Analyze `ReferenceFlags` incorrectly when there are
nested `AssignmentTarget` (#5847) (Dunqing)
- 87323c6 transformer: Arrow function transform: prevent stack getting
out of sync (#5941) (overlookmotel)
- 4e9e838 transformer: Fix arrow function transform (#5933)
(overlookmotel)
- 4d5c4f6 transformer: Fix reference flags in logical assignment
operator transform (#5903) (overlookmotel)
- d335a67 transformer: Fix references in logical assignment operator
transform (#5896) (overlookmotel)
- 9758c1a transformer: JSX source: add `var _jsxFileName` statement
(#5894) (overlookmotel)
- 49ee1dc transformer: Arrow function transform handle `this` in arrow
function in class static block (#5848) (overlookmotel)
- 172fa03 transformer: Fix stacks in arrow function transform (#5828)
(overlookmotel)
- d74c7fa transformer: Remove `AstBuilder::copy` from arrow functions
transform (#5825) (overlookmotel)
- 3cc38df transformer/react: React refresh panics when encounter `use`
hook (#5768) (Dunqing)

### Performance

- cd34f07 isolated-declarations: Combine type/value bindings and
type/value references into one (#5968) (Dunqing)
- c477424 mangler: Use `sort_unstable_by_key` instead of `sort_by`
(#5948) (Boshen)
- c3e0fb6 semantic: Simplify resetting ReferenceFlags in
`AssignmentExpression` (#5846) (Dunqing)
- ff7d9c1 transformer: Arrow function transform: calculate whether
`this` is in arrow function lazily (#5850) (Dunqing)
- fd70c4b transformer: Arrow function transform more efficient scope
search (#5842) (overlookmotel)
- 56703a3 transformer: Make branch more predictable in arrow function
transform (#5833) (overlookmotel)
- 36e698b transformer: Call `transform_jsx` in `exit_expression` rather
than `enter_expression` (#5751) (Dunqing)
- aac8316 transformer/react: Improve `is_componentish_name`'s
implementation (#5769) (Dunqing)

### Documentation

- acc2d16 ast: Document most TypeScript AST nodes (#5983) (DonIsaac)
- 47c2faa ast: Document TryStatement and related nodes (#5970)
(DonIsaac)
- 83ca7f5 diagnostics: Fully document `oxc_diagnostics` (#5865)
(DonIsaac)
- bacfbb8 oxc: Add submodule documentation (#5984) (DonIsaac)
- 3120c6c parser: Add module and struct level documentation (#5831)
(DonIsaac)
- 1ccf290 semantic: Document `AstNode` and `AstNodes` (#5872) (DonIsaac)
- e04841c syntax: Add ModuleRecord documentation (#5818) (DonIsaac)
- 7085829 transformer: Arrow function transform: comment about
incomplete implementation (#5945) (overlookmotel)
- 66b4688 transformer: React: convert docs to standard format (#5891)
(overlookmotel)
- 7f05eed transformer: Add comment about missing features in arrow
function transform (#5855) (overlookmotel)
- 8770647 transformer: Correct docs for arrow function transform (#5854)
(overlookmotel)

### Refactor

- f4fac0f ast: Remove `.iter()` where not needed (#5904) (camchenry)
- 17cd903 ast: Move functions to top level in `ast` macro (#5793)
(overlookmotel)
- cf97f6d ast: Import `syn` types in `ast` macro (#5792) (overlookmotel)
- dc10eaf ast: Split `ast` macro into multiple files (#5791)
(overlookmotel)
- 6dd6f7c ast: Change `Comment` struct (#5783) (Boshen)
- bb95306 codegen: Change annotation comment tests to snapshot (#5800)
(Boshen)
- e613a3d codegen: Prepare to add leading comments by adding a template
method pattern (#5784) (Boshen)
- 7caae5b codegen: Add `GetSpan` requirement to `Gen` trait (#5772)
(Boshen)
- c84bd28 isolated-declarations: Simplify to infer the getter and setter
methods (#5966) (Dunqing)
- 67b4220 isolated-declarations: Simplify handling VariableDeclaration
transform (#5916) (Dunqing)
- 2fd5c2a isolated-declarations: Pre-filter statements that do not need
to be transformed (#5909) (Dunqing)
- 943bd76 minifier: Move tests to their src files (#5912) (Boshen)
- cbaeea6 minifier: Clean up some tests (#5910) (Boshen)
- 144611e minifier: Align ast pass names with closure compiler (#5908)
(Boshen)
- 31e9db4 parser: Shorten `UniquePromise` code (#5805) (overlookmotel)
- 2322b8b parser: Remove dead code warning when running tests (#5804)
(overlookmotel)
- 4abfa76 parser: Add `--ast` and `--comments` to example (Boshen)
- a4b55bf parser: Use AstBuilder (#5743) (Boshen)
- d910304 semantic: Rename lifetime on `impl IntoIterator for &AstNodes`
(#5881) (overlookmotel)
- f360e2c semantic: Remove redundunt is_leading check for JSDoc (#5877)
(leaysgur)
- 9115dd9 semantic: Use `Comment::attached_to` for jsdoc attachment
(#5876) (Boshen)
- db4f16a semantic: Call `with_trivias` before `build_with_jsdoc`
(#5875) (Boshen)
- 3d13c6d semantic: Impl `IntoIterator` for `&AstNodes` (#5873)
(DonIsaac)
- 47d9ad8 semantic: Remove unused vars warning in release mode (#5803)
(overlookmotel)
- 155d7fc transformer: Arrow function transform: ignore type fields when
finding enclosing arrow function (#5944) (overlookmotel)
- 2cf5607 transformer: Split up logical assignment operator transform
into functions (#5902) (overlookmotel)
- 41fbe15 transformer: Internal functions not `pub` in logical
assignment operator transform (#5898) (overlookmotel)
- b11d91c transformer: Remove nested match in logical assignment
operator transform (#5897) (overlookmotel)
- 52c9903 transformer: JSX: use `AstBuilder::vec_from_iter` (#5862)
(overlookmotel)
- 74364ad transformer: JSX: merge `transform_jsx_attribute_item` into
`transform_jsx` (#5861) (overlookmotel)
- d2eaa7d transformer: Reorder match arms in JSX transform (#5860)
(overlookmotel)
- 58a8327 transformer: Simplify match in JSX transform (#5859)
(overlookmotel)
- b9c4564 transformer: Transformer example output semantic + transformer
errors (#5852) (overlookmotel)
- 03e02a0 transformer: Comment about potential improvement to arrow
function transform (#5841) (overlookmotel)
- 40cdad5 transformer: Remove repeat code in arrow function transform
(#5837) (overlookmotel)
- 3dd188c transformer: Deref `SymbolId` immediately (#5836)
(overlookmotel)
- 03a9e1a transformer: Reorder methods in arrow function transform
(#5830) (overlookmotel)
- 4d97184 transformer: Rename vars in arrow function transform (#5827)
(overlookmotel)
- 01c5b7c transformer: Shorten code in arrow functions transform (#5826)
(overlookmotel)
- 85ac3f7 transformer: Arrow functions transform do not wrap function
expressions in parentheses (#5824) (overlookmotel)
- 1c1353b transformer: Use AstBuilder instead of using struct
constructor (#5778) (Boshen)

### Testing

- 84b7d1a index: Add unit tests to `oxc_index` (#5979) (DonIsaac)
- d6cbbe7 isolated-declarations: Arrow function unions in return
signature (#5973) (DonIsaac)

---------

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-09-23 11:20:12 +08:00
DonIsaac
d6cbbe723c test(isolated-declarations): arrow function unions in return signature (#5973) 2024-09-23 02:44:01 +00:00
Dunqing
cd34f07e09 perf(isolated-declarations): Combine type/value bindings and type/value references into one (#5968) 2024-09-23 02:39:28 +00:00
DonIsaac
bacfbb85c7 docs(oxc): add submodule documentation (#5984) 2024-09-23 01:25:35 +00:00
DonIsaac
acc2d16b41 docs(ast): document most TypeScript AST nodes (#5983)
Part of #5870
2024-09-23 01:25:34 +00:00
Boshen
07f34c51d8
chore(renovate): ignore unicode-width update, which is pinned to miette 2024-09-23 09:24:28 +08:00
camchenry
0a5a4a9812 refactor(linter): use parsed patterns for unicorn/no-hex-escape (#5985)
- part of https://github.com/oxc-project/oxc/issues/5416

This pull request includes significant improvements to the `no_hex_escape` rule in the `oxc_linter` crate. The changes enhance the detection and replacement of hexadecimal escapes within regular expressions by introducing a more comprehensive AST traversal.

  - Implemented a new `visit_terms` function and its helper functions to traverse the regex AST and apply checks on individual terms.
  - Introduced the `check_character` function to replace hexadecimal escapes with Unicode escapes within regex patterns.
  - Updated snapshots to reflect the new diagnostic messages and replacements for hexadecimal escapes in regex patterns.
2024-09-23 01:11:02 +00:00
camchenry
b681c9a12c test(linter): import test cases for no-empty-character-class (#5981)
improved test coverage for this rule by importing the newer test cases from 27383226b8/tests/lib/rules/no-empty-character-class.js (L4)
2024-09-23 00:33:29 +00:00
camchenry
2cf2edd6bf refactor(linter): use parsed patterns in no-empty-character-class rule (#5980)
- part of https://github.com/oxc-project/oxc/issues/5416

Uses the parsed regular expression patterns for detecting empty character classes. This is more robust than the handwritten pattern matching from before and allows us to provide more accurate diagnostics and actually point to the empty character class in the literal.
2024-09-23 00:33:29 +00:00
DonIsaac
d24985ed51 feat(linter): add oxc-security/api-keys (#5906)
## What This PR does
Adds a new `oxc-security/api-key` rule that scans for hard-coded API keys.

It is broken up into "secret rules", where each one is responsible for finding a different kind of key. It is architecturally identical to how lint rules themselves. This PR also includes the first of these rules, for AWS access key IDs.

Logic and rules are based on [keyhunter](https://github.com/Donisaac/keyhunter). I've licensed that repo under GNU GPLv3, but it's my code and I can do what I want with it 😈 (read: I'm fine with it being MIT for oxc).

This PR is a complete feature in its own right, but does not represent the end of this work. See https://github.com/oxc-project/backlog/issues/116 to track overall progress.
2024-09-22 22:39:56 +00:00
camchenry
767602b56d test(linter): add regression test for #5227 (#5975)
- closes https://github.com/oxc-project/oxc/issues/5227
2024-09-22 22:25:25 +00:00
DonIsaac
84b7d1ac8b test(index): add unit tests to oxc_index (#5979)
Trying to improve `oxc_index`'s code coverage.
2024-09-22 22:10:04 +00:00
camchenry
f9b44c5738 feat(linter): add unicode sets support to no-useless-escape rule (#5974)
- part of https://github.com/oxc-project/oxc/issues/5416

Replaces the handwritten regex parsing logic with the `oxc_regular_expression` parser, which should be more accurate and enables support for unicode sets.
2024-09-22 21:19:15 +00:00
DonIsaac
74d8714d5a feat(semantic): add help message for invalid let x?: number (#5969) 2024-09-22 15:59:49 +00:00
DonIsaac
47c2faa7a9 docs(ast): document TryStatement and related nodes (#5970)
Part of #5870
2024-09-22 15:54:27 +00:00
Boshen
612f638bcd
chore: change just c to run cargo conformance 2024-09-22 23:50:30 +08:00
Boshen
362c427b94 fix(mangler,codegen): do not mangle top level symbols (#5965) 2024-09-22 13:45:54 +00:00
Dunqing
fd1c46ca9e fix(isolated-declarations): infer failed if there are two setter/getter methods that need to be inferred (#5967) 2024-09-22 13:41:47 +00:00
Dunqing
c84bd28a9c refactor(isolated-declarations): simplify to infer the getter and setter methods (#5966) 2024-09-22 13:02:46 +00:00
Dunqing
6df82eee28 fix(isolated-declarations): false positive for class private method that has arguments without type annotations (#5964)
close: #5874
2024-09-22 10:10:52 +00:00
Dunqing
6a9e71da46 fix(isolated-declarations): wrap TSFunctionType in parentheses if it is inside the TSUnionType (#5963) 2024-09-22 10:10:52 +00:00
camchenry
eed9ac7c46 fix(linter): include actual span size in no-regex-spaces diagnostic (#5957) 2024-09-22 04:45:40 +00:00
camchenry
a9a8e2ad41 refactor(linter): use regex parser in eslint/no-regex-spaces (#5952)
- part of https://github.com/oxc-project/oxc/issues/5416

Use the `oxc_regular_expression` parser to make these checks more robust. a few snapshots are updated because they now output more accurate diagnostics based on the regex AST. for example, `/   ?/` now correctly only highlights two spaces rather than three (because the last one is part of a quantifier)
2024-09-22 04:33:46 +00:00
DonIsaac
40c89c2c5f fix(linter): move promise/avoid-new to style category (#5961) 2024-09-22 04:25:48 +00:00
DonIsaac
f1551d64bc fix(semantic): ? on variable declaration type annotations is a syntax error (#5956)
Closes #5955
2024-09-22 00:01:47 +00:00
camchenry
05f592b834 refactor(linter): Use parsed patterns in unicorn/prefer-string-starts-ends-with (#5949)
- part of https://github.com/oxc-project/oxc/issues/5416

This change enhances the accuracy of the `prefer_string_starts_ends_with` rule by using the parsed regex patterns for analysis. It allows for more precise detection of patterns that can be replaced with `startsWith()` and `endsWith()` methods, reducing false positives and improving the overall effectiveness of the linter.

### What changed?

- Replaced the simple string-based regex analysis with a more robust AST-based approach.
- Removed the `is_simple_string` function as it's no longer needed.
2024-09-21 18:15:07 +00:00
camchenry
3273b64a0f refactor(linter): Use parsed patterns for unicorn/prefer-string-replace-all rule (#5943)
- part of https://github.com/oxc-project/oxc/issues/5416

Replaces the `is_simple_string` method with a more robust check against the parsed terms from the regular expression.
2024-09-21 18:02:59 +00:00
Boshen
c477424bab perf(mangler): use sort_unstable_by_key instead of sort_by (#5948) 2024-09-21 16:44:02 +00:00
Dunqing
4a62703d88 feat(isolated-declarations): handle export in the namespace correctly (#5950)
Previous I didn't follow the behavior of `TypeScript` to handle `export` in `namespace` as I thought no one used this
2024-09-21 16:39:58 +00:00