Commit graph

1477 commits

Author SHA1 Message Date
cinchen
c9367820ef
feat(linter): eslint-plugin-vitest/no-conditional-expect (#4425)
support
[eslint-plugin-vitest/no-conditional-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md)
2024-07-23 21:50:45 +08:00
cinchen
27fdd69448
feat(linter): eslint-plugin-vitest/no-commented-out-tests (#4424) 2024-07-23 08:52:39 -04:00
DonIsaac
68efcd4000 feat(linter/react-perf): handle new objects and arrays in prop assignment patterns (#4396)
# What This PR Does

Massively improves all `react-perf` rules
- feat: handle new objects/etc assigned to variables
```tsx
const Foo = () => {
  const x = { foo: 'bar' } // <- now reports this new object
  return <Bar x={x} />
}
```
- feat: handle new objects/etc in binding patterns
```tsx
const Foo = ({ x = [] }) => {
  //           ^^^^^^ now reports this new array
  return <Bar x={x} />
}
```
-feat: nice and descriptive labels for new objects/etc assigned to intermediate variables
```
  ⚠ eslint-plugin-react-perf(jsx-no-new-object-as-prop): JSX attribute values should not contain objects created in the same scope.
   ╭─[jsx_no_new_object_as_prop.tsx:1:27]
 1 │ const Foo = () => { const x = {}; return <Bar x={x} /> }
   ·                           ┬   ─┬                 ┬
   ·                           │    │                 ╰── And used here
   ·                           │    ╰── And assigned a new value here
   ·                           ╰── The prop was declared here
   ╰────
  help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
```
- feat: consider `Object.assign()` and `Object.create()` as a new object
- feat: consider `arr.[map, filter, concat]` as a new array
- refactor: move shared implementation code to `ReactPerfRule` in `oxc_linter::utils::react_perf`
2024-07-23 01:52:59 +00:00
DonIsaac
ac08de817e fix(linter/react_perf): allow new objects, array, fns, etc in top scope (#4395)
Consider the following code:
```tsx
import { FC } from 'react'
import { SvgIcon } from '@mui/material'

const StyledIcon = <SvgIcon sx={{ padding: 1, color: '#ff0000' }} />
//          reported violation  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
export const MyComponent: FC = () => {
    return (
        <div>
            {StyledIcon}
            {/* ... */}
        </div>
    )
}
```

This should not be a violation since the JSX is pre-computed and re-used, which
does not break React's `Object.is()` checks.
2024-07-23 01:39:07 +00:00
Dunqing
85a7cea9d1 refactor(semantic)!: remove name from reference (#4329)
related to: https://github.com/oxc-project/backlog/issues/32
2024-07-22 15:59:23 +00:00
DonIsaac
289dc39865 fix(linter): overflow in no-obj-calls (#4397)
Closes #4389
2024-07-21 23:35:47 +00:00
DonIsaac
f7da22da18 perf(linter): disable lint rules by file type (#4380)
### TL;DR

Added a `should_run` function to multiple lint rules to determine if a rule should be executed based on the source type. This change optimizes the linting process by avoiding unnecessary rule checks.

### What changed?

1. **New Method**: Introduced the `should_run` method in the `Rule` trait.
2. **Implementation**: Implemented the `should_run` method for various lint rules, particularly those related to React and TypeScript.
3. **Usage**: Updated the `Linter` to use the `should_run` method to filter rules before execution.
4. **Macro Update**: Modified the `declare_all_lint_rules` macro to incorporate the `should_run` method.

### How to test?

1. Run the linter on a project containing React and TypeScript files.
2. Verify that only relevant rules are executed based on the file type (e.g., JSX rules for React files).

### Why make this change?

This change improves the performance of the linter by ensuring that only applicable rules are run for a given file type, reducing unnecessary computation and potential false positives.

---
2024-07-21 15:22:54 +00:00
DonIsaac
51f5025c9c feat(linter): add fixer for unicorn/prefer-string-starts-ends-with (#4378)
Part of #4179
2024-07-21 07:20:22 +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
7a75e0f8a7 refactor(linter): use diagnostic codes in lint rules (#4349)
> This PR is (unfortunately) quite large, but all changes are needed in tandem for this to work properly.

## What This PR Does

Updates the linter to populate diagnostics reported by rules with error codes statically derived from `RuleMeta` + `RuleEnum`.

Doing so required changing how we handle vitest rules. I know @mysterven was hoping to refactor that part of the code, and I think this approach is an improvement (but could probably be cleaned up further).

## Changes

### 1. Auto-Populate Error Codes
`LintContext` now sets an error code scope + error code number for diagnostics reported by lint rules. `LintContext` will not clobber existing codes set by rules, allowing for rule-specific override behavior (e.g. to use `eslint-plugin-react-hooks` as an error scope).

In order to accomplish this, I had to update every diagnostic factory for every rule. While doing this I found some incorrect error messages, or messages that could be easily improved. This is where a large majority of the snapshot diffs come from. Additionally, I was able to reduce string allocations from `format!` usages in diagnostic factories, especially within jest rules.

### 2. Framework and Library Detection
This PR adds `FrameworkFlags`, which specify what (if any) set of libraries and frameworks are being used by a project and/or file. They are passed in two ways:

1. `LintOptions` can specify a set of `framework_hints` that apply to the entire target codebase. Right now these are always empty, but I'm thinking in the future we could sniff `package.json`. It may be helpful for enabling/disabling default rules.
2. When `Linter` gets run on a file, framework information is sniffed from the `LintContext`. Right now, we are only checking for `vitest` imports in `ModuleRecord` and test path prefixes from `source_path`. It may be useful to do something similar for React/NextJS rules in the future. I know that [next/no-html-link-for-pages](https://nextjs.org/docs/messages/no-html-link-for-pages) could benefit greatly from this.
2024-07-20 03:35:00 +00:00
Jelle van der Waa
5f1e070c8b
feat(linter/eslint-plugin-unicorn): add fixer for prefer-code-point (#4353) 2024-07-20 10:33:15 +08:00
Jaden Rodriguez
3c0c7093b5
feat(linter): add typescript-eslint/no-extraneous-class (#4357)
Added rule for https://typescript-eslint.io/rules/no-extraneous-class/

Also, I chose to make the match the node against the class and derive
the body from the node, rather than matching against the body and using
the context to go back up to the parent class node as in the original
source.
2024-07-19 15:56:30 -04:00
DonIsaac
7afa1f06c3 feat(linter): support suggestions and dangerous fixes (#4223) 2024-07-18 02:20:30 +00:00
cinchen
acc57295d5
feat(linter): eslint-plugin-vitest/expect-expect (#4299)
support
[eslint-plugin-vitest/expect-expect](https://github.com/veritem/eslint-plugin-vitest/blob/main/src/rules/expect-expect.ts)

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-07-18 10:13:45 +08:00
Jelle van der Waa
ed49e169cb
feat(linter/eslint-plugin-unicorn): implement fixer for prefer-dom-node-append (#4306) 2024-07-18 09:44:23 +08:00
Jelle van der Waa
9df7b5675f
feat(jsx-a11y/no-autofocus): implement fixer support (#4171)
Let oxlint automatically remove the autoFocus attribute when `--fix` is
passed.
2024-07-17 16:31:19 -04:00
cinchen
2213f9393b
feat(linter): eslint-plugin-vitest/no-alias-methods (#4301)
support
[eslint-plugin-vitest/no-alias-methods](https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-alias-method.md)
2024-07-17 16:30:35 -04:00
Jelle van der Waa
4463eb4c48
chore(linter): add fixer test cases for prefer-dom-node-text-content (#4315) 2024-07-17 16:21:31 -04:00
Jelle van der Waa
db2fd70432
feat(linter/eslint-plugin-promise): implement no-webpack-loader-syntax (#4331)
Rule detail:

[link](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-webpack-loader-syntax.md)
2024-07-17 16:13:54 -04:00
github-actions[bot]
697c0efdef
Release oxlint v0.6.1 (#4326)
## [0.6.1] - 2024-07-17

### Features

- 83c2c62 codegen: Add option for choosing quotes; remove slow
`choose_quot` method (#4219) (Boshen)
- 1f8968a linter: Add eslint-plugin-promise rules: avoid-new,
no-new-statics, params-names (#4293) (Jelle van der Waa)
- a4dc56c linter: Add fixer for
unicorn/no_useless_promise_resolve_reject (#4244) (Burlin)
- 6fb808f linter: Add typescript-eslint/no-confusing-non-null-assertion
(#4224) (Jaden Rodriguez)
- 126b66c linter: Support eslint-plugin-vitest/valid-describe-callback
(#4185) (cinchen)
- 05b9a73 linter: Support eslint-plugin-vitest/valid-expect (#4183)
(cinchen)
- 3e56b2b linter: Support eslint-plugin-vitest/no-test-prefixes (#4182)
(cinchen)
- 3016f03 linter: Let fixer functions return a `None` fix (#4210)
(DonIsaac)
- bbe6137 linter: Implement unicorn/no-useless-undefined (#4079)
(Burlin)
- 20cdb1f semantic: Align class scope with typescript (#4195) (Dunqing)

### Bug Fixes

- 9df60da linter: Correct find first non whitespace logic in
@typescript-eslint/consistent-type-imports (#4198) (mysteryven)
- 67240dc linter: Not ignore adjacent spans when fixing (#4217)
(mysteryven)
- dd07a54 linter: Global variables should always check the builtin
variables (#4209) (Jelle van der Waa)
- 351ecf2 semantic: Incorrect resolve references for `TSTypeQuery`
(#4310) (Dunqing)
- 1108f2a semantic: Resolve references to the incorrect symbol (#4280)
(Dunqing)

### Performance

- 0fdc88b linter: Optimize no-dupe-keys (#4292) (lucab)

### Refactor

- 2c7bb9f ast: Pass final `ScopeFlags` into `visit_function` (#4283)
(overlookmotel)
- aa22073 codegen: Improve print API (#4196) (Boshen)
- b5a8f3c linter: Use get_first_parameter_name from unicorn utils
(#4255) (Jelle van der Waa)
- 7089a3d linter: Split up fixer code into separate files (#4222)
(DonIsaac)
- ace4f1f semantic: Update the order of `visit_function` and `Visit`
fields in the builder to be consistent (#4248) (Dunqing)
- 7f1addd semantic: Correct scope in CatchClause (#4192) (Dunqing)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-17 21:18:28 +08:00
Dunqing
a88d588a07 feat(semantic): add ReferenceFlags::TSTypeQuery to indicate referenced by TSTypeQuery (#4317)
`ReferenceFlags::TSTypeQuery` can be used to help us insist on whether the reference is referenced by the type or not.
2024-07-17 09:52:57 +00:00
Dunqing
351ecf2707 fix(semantic): incorrect resolve references for TSTypeQuery (#4310)
```ts
type A = typeof Foo
                ^^^ Only allow reference to value symbol
```

I have verified the changed snapshot. That's correct
2024-07-17 03:33:00 +00:00
Dunqing
1108f2a700 fix(semantic): resolve references to the incorrect symbol (#4280)
close: #3799
related: #3863
2024-07-17 02:50:48 +00:00
Jelle van der Waa
1f8968a521
feat(linter): Add eslint-plugin-promise rules: avoid-new, no-new-statics, params-names (#4293)
This introduces the `eslint-plugin-promise` plugin and implements three
relatively simple rules.

Split off from https://github.com/oxc-project/oxc/pull/4252
2024-07-17 09:21:20 +08:00
lucab
0fdc88beee perf(linter): optimize no-dupe-keys (#4292)
This tweaks the `no-dupe-keys` lint in order to try to optimize it.
The lints reliably shows up in both CPU and memory profiling,
due to the cost of allocating/growing the hashmap and hashing into it.
This PR tries to tackle both by skipping trivial cases and by
pre-allocating a larger hashmap.
2024-07-16 11:08:23 +00:00
overlookmotel
2c7bb9f6c8 refactor(ast): pass final ScopeFlags into visit_function (#4283)
We have a strange workaround for `visit_function` where we pass in `ScopeFlags`, to support creating the scope inside `Function`, but setting different flags for `MethodDefinition`s.

Previously `visit_function` took `Option<ScopeFlags>` and then did `flags.unwrap_or(ScopeFlags::empty()) | ScopeFlags::Function` to it. Personally, I found this confusing. When I was looking at `MethodDefinition`, I was wondering "It's a function, why doesn't it set Function flag too?"

This changes makes it more explicit and clear what `ScopeFlags` everything has.
2024-07-16 07:22:07 +00:00
Jelle van der Waa
b5a8f3c60c
refactor(linter): use get_first_parameter_name from unicorn utils (#4255) 2024-07-16 09:41:38 +08:00
Jelle van der Waa
3416099a18
eslint-plugin-unicorn: prefer-string-trim-start-end rule fixer and fixes (#4285) 2024-07-16 01:45:33 +03:30
Boshen
a71787572e
chore: remove unsafe_code = "warn" rust lint
Feels too verbose as we already have unsafe comment turned on
2024-07-15 10:39:08 +08:00
Burlin
a4dc56c36d
feat(linter): add fixer for unicorn/no_useless_promise_resolve_reject (#4244)
Part of https://github.com/oxc-project/oxc/issues/4179

add fixer for unicorn/no_useless_promise_resolve_reject
2024-07-14 20:19:52 +08:00
Dunqing
ace4f1ff77 refactor(semantic): update the order of visit_function and Visit fields in the builder to be consistent (#4248)
Same as #4195
2024-07-14 11:39:15 +00:00
Dunqing
20cdb1fe0a feat(semantic): align class scope with typescript (#4195)
```ts
class Klass <T>   extends Root       <R>                   {}
//    ^^^^^ ^^^           ^^^^       ^^^                   ^^
//    id type_paramter super_class super_type_parameters  body
```
I reorder fields according to the order above

The class scope is not defined in the spec. But we need to create a scope for `class` to store `TypeParamters`
2024-07-14 03:19:30 +00:00
mysteryven
9df60da6f3 fix(linter): correct find first non whitespace logic in @typescript-eslint/consistent-type-imports (#4198) 2024-07-13 02:33:03 +00:00
DonIsaac
7089a3d67b refactor(linter): split up fixer code into separate files (#4222)
refactor(linter): split up fixer code into separate files

refactor: mark Fix as non_exhaustive
2024-07-13 02:26:00 +00:00
mysteryven
67240dce85 fix(linter): not ignore adjacent spans when fixing (#4217)
fixes: #4204
2024-07-13 02:11:40 +00:00
Jaden Rodriguez
6fb808febf
feat(linter): add typescript-eslint/no-confusing-non-null-assertion (#4224)
Added logic for
https://typescript-eslint.io/rules/no-confusing-non-null-assertion

Left comments for when Suggest feature is added

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-07-12 11:12:43 -04:00
cinchen
126b66c4f8
feat(linter): support eslint-plugin-vitest/valid-describe-callback (#4185)
Rule detail:
[link](https://github.com/veritem/eslint-plugin-vitest/blob/main/src/rules/valid-describe-callback.ts)

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-07-12 11:35:00 +08:00
cinchen
05b9a7375a
feat(linter): support eslint-plugin-vitest/valid-expect (#4183)
Rule detail:
[link](https://github.com/veritem/eslint-plugin-vitest/blob/main/src/rules/valid-expect.ts)

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-07-12 11:24:57 +08:00
Boshen
83c2c62f7b feat(codegen): add option for choosing quotes; remove slow choose_quot method (#4219) 2024-07-12 03:08:22 +00:00
cinchen
3e56b2bd16
feat(linter): support eslint-plugin-vitest/no-test-prefixes (#4182)
Rule detail:
[link](https://github.com/veritem/eslint-plugin-vitest/blob/main/src/rules/no-test-prefixes.ts)
2024-07-12 11:03:39 +08:00
DonIsaac
3016f03578 feat(linter): let fixer functions return a None fix (#4210)
Part of #4187.

Adds `CompositeFix::None`, which enables fixer functions to decide not to fix some code.

While I was in the area, I took the liberty of adding some doc comments.
2024-07-12 01:12:42 +00:00
Jelle van der Waa
dd07a5475b
fix(linter): global variables should always check the builtin variables (#4209)
This fixes commit dbbb6fca56.

Closes #3374
2024-07-11 13:22:34 -04:00
Burlin
bbe6137dc9
feat(linter): implement unicorn/no-useless-undefined (#4079)
Resolves #3870

Hey there, thought I'd give this a try as it's tagged "good first issue"
:) Let me know if there's anything that needs to change

Another part of the code also needs modification:

https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/no-useless-undefined.js#L95

I tried to modify it. If there are any issues with these modifications,
please let me know.
```
fn is_has_function_return_type(node: &AstNode, ctx: &LintContext<'_>) -> bool {
    let Some(parent_node) = ctx.nodes().parent_node(node.id()) else {
        return false;
    };
    match parent_node.kind() {
        AstKind::ArrowFunctionExpression(arrow_func_express) => {
            arrow_func_express.return_type.is_some()
        }
        AstKind::Function(func) => func.return_type.is_some(),
        _ => is_has_function_return_type(parent_node, ctx),
    }
}
```
2024-07-11 22:09:25 +08:00
Dunqing
7f1adddaf0 refactor(semantic): correct scope in CatchClause (#4192)
close: #4186

CatchClause has two scopes. The first one is `CatchClause`, which will add a `CatchParameter` to it. The second one is `Block`, which will add binding that declares in the current block scope.

The spec has a syntax error about `CatchParameter`
- It is a Syntax Error if any element of the BoundNames of CatchParameter also occurs in the LexicallyDeclaredNames of Block.
2024-07-11 08:45:30 +00:00
Boshen
aa22073736 refactor(codegen): improve print API (#4196) 2024-07-11 08:41:04 +00:00
github-actions[bot]
4f26e51b74
Release oxlint v0.6.0 (#4194)
## [0.6.0] - 2024-07-11

- 5731e39 ast: [**BREAKING**] Store span details inside comment struct
(#4132) (Luca Bruno)

### Features

- fb549e1 linter: Add vitest/no-focused-tests rule (#4178) (mysteryven)
- 6c49007 linter: Add fixer for
@typescript-eslint/consistent-type-imports (#3984) (mysteryven)
- 278c3e9 linter: Add fixer for jsx-a11y/aria-props (#4176) (DonIsaac)
- 2188144 linter: Eslint-plugin-jest/prefer-hooks-in-order (#4052)
(cinchen)
- cc58614 linter: Better schemas for allow/warn/deny (#4150) (DonIsaac)
- c5b4be0 linter: Add fixer for prefer-node-protocol (#4129) (DonIsaac)
- 7ec0c0b linter/eslint: Implement no-label-var (#4087) (Jelle van der
Waa)

### Bug Fixes

- ed4c54c eslint/radix: Detect yield Number.parseInt variant (#4110)
(Jelle van der Waa)
- e9ad03b linter: Fixer for no-debugger creates incorrect code (#4184)
(DonIsaac)
- bd69571 linter: Fix top level return panic in
eslint/array_callback_return (#4167) (Boshen)
- c8f5664 linter: Fix panic with unicode in
unicorn/prefer_dom_node_dataset (#4166) (Boshen)
- f2b3273 linter: Fix fixer panic in
typescript/consistent_indexed_object_style (#4165) (Boshen)
- 2334515 linter: Panic in `get_enclosing_function` (#4121) (DonIsaac)
- 1b91d40 linter: Incorrect fixer for `no-unused-labels` (#4123) (Don
Isaac)
- 1729249 linter: Incorrect fix in
`no-single-promise-in-promise-methods` rule; (#4094) (DonIsaac)
- cc7e893 linter/tree-shaking: Avoid recursive function stackoverflow
(#4191) (mysteryven)
- 28eeee0 parser: Fix asi error diagnostic pointing at invalid text
causing crash (#4163) (Boshen)
- 0f02608 semantic: Bind `TSImportEqualsDeclaration`s (#4100) (Don
Isaac)

### Performance

- ddfa343 diagnostic: Use `Cow<'static, str>` over `String` (#4175)
(DonIsaac)

### Refactor

- 2687ebc react: Use find_binding helper for finding React binding
(#4108) (Jelle van der Waa)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-11 14:38:41 +08:00
mysteryven
fb549e1288 feat(linter): add vitest/no-focused-tests rule (#4178)
Rule detail: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
2024-07-11 05:37:04 +00:00
mysteryven
cc7e893634 fix(linter/tree-shaking): avoid recursive function stackoverflow (#4191)
fixes: #4164
2024-07-11 05:28:35 +00:00
mysteryven
6c49007b27 feat(linter): add fixer for @typescript-eslint/consistent-type-imports (#3984)
This rule's fixer is complicated, I do line by line copy as possible.

7b13dae347/packages/eslint-plugin/src/rules/consistent-type-imports.ts
2024-07-11 04:48:04 +00:00
DonIsaac
e9ad03bb62 fix(linter): fixer for no-debugger creates incorrect code (#4184)
Part of #4179.

Fixes cases like:
```js
if (foo) debugger
// got fixed into
if (foo)
// but now gets fixed to
if (foo) {}
```
2024-07-11 04:33:43 +00:00
DonIsaac
278c3e9313 feat(linter): add fixer for jsx-a11y/aria-props (#4176)
Part of  #4179.

Adds a fixer for some common typos.
2024-07-11 04:33:37 +00:00
Jelle van der Waa
7ec0c0bdd4
feat(linter/eslint): Implement no-label-var (#4087)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/no-label-var)

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-07-10 23:22:31 -04:00
DonIsaac
ddfa343475 perf(diagnostic): use Cow<'static, str> over String (#4175)
Allows us to use `&'static str` for  error and help messages without allocating them into `String`s.
2024-07-11 01:44:13 +00:00
Boshen
bd69571965 fix(linter): fix top level return panic in eslint/array_callback_return (#4167) 2024-07-10 15:28:01 +00:00
Boshen
c8f5664e0a fix(linter): fix panic with unicode in unicorn/prefer_dom_node_dataset (#4166) 2024-07-10 15:14:45 +00:00
Boshen
f2b32731df fix(linter): fix fixer panic in typescript/consistent_indexed_object_style (#4165) 2024-07-10 14:45:15 +00:00
Boshen
28eeee0f71 fix(parser): fix asi error diagnostic pointing at invalid text causing crash (#4163) 2024-07-10 14:45:10 +00:00
cinchen
218814483b
feat(linter): eslint-plugin-jest/prefer-hooks-in-order (#4052)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-hooks-in-order.ts)
2024-07-10 22:41:19 +08:00
DonIsaac
cc586145ab feat(linter): better schemas for allow/warn/deny (#4150) 2024-07-10 02:51:10 +00:00
Luca Bruno
5731e3957f
refactor(ast)!: store span details inside comment struct (#4132)
This tweaks `Comment` definition in order to internally store the start
and end position of its span.

Closes: https://github.com/oxc-project/oxc/issues/4069
2024-07-09 23:23:43 +08:00
DonIsaac
c5b4be021e feat(linter): add fixer for prefer-node-protocol (#4129) 2024-07-09 03:13:24 +00:00
DonIsaac
2334515247 fix(linter): panic in get_enclosing_function (#4121)
Fixes one of the panics described in #4111
2024-07-09 02:59:08 +00:00
Don Isaac
1b91d40da2
fix(linter): incorrect fixer for no-unused-labels (#4123) 2024-07-08 17:58:59 -04:00
Jelle van der Waa
2687ebc1c5
refactor(react): use find_binding helper for finding React binding (#4108)
Discovered `find_binding()` when hacking on
https://github.com/oxc-project/oxc/pull/4087 seemed like a nice
refactor.
2024-07-08 18:35:48 +08:00
Jelle van der Waa
ed4c54c0de
fix(eslint/radix): detect yield Number.parseInt variant (#4110)
The eslint rule perfer-numeric-literals has a test for the yield variant
which the radix testsuite did not have. See
https://github.com/oxc-project/oxc/pull/4109
2024-07-08 18:33:18 +08:00
Don Isaac
0f026089d1
fix(semantic): bind TSImportEqualsDeclarations (#4100)
Closes #4091
2024-07-08 14:03:47 +08:00
DonIsaac
17292491b4 fix(linter): incorrect fix in no-single-promise-in-promise-methods rule; (#4094)
Closes #4093
2024-07-08 02:34:19 +00:00
github-actions[bot]
0c7f3eecc6
Release oxlint v0.5.3 (#4082)
## [0.5.3] - 2024-07-07

### Features

- 1681b11 linter: Eslint-plugin-jest/consistent-test-it (#4053)
(cinchen)
- 6876490 linter: Add rule no-undefined (#4041) (jordan boyer)
- bf04dee linter: Implement unicorn/no-negation-in-equality-check
(#4034) (Nissim Chekroun)
- aa45604 linter/eslint: Implement no-multi-str (#4038) (Jelle van der
Waa)

### Bug Fixes

- 7b2dc3b linter: Fix panic in import/namespace (#4080) (Boshen)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-07 19:31:03 +08:00
Boshen
0ec12cf38d
chore(linter): change no-negation-in-equality-check to pedantic 2024-07-07 19:19:09 +08:00
Boshen
7b2dc3b92b fix(linter): fix panic in import/namespace (#4080) 2024-07-07 11:04:20 +00:00
Jelle van der Waa
aa45604bd3
feat(linter/eslint): Implement no-multi-str (#4038)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/no-multi-str)

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-07-06 22:12:10 +08:00
cinchen
1681b11adb
feat(linter): eslint-plugin-jest/consistent-test-it (#4053)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/consistent-test-it.ts)
2024-07-06 11:03:14 +08:00
jordan boyer
6876490baa
feat(linter): add rule no-undefined (#4041)
Implementing rule https://eslint.org/docs/latest/rules/no-undefined

This is my first time contributing here, I wanted to started with a
simple rule before contributing more.

related to #479
2024-07-04 23:50:46 -04:00
Nissim Chekroun
bf04dee861
feat(linter): implement unicorn/no-negation-in-equality-check (#4034)
Fixes https://github.com/oxc-project/oxc/issues/3869

Hey there, thought I'd give this a try as it's tagged "good first issue"
:) Let me know if there's anything that needs to change, I wasn't sure
about the rule category so left as TODO.
2024-07-04 23:05:47 +08:00
github-actions[bot]
b66ad0b675
Release oxlint v0.6.0 (#4029)
## [0.6.0] - 2024-07-02

- c98d8aa ast: [**BREAKING**] Rename `visit_arrow_expression` to
`visit_arrow_function_expression`. (#3995) (rzvxa)

### Features

- dc6d45e ast,codegen: Add `TSParenthesizedType` and print type
parentheses correctly (#3979) (Boshen)
- b257d53 linter: Support report
`@typescript-eslint/consistent-type-imports` (#3895) (mysteryven)
- 2114475 linter: Implement @typescript-eslint/no-dynamic-delete (#3971)
(kaykdm)
- 10a3c9a linter/eslint-plugin-react: Implement no-set-state (#3975)
(Jelle van der Waa)

### Bug Fixes

- 432d6d9 linter: Find disabled directives using the message's `Span`.
(#4010) (rzvxa)
- dbbb6fc linter: Global variable check should always check builtin
variables (#3973) (Boshen)

### Performance

- 1eac3d2 semantic: Use `Atom<'a>` for `Reference`s (#3972) (Don Isaac)

### Refactor

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-07-02 22:07:52 +08:00
rzvxa
432d6d93c9 fix(linter): find disabled directives using the message's Span. (#4010)
fixes #4005
2024-07-02 10:49:05 +00:00
rzvxa
c98d8aa000 refactor(ast)!: rename visit_arrow_expression to visit_arrow_function_expression. (#3995) 2024-07-02 09:19:25 +00:00
renovate[bot]
765f6cc1c7
chore(deps): update rust crate dashmap to v6 (#3987) 2024-07-01 11:25:09 +08:00
mysteryven
b257d53151 feat(linter): support report @typescript-eslint/consistent-type-imports (#3895)
This PR only contains the part about report error, adding the fixer part will make the whole PR difficult to review at one time.

There are also some commented cases. One kind of them is `decorator`, as it blocked by #3645, another kind of them is type reference, need to solve #3799 first. I added TODO flags for them.
2024-06-30 13:48:08 +00:00
kaykdm
211447559b
feat(linter): implement @typescript-eslint/no-dynamic-delete (#3971)
Related issue: https://github.com/oxc-project/oxc/issues/2180

original implementation

- code:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/no-dynamic-delete.ts
- test:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/no-dynamic-delete.test.ts
- doc: https://typescript-eslint.io/rules/no-dynamic-delete/
2024-06-30 19:11:46 +08:00
Jelle van der Waa
10a3c9a052
feat(linter/eslint-plugin-react): Implement no-set-state (#3975)
Rule Detail:


[link](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md)
2024-06-30 19:11:33 +08:00
Boshen
dc6d45e2e6 feat(ast,codegen): add TSParenthesizedType and print type parentheses correctly (#3979)
closes #3916
2024-06-30 07:57:48 +00:00
Boshen
54c653ebd4 Revert "perf(semantic): use Atom<'a> for References" (#3974)
Reverts oxc-project/oxc#3972

@DonIsaac As it turns out we can't have lifetimes on these structures because semantic data is exposed to downstream users to use freely, detached from the ast and allocator.
2024-06-29 15:55:04 +00:00
Boshen
dbbb6fca56 fix(linter): global variable check should always check builtin variables (#3973)
closes #3374
2024-06-29 15:27:23 +00:00
Don Isaac
1eac3d244d
perf(semantic): use Atom<'a> for References (#3972)
Relates to [this
issue](https://github.com/oxc-project/backlog/issues/31) on the backlog.
2024-06-29 23:23:36 +08:00
github-actions[bot]
21b964b214
Release oxlint v0.5.1 (#3967)
## [0.5.1] - 2024-06-29

### Features

- f64ad4b semantic: Make jsdoc building optional (turned off by default)
(#3955) (Boshen)

### Bug Fixes

- c26975a linter: Only show the filename for max-lines (#3966) (Boshen)
- 94329e4 linter: Handle useful but empty constructors in
no-useless-constructor (#3951) (DonIsaac)
- 6498a08 linter: No-useless-spread fixer with multiple spread elements
(#3950) (DonIsaac)
- 750cb43 oxlint: Gate custom allocators by feature flag (#3945) (Luca
Bruno)

### Refactor

- 1cca2a8 eslint: Convert with_labels to with_label where applicable
(#3946) (Jelle van der Waa)
- 2705df9 linter: Improve diagnostic labeling (#3960) (DonIsaac)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-29 17:01:56 +08:00
Boshen
3c72ab769b
chore: s/with_labels([span])/with_label(span) 2024-06-29 16:49:47 +08:00
Boshen
c26975ab76 fix(linter): only show the filename for max-lines (#3966)
closes #3961
2024-06-29 08:40:41 +00:00
DonIsaac
2705df93b3 refactor(linter): improve diagnostic labeling (#3960) 2024-06-29 05:19:22 +00:00
Boshen
f64ad4b7c2 feat(semantic): make jsdoc building optional (turned off by default) (#3955) 2024-06-29 05:12:25 +00:00
DonIsaac
94329e4c66 fix(linter): handle useful but empty constructors in no-useless-constructor (#3951)
Closes #3665
2024-06-28 02:12:20 +00:00
DonIsaac
6498a089ea fix(linter): no-useless-spread fixer with multiple spread elements (#3950)
Closes #3909
2024-06-28 02:06:58 +00:00
Jelle van der Waa
ea30aecb67
Coccinelle labels refactor (#3947)
Follow up of https://github.com/oxc-project/oxc/pull/3946
2024-06-27 19:11:46 -04:00
Jelle van der Waa
1cca2a8d92
refactor(eslint): convert with_labels to with_label where applicable (#3946)
Following earlier work in d6437fec0b prefer `with_label` over
`with_labels`. Automatically converted using CoccinelleForRust.

---

I noticed some conversions of `with_labels` to `with_label` for a single
span in https://github.com/oxc-project/oxc/pull/3854 and in my recent
pull requests. The Linux kernel uses Coccinelle to automatically
converted helper functions, so I was wondering if there was something
similar for Rust as Coccinelle only does C. It turns out that there is a
[Coccinelle for
Rust](https://gitlab.inria.fr/coccinelle/coccinelleforrust), so I wrote
a small Coccinelle rule to automatically convert all rules. (This PR
only touches eslint, I am happy to run it for the whole rules directory,
this is more a test if the project is willing to accept such massive
automatic refactors).

To convert this automatically build the tool, and save the snippet below
as `with_labels.cocci` and run:

```
~/code/coccinelleforrust/target/debug/cfr --apply --coccifile with_labels.cocci  crates/oxc_linter/src/rules/eslint
```

with_labels.cocci:
```
@@
expression E, OxcDiagnostic;
@@

OxcDiagnostic.
- with_labels([E.into()])
+ with_label(E)
```
2024-06-27 15:11:19 -04:00
github-actions[bot]
06e4ce4f5d
Release oxlint v0.5.0 (#3940)
## [0.5.0] - 2024-06-27

- 6796891 ast: [**BREAKING**] Rename all instances of `BigintLiteral` to
`BigIntLiteral`. (#3898) (rzvxa)

- ae09a97 ast: [**BREAKING**] Remove `Modifiers` from ts nodes (#3846)
(Boshen)

- 1af5ed3 ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`const` on `EnumDeclaration` (#3845) (Boshen)

- ee6ec4e ast: [**BREAKING**] Replace `Modifiers` with `declare` and
`abstract` on `Class` (#3841) (Boshen)

- 4456034 ast: [**BREAKING**] Add `IdentifierReference` to
`ExportSpecifier` (#3820) (Boshen)

- 0537d29 cfg: [**BREAKING**] Move control flow to its own crate.
(#3728) (rzvxa)

- 5c38a0f codegen: [**BREAKING**] New code gen API (#3740) (Boshen)

- 4bce59d semantic/cfg: [**BREAKING**] Re-export `petgraph` as
`control_flow::graph`. (#3722) (rzvxa)

### Features

- 3ae2628 linter: Change `no-import-assign` to correctness (#3928)
(Boshen)
- a89d501 linter: Implement
@typescript-eslint/no-non-null-asserted-nulli… (#3850) (kaykdm)
- fc48cb4 linter: eslint-plugin-jest/prefer-jest-mocked (#3865)
(cinchen)
- 63b98bd linter: Accept multiple fixes when fix code (#3842)
(mysteryven)
- 328445b linter: Support `vitest/no-disabled-tests` (#3717)
(mysteryven)
- 8c61f9c linter: Implement @typescript-eslint/no-non-null-assertion
(#3825) (kaykdm)
- 080ecbd linter: Add `no-fallthrough`. (#3673) (rzvxa)
- 9493fbe linter: Add `oxc/no-optional-chaining` rule (#3700)
(mysteryven)
- 139adfe linter: Add `@typescript-eslint/no-import-type-side_effects`
(#3699) (mysteryven)
- 5f84500 linter/eslint-plugin-react: Implement prefer-es6-class (#3812)
(Jelle van der Waa)
- fafe67c linter/import: Implement max-dependencies (#3814) (Jelle van
der Waa)
- d5f6aeb semantic: Check for illegal symbol modifiers (#3838) (Don
Isaac)

### Bug Fixes

- 4bd2c88 linter: Fix and promote `getter-return` to correctness.
(#3777) (rzvxa)
- 1190dee linter: False positives with setters in the `getter-return`
rule. (#3714) (rzvxa)
- de0690f linter: Do not run getter-return in typescript (#3693)
(Boshen)
- cf71c23 linter: Edge case with infinite loops. (#3672) (rzvxa)
- 5902331 oxlint: Properly report error (#3889) (Luca Bruno)
- 99a40ce semantic: `export default foo` should have
`ExportLocalName::Default(NameSpan)` entry (#3823) (Boshen)
- abd6ac8 semantic/cfg: Discrete finalization path after `NewFunction`s.
(#3671) (rzvxa)

### Performance
- 4f7ff7e Do not pass `&Atom` to functions (#3818) (overlookmotel)

### Refactor

- 4d2b7f1 linter: `LintContext` can now only be constructed with a cfg
enabled semantic. (#3761) (rzvxa)
- 7302429 linter/prefer_number_properties: Remove the unused
`IdentifierName` check (#3822) (Boshen)
- d8ad321 semantic: Make control flow generation optional. (#3737)
(rzvxa)

### Testing

- 887da40 linter: Enable `no-fallthrough` test with `disable-next-line`.
(#3766) (rzvxa)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-27 15:09:13 +08:00
Boshen
cd4bd6ec7f
chore(linter): change getter-return to nursery
relates #3935
2024-06-27 14:38:43 +08:00
Boshen
37fceefbbf
chore(linter): change no-fallthrough to pedantic
Because the code is still correct.
2024-06-27 14:37:44 +08:00
Boshen
3ae2628832
feat(linter): change no-import-assign to correctness (#3928)
closes #3733
2024-06-26 22:43:45 +08:00
Jelle van der Waa
5f84500200
feat(linter/eslint-plugin-react): Implement prefer-es6-class (#3812)
Rule Detail:

[link](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md)

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-26 22:20:16 +08:00
kaykdm
a89d501d51
feat(linter): implement @typescript-eslint/no-non-null-asserted-nulli… (#3850)
…sh-coalescing

Related issue: https://github.com/oxc-project/oxc/issues/2180

original implementation

- code:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts
- test:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/no-non-null-asserted-nullish-coalescing.test.ts
- doc:
https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing/
2024-06-26 21:57:33 +08:00
cinchen
fc48cb4560
feat(linter): eslint-plugin-jest/prefer-jest-mocked (#3865)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-jest-mocked.ts)
2024-06-26 21:46:46 +08:00
mysteryven
63b98bddd9 feat(linter): accept multiple fixes when fix code (#3842)
Want to add this because of there are bunch of fix codes in [consistent-type-import](e408b93e48/packages/eslint-plugin/src/rules/consistent-type-imports.ts (L610-L945)) are not easy to port.
2024-06-26 13:29:22 +00:00
Jelle van der Waa
fafe67c817
feat(linter/import): Implement max-dependencies (#3814)
Rule Detail:

[link](https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/max-dependencies.md)

---

This lacks the handling of `require()` which seems to be the case for
most existing `import` rules.

Another "issue" could be if you have:
```
import { foo } from "./foo";
import { bar } from "./foo";
```

But then again there should be another rule to filter these duplicate
imports out and combine them into one.

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-06-25 13:18:01 -04:00
rzvxa
6796891e2e fix(ast)!: rename all instances of BigintLiteral to BigIntLiteral. (#3898)
Notice the casing! Just for the sake of consistency.
2024-06-25 14:39:42 +00:00
mysteryven
328445b4ca feat(linter): support vitest/no-disabled-tests (#3717) 2024-06-24 15:16:32 +00:00
Boshen
7f1266a37b chore(deps): update rust crates (#3873) 2024-06-24 11:24:54 +00:00
kaykdm
8c61f9c0b4
feat(linter): implement @typescript-eslint/no-non-null-assertion (#3825)
Related issue: https://github.com/oxc-project/oxc/issues/2180

original implementation

- code:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/no-non-null-assertion.ts
- test:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/no-non-null-assertion.test.ts
- doc: https://typescript-eslint.io/rules/no-non-null-assertion/


typescript-eslint has a feature that is manually fixable by editor
suggestions on this rule, but oxc does not have one as far as I know, so
the implementation is simple compared to typescript-eslint
2024-06-24 00:09:52 -04:00
Boshen
ae09a97a09
refactor(ast)!: remove Modifiers from ts nodes (#3846) 2024-06-23 19:44:35 +08:00
Boshen
1af5ed3d89 refactor(ast)!: replace Modifiers with declare and const on EnumDeclaration (#3845) 2024-06-23 10:34:55 +00:00
Boshen
ee6ec4ee57 refactor(ast)!: replace Modifiers with declare and abstract on Class (#3841) 2024-06-23 10:34:53 +00:00
Don Isaac
d5f6aeb1ca
feat(semantic): check for illegal symbol modifiers (#3838) 2024-06-23 12:36:09 +08:00
Boshen
445603444f feat(ast)!: add IdentifierReference to ExportSpecifier (#3820)
closes #3795
closes #3796
2024-06-22 11:43:41 +00:00
Boshen
99a40ce6ac fix(semantic): export default foo should have ExportLocalName::Default(NameSpan) entry (#3823) 2024-06-22 11:09:23 +00:00
Boshen
7302429b2b refactor(linter/prefer_number_properties): remove the unused IdentifierName check (#3822) 2024-06-22 09:40:02 +00:00
overlookmotel
4f7ff7e3ad perf: do not pass &Atom to functions (#3818)
`Atom` is just a wrapper around `&str`, so better not to pass `&Atom` to functions, as that's a double-reference. Prefer `Atom` or `&str` instead to avoid indirection.
2024-06-22 04:48:00 +00:00
rzvxa
4bd2c882d3 fix(linter): fix and promote getter-return to correctness. (#3777)
I had to rewrite some parts of this rule so now it uses a set dfs. It is arguably a little bit slower than before but it is less prone to false negatives.

closes #2312

[oxlint-ecosystem-ci](https://github.com/oxc-project/oxlint-ecosystem-ci/actions/runs/9586832129/job/26435575457?pr=16)
2024-06-20 01:27:07 +00:00
rzvxa
1190dee47f fix(linter): false positives with setters in the getter-return rule. (#3714)
related but won't close #2312

[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9547942249/job/26314030884)
2024-06-19 14:45:06 +00:00
rzvxa
887da40518 test(linter): enable no-fallthrough test with disable-next-line. (#3766)
I thought we didn't have this, But now that I've read the `LintContext` I have realized it wasn't true.
2024-06-19 13:24:21 +00:00
rzvxa
4d2b7f1227 refactor(linter): LintContext can now only be constructed with a cfg enabled semantic. (#3761)
It has the same spirit as #3747 but with a much simpler approach. I've used the fact that @Boshen mentioned about linter always using CFG so now we assert `semantic.cfg().is_some()` in the `LintContext::new` because of this assertion we can have a `LintContext::cfg` that unwraps unchecked.
Eliminates unnecessary checks in our hot paths.

It has the best of both worlds, No complicated typing yet we still get the CFG as a non-optional value without extra ASM or branching.
2024-06-19 13:01:33 +00:00
Boshen
3d0693f4d4 chore(linter): regenerate snapshot (#3758) 2024-06-19 09:33:04 +00:00
Boshen
4e9d8a5585
chore: fix some nightly clippy warnings 2024-06-19 00:53:58 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt 2024-06-19 00:48:30 +08:00
rzvxa
256acc949b
chore(semantic)!: no longer generate CFG by default. (#3738)
related but won't close #3641
2024-06-19 00:13:29 +08:00
rzvxa
d8ad321687 refactor(semantic): make control flow generation optional. (#3737)
For maximum backward compatibility, we generate CFG by default.

Note: It can't be done with a simple method since lifetimes make it impossible(at least without unsafe trickery) I've tried to do it without a macro but it was just unintuitive.
2024-06-18 15:59:38 +00:00
rzvxa
0537d298db refactor(cfg)!: move control flow to its own crate. (#3728) 2024-06-18 15:59:29 +00:00
Boshen
5c38a0fd69 feat(codegen)!: new code gen API (#3740)
This PR introduces two type alias to avoid the confusing const generic `pub struct Codegen<'a, const MINIFY: bool>`

* CodeGenerator - Code generator without whitespace removal.
* WhitespaceRemover - Code generator with whitespace removal.

Usage is changed to a builder pattern:

```rust
CodeGenerator::new()
  .enable_comment(...)
  .enable_sourcemap(...)
  .build(&program);
```
2024-06-18 15:50:12 +00:00
rzvxa
4bce59df68 refactor(semantic/cfg)!: re-export petgraph as control_flow::graph. (#3722)
So we can replace or extend it easily.
2024-06-17 14:16:55 +00:00
rzvxa
080ecbd88d feat(linter): add no-fallthrough. (#3673)
[no-fallthrough](https://eslint.org/docs/latest/rules/no-fallthrough)

[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9546510803)

related to #633 and closes #597
also related to #3662
2024-06-17 11:50:24 +00:00
Boshen
982e6f08df chore: make println and eprintln opt-in (#3712)
I noticed accidental `println` can be merged, which isn't really nice.
2024-06-17 10:40:34 +00:00
mysteryven
9493fbef2c feat(linter): add oxc/no-optional-chaining rule (#3700)
To support: https://github.com/vuejs/core/pull/10919
2024-06-17 08:28:49 +00:00
mysteryven
139adfe7cb feat(linter): add @typescript-eslint/no-import-type-side_effects (#3699) 2024-06-17 08:25:20 +00:00
Boshen
de0690f2e5
fix(linter): do not run getter-return in typescript (#3693) 2024-06-15 23:44:37 +08:00
rzvxa
cf71c23d93 fix(linter): edge case with infinite loops. (#3672)
closes #3663 this time for real😅

browser search doesn't work in the GitHub actions (because of the partial rendering I guess) I had to use GitHub's own log search to see all instances related to this rule.

[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9512820948)
2024-06-14 08:37:16 +00:00
rzvxa
abd6ac8811 fix(semantic/cfg): discrete finalization path after NewFunctions. (#3671)
closes #3668

[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9512489987/job/26220576138)

For this code:

```js
function f() {
    try {
        return a();
    }
    catch (err) {
        throw new class CustomError extends Error {
            constructor() {
                super(err);
            }
        };
    }
    finally {
        this.b();
    }
}

```

We went from this:
![image](https://github.com/oxc-project/oxc/assets/3788964/bcb751aa-50cf-4c0a-8975-e01697ff78b2)

To this:
![Screenshot 2024-06-14 110805](https://github.com/oxc-project/oxc/assets/3788964/03a03525-5326-47b1-8d6c-69720f7f3149)
2024-06-14 08:32:02 +00:00
Boshen
67e0d3077a
chore(linter): add description to website rules generator (#3670) 2024-06-14 15:32:23 +08:00
github-actions[bot]
6168969f94
Release oxlint v0.4.4 (#3669)
## [0.4.4] - 2024-06-14

### Features

- 8f5655d linter: Add eslint/no-useless-constructor (#3594) (Don Isaac)
- 29c78db linter: Implement
@typescript-eslint/explicit-function-return-type (#3455) (kaykdm)
- 21d3425 linter: Typescript-eslint no-useless-empty-export (#3605)
(keita hino)
- 85c3b83 linter: Eslint-plugin-jest/max-nested-describes (#3585)
(cinchen)
- f6d9ca6 linter: Add `eslint/sort-imports` rule (#3568) (Wang Wenzhe)
- 046ff3f linter/eslint: Add `no_unreachable` rule. (#3238) (rzvxa)
- e32ce00 linter/jsdoc: Implement require-param-name rule (#3636) (Yuji
Sugiura)
- 110661c linter/jsdoc: Implement require-param-description (#3621)
(Yuji Sugiura)
- d6370f1 linter/jsdoc: Implement require-param-type rule (#3601) (Yuji
Sugiura)
- d9c5b33 semantic/cfg: Add `Condition` instruction. (#3567) (Ali
Rezvani)
- f2dfd66 semantic/cfg: Add iteration instructions. (#3566) (rzvxa)

### Bug Fixes

- f0b689d linter: Panic in jsdoc/require-param (#3590) (Don Isaac)
- e148a32 semantic/cfg: Correct unreachability propagation in
try-finally. (#3667) (Ali Rezvani)

### Refactor

- 84304b4 linter: Add a `ctx.module_record()` method (#3637) (Boshen)
- f98f777 linter: Add rule fixer (#3589) (Don Isaac)
- fa11644 linter: Pass `Rc` by value (#3587) (overlookmotel)
- f702fb9 semantic/cfg: Cleanup control flow and it's builder. (#3650)
(rzvxa)
- 5793ff1 transformer: Replace `&’a Trivias` with `Rc<Trivias>` (#3580)
(Dunqing)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-14 15:05:26 +08:00
Ali Rezvani
e148a32ce3
fix(semantic/cfg): correct unreachability propagation in try-finally. (#3667)
closes #3663


[oxlint-ecosystem-ci](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9511509383/job/26217870705)

From this:

![Screenshot 2024-06-14
092916](https://github.com/oxc-project/oxc/assets/3788964/9e6a9a01-984a-4a19-8a73-abc3b71fb9c2)

To this:

![Screenshot 2024-06-14
092852](https://github.com/oxc-project/oxc/assets/3788964/46483bc2-a227-4416-b8da-07b11ab96990)

Since try-finally (without a catch) wouldn't join after finalization.
2024-06-14 14:39:20 +08:00
Boshen
c7c22b70eb
chore(linter): fix whitespace in no-useless-constructor 2024-06-14 13:32:32 +08:00
Boshen
d92bb3a0c3
chore(linter): move no-useless-constructor to nursery 2024-06-14 13:21:38 +08:00
Boshen
ce6cacc85a
chore(linter): move no-unreachable to nursery 2024-06-14 13:13:10 +08:00
renovate
c1b34ff011 chore(deps): update dependency rust to v1.79.0 (#3661)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rust](https://togithub.com/rust-lang/rust) | minor | `1.78.0` -> `1.79.0` |

---

### Release Notes

<details>
<summary>rust-lang/rust (rust)</summary>

### [`v1.79.0`](https://togithub.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1790-2024-06-13)

[Compare Source](https://togithub.com/rust-lang/rust/compare/1.78.0...1.79.0)

\==========================

<a id="1.79.0-Language"></a>

## Language

-   [Stabilize inline `const {}` expressions.](https://togithub.com/rust-lang/rust/pull/104087/)
-   [Prevent opaque types being instantiated twice with different regions within the same function.](https://togithub.com/rust-lang/rust/pull/116935/)
-   [Stabilize WebAssembly target features that are in phase 4 and 5.](https://togithub.com/rust-lang/rust/pull/117457/)
-   [Add the `redundant_lifetimes` lint to detect lifetimes which are semantically redundant.](https://togithub.com/rust-lang/rust/pull/118391/)
-   [Stabilize the `unnameable_types` lint for public types that can't be named.](https://togithub.com/rust-lang/rust/pull/120144/)
-   [Enable debuginfo in macros, and stabilize `-C collapse-macro-debuginfo` and `#[collapse_debuginfo]`.](https://togithub.com/rust-lang/rust/pull/120845/)
-   [Propagate temporary lifetime extension into `if` and `match` expressions.](https://togithub.com/rust-lang/rust/pull/121346/)
-   [Restrict promotion of `const fn` calls.](https://togithub.com/rust-lang/rust/pull/121557/)
-   [Warn against refining impls of crate-private traits with `refining_impl_trait` lint.](https://togithub.com/rust-lang/rust/pull/121720/)
-   [Stabilize associated type bounds (RFC 2289).](https://togithub.com/rust-lang/rust/pull/122055/)
-   [Stabilize importing `main` from other modules or crates.](https://togithub.com/rust-lang/rust/pull/122060/)
-   [Check return types of function types for well-formedness](https://togithub.com/rust-lang/rust/pull/115538)
-   [Rework `impl Trait` lifetime inference](https://togithub.com/rust-lang/rust/pull/116891/)
-   [Change inductive trait solver cycles to be ambiguous](https://togithub.com/rust-lang/rust/pull/122791)

<a id="1.79.0-Compiler"></a>

## Compiler

-   [Define `-C strip` to only affect binaries, not artifacts like `.pdb`.](https://togithub.com/rust-lang/rust/pull/115120/)
-   [Stabilize `-Crelro-level` for controlling runtime link hardening.](https://togithub.com/rust-lang/rust/pull/121694/)
-   [Stabilize checking of `cfg` names and values at compile-time with `--check-cfg`.](https://togithub.com/rust-lang/rust/pull/123501/)
    *Note that this only stabilizes the compiler part, the Cargo part is still unstable in this release.*
-   [Add `aarch64-apple-visionos` and `aarch64-apple-visionos-sim` tier 3 targets.](https://togithub.com/rust-lang/rust/pull/121419/)
-   [Add `riscv32ima-unknown-none-elf` tier 3 target.](https://togithub.com/rust-lang/rust/pull/122696/)
-   [Promote several Windows targets to tier 2](https://togithub.com/rust-lang/rust/pull/121712): `aarch64-pc-windows-gnullvm`, `i686-pc-windows-gnullvm`, and `x86_64-pc-windows-gnullvm`.

Refer to Rust's \[platform support page]\[platform-support-doc]
for more information on Rust's tiered platform support.

<a id="1.79.0-Libraries"></a>

## Libraries

-   [Implement `FromIterator` for `(impl Default + Extend, impl Default + Extend)`.](https://togithub.com/rust-lang/rust/pull/107462/)
-   [Implement `{Div,Rem}Assign<NonZero<X>>` on `X`.](https://togithub.com/rust-lang/rust/pull/121952/)
-   [Document overrides of `clone_from()` in core/std.](https://togithub.com/rust-lang/rust/pull/122201/)
-   [Link MSVC default lib in core.](https://togithub.com/rust-lang/rust/pull/122268/)
-   [Caution against using `transmute` between pointers and integers.](https://togithub.com/rust-lang/rust/pull/122379/)
-   [Enable frame pointers for the standard library.](https://togithub.com/rust-lang/rust/pull/122646/)

<a id="1.79.0-Stabilized-APIs"></a>

## Stabilized APIs

-   [`{integer}::unchecked_add`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_add)
-   [`{integer}::unchecked_mul`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_mul)
-   [`{integer}::unchecked_sub`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_sub)
-   [`<[T]>::split_at_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_unchecked)
-   [`<[T]>::split_at_mut_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_mut_unchecked)
-   [`<[u8]>::utf8_chunks`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.utf8\_chunks)
-   [`str::Utf8Chunks`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunks.html)
-   [`str::Utf8Chunk`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunk.html)
-   [`<*const T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned)
-   [`<*mut T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned-1)
-   [`NonNull::is_aligned`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_aligned)
-   [`<*const [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len)
-   [`<*mut [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len-1)
-   [`<*const [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty)
-   [`<*mut [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty-1)
-   [`NonNull::<[T]>::is_empty`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_empty)
-   [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes)
-   [`io::Error::downcast`](https://doc.rust-lang.org/stable/std/io/struct.Error.html#method.downcast)
-   [`num::NonZero<T>`](https://doc.rust-lang.org/stable/core/num/struct.NonZero.html)
-   [`path::absolute`](https://doc.rust-lang.org/stable/std/path/fn.absolute.html)
-   [`proc_macro::Literal::byte_character`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.byte_character)
-   [`proc_macro::Literal::c_string`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.c_string)

These APIs are now stable in const contexts:

-   [`Atomic*::into_inner`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicUsize.html#method.into_inner)
-   [`io::Cursor::new`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.new)
-   [`io::Cursor::get_ref`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.get_ref)
-   [`io::Cursor::position`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.position)
-   [`io::empty`](https://doc.rust-lang.org/stable/std/io/fn.empty.html)
-   [`io::repeat`](https://doc.rust-lang.org/stable/std/io/fn.repeat.html)
-   [`io::sink`](https://doc.rust-lang.org/stable/std/io/fn.sink.html)
-   [`panic::Location::caller`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.caller)
-   [`panic::Location::file`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.file)
-   [`panic::Location::line`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.line)
-   [`panic::Location::column`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.column)

<a id="1.79.0-Cargo"></a>

## Cargo

-   [Prevent dashes in `lib.name`, always normalizing to `_`.](https://togithub.com/rust-lang/cargo/pull/12783/)
-   [Stabilize MSRV-aware version requirement selection in `cargo add`.](https://togithub.com/rust-lang/cargo/pull/13608/)
-   [Switch to using `gitoxide` by default for listing files.](https://togithub.com/rust-lang/cargo/pull/13696/)
-   [Error on `[project]` in Edition 2024; `cargo fix --edition` will change it to `[package]`.](https://togithub.com/rust-lang/cargo/pull/13747/)

<a id="1.79.0-Rustdoc"></a>

## Rustdoc

-   [Always display stability version even if it's the same as the containing item.](https://togithub.com/rust-lang/rust/pull/118441/)
-   [Show a single search result for items with multiple paths.](https://togithub.com/rust-lang/rust/pull/119912/)
-   [Support typing `/` in docs to begin a search.](https://togithub.com/rust-lang/rust/pull/123355/)

<a id="1.79.0-Misc"></a>

## Misc

<a id="1.79.0-Compatibility-Notes"></a>

## Compatibility Notes

-   [Update the minimum external LLVM to 17.](https://togithub.com/rust-lang/rust/pull/122649/)
-   [`RustcEncodable` and `RustcDecodable` are soft-destabilized, to be removed
    from the prelude in next edition.](https://togithub.com/rust-lang/rust/pull/116016/)
-   [The `wasm_c_abi` future-incompatibility lint will warn about use of the
    non-spec-compliant C ABI.](https://togithub.com/rust-lang/rust/pull/117918/)
    Use `wasm-bindgen v0.2.88` to generate forward-compatible bindings.
-   [Check return types of function types for well-formedness](https://togithub.com/rust-lang/rust/pull/115538)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
2024-06-14 02:28:06 +00:00
rzvxa
f702fb91ee refactor(semantic/cfg): cleanup control flow and it's builder. (#3650)
Removed remaining parts of the old CFG implementation and some cleanups here and there.
2024-06-13 09:37:49 +00:00
rzvxa
046ff3fdfb feat(linter/eslint): add no_unreachable rule. (#3238)
closes #621
[no-unreachable](069aa680c7/lib/rules/no-unreachable.js (L196))

[oxlint-echosystem-ci result](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9406195143/job/25909079029)

This rule is done but since it is running for every possible statement and does quite a bit of work on them to determine whether it is 100% reachable or not; The performance in my opinion is kind of abysmal.

I'll try to work it out, I know Biome does 2 types of checks to simplify the rule for some nodes, However, they have a lot more false negatives than our implementation.

##### Here is one example of those [false negatives](https://biomejs.dev/playground/?code=ZgB1AG4AYwB0AGkAbwBuACAAeAAoACkAIAB7ACAAZABvACAAewAgAGEAKAApADsAIAB9ACAAdwBoAGkAbABlACgAdAByAHUAZQApADsAIABiACgAKQA7ACAAfQA%3D)

-------------

### Update 1:

I've benchmarked this rule using only the simplified reachability checks and it was around 5% faster, To be honest, it isn't much improvement especially considering that we can only use this check for a small portion of nodes and even that is accompanied by newly introduced checks which would lessen the amount of performance gain further.

Most of the performance regression is because of allocations during our depth first search since we have to store both the visited and finished nodes which results in a bunch of rapid-fire allocations back to back. Currently, At the moment I don't have a great idea of how to improve it, We may have to implement our own graph to use arenas underneath.

Given that this rule is the most extensive use case of control flow (It doesn't come with a limited scope similar to property and constructor rules already implemented) this performance drop might be reasonable to some extent.

------------

### Update 2:

I reworked my approach in 2 senses, First I used @Boshen's suggestion inspired by TypeScript and kept some of the reachability information in the basic block structure instead of calculating it on the fly. It is done by propagating the `Unreachable` edge and `Unreachable` instruction throughout subgraphs.

This for sure helped with the performance but the next part is what never failed to amaze me, Going from something near `O(n!)` in the worst-case scenario to `O(n^2)` (in the worst-case scenario). By changing the approach instead of checking the reachability of each statement we do it in 3 paths; First, we do a path on the entire CFG and query all reachable but suspicious cases, and then we do another path on each of these suspicions subgraphs to determine the reachability with higher confidence. Finally, we iterate all of the appropriate nodes and check their reachability status according to the information collected in 2 previous paths.

With these 2 this rule went from `-24%` to `~-2%`.

This performance gain doesn't come for free though; It increases the likelihood of false positives/negatives, But as long as we are passing our `ecosystem-ci` it should be fine. We can always sacrifice some performance to check for edge cases if there are any.

[new oxlint-echosystem-ci result](https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9490791181)
2024-06-13 09:37:45 +00:00
Ali Rezvani
d9c5b33394
feat(semantic/cfg): add Condition instruction. (#3567) 2024-06-13 16:17:24 +08:00
rzvxa
f2dfd667df feat(semantic/cfg): add iteration instructions. (#3566) 2024-06-13 07:36:20 +00:00
rzvxa
9b3097147e improvement(semantic/cfg): rework error path. (#3519)
This PR aims to provide a more accurate error/finalization flow, I've nuked the old error path approach and rewrote it with more versatility in mind.

We used to visit the finalizer block twice and create 2 sets of AstNodes/Basic Blocks for them, This was there to differentiate between the error path finalizer and success path one. There is no longer a need for having 2 separate sets of nodes to do this differentiation.

As for the error path now we have 2 kinds of them, Everything is attached to an error block - even if it is not in a try-catch statement - this results in a lot of extra edges to keep track of these "Implicit" error blocks but I believe in future it can help us to track cross block error paths, For example, we can dynamically attach and cache the implicit error block of a function to its call site error path (either implicit or explicit).
2024-06-13 07:36:16 +00:00
Boshen
1edcd87203
chore: change all usages of static_assertions to dev-dependencies (#3654) 2024-06-13 13:18:53 +08:00
Don Isaac
8f5655dfe6
feat(linter): add eslint/no-useless-constructor (#3594)
Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-13 13:12:18 +08:00
kaykdm
29c78db358
feat(linter): implement @typescript-eslint/explicit-function-return-type (#3455)
Related issue: https://github.com/oxc-project/oxc/issues/2180

original implementation

- code:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/explicit-function-return-type.ts
- test:
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts
- doc: https://typescript-eslint.io/rules/explicit-function-return-type/

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-12 16:45:02 +08:00
Boshen
b58d8eb88f fix!(codegen): remove the unecessary 4th argument from Codegen::new (#3640) 2024-06-12 07:58:54 +00:00
Boshen
d77ec9f95a
chore: remove trailing whitespaces for all files; add .editorconfig (#3639) 2024-06-12 15:47:26 +08:00
Boshen
f6752b482f
feat!(ast): make Trivias clonable by adding Arc (#3638)
This makes `Trivias` cloneable and stops us from using `Rc::new` and
`Rc::clone` everywhere.

`Trivias` is rarely cloned so an `Arc` should suffice.
2024-06-12 13:16:10 +08:00
Boshen
84304b4f8f refactor(linter): add a ctx.module_record() method (#3637) 2024-06-12 04:32:38 +00:00
keita hino
21d3425db0
feat(linter): typescript-eslint no-useless-empty-export (#3605)
partof: #2180

docs: https://typescript-eslint.io/rules/no-useless-empty-export/
code:
584db29ec4/packages/eslint-plugin/src/rules/no-useless-empty-export.ts
test:
ac397f1817/packages/eslint-plugin/tests/rules/no-useless-empty-export.test.ts

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-12 12:05:38 +08:00
Yuji Sugiura
e32ce00bfb
feat(linter/jsdoc): Implement require-param-name rule (#3636)
Part of #1170 

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-name.md
2024-06-12 10:55:37 +08:00
cinchen
85c3b83f5f
feat(linter): eslint-plugin-jest/max-nested-describes (#3585)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/max-nested-describe.ts)
2024-06-11 20:13:31 +08:00
Boshen
0654400cfa
chore(linter): fix clippy 2024-06-11 16:52:02 +08:00
Boshen
b3d4a53396
chore(linter): fix merge conflict 2024-06-11 16:43:11 +08:00
Yuji Sugiura
110661cc80
feat(linter/jsdoc): Implement require-param-description (#3621)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-description.md
2024-06-11 16:31:53 +08:00
Wang Wenzhe
f6d9ca6e47
feat(linter): add eslint/sort-imports rule (#3568)
Rule detail: https://eslint.org/docs/latest/rules/sort-imports
2024-06-11 16:31:14 +08:00
Dunqing
5793ff1986
refactor(transformer): replace &’a Trivias with Rc<Trivias> (#3580)
`Transformer` needs to borrow `Trivias`.
8be1cc8052 (r1630711060)
2024-06-11 13:23:41 +08:00
Yuji Sugiura
d6370f19fe
feat(linter/jsdoc): Implement require-param-type rule (#3601)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-type.md
2024-06-10 17:23:41 +08:00
Don Isaac
f98f7771d8
refactor(linter): add rule fixer (#3589)
Adds a new `RuleFixer` struct that gets passed to
`ctx.diagnostic_with_fix`.
2024-06-10 17:20:14 +08:00
Don Isaac
f0b689d115
fix(linter): panic in jsdoc/require-param (#3590) 2024-06-08 18:44:22 -04:00
overlookmotel
fa116448c9 refactor(linter): pass Rc by value (#3587)
Same as #3586.
2024-06-08 11:19:02 +00:00
Boshen
060819894d
chore: crates should only publish src and examples directory 2024-06-08 16:35:16 +08:00
Don Isaac
3e694573df
up(linter): add fixer for no-useless-spread (#3583)
Only fixes array spreads for now.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-08 11:38:38 +08:00
github-actions[bot]
8cbf937e84
Release oxlint v0.4.3 (#3581)
## [0.4.3] - 2024-06-07

### Features

- 1fb9d23 linter: Add fixer for no-useless-fallback-in-spread rule
(#3544) (Don Isaac)
- 6506d08 linter: Add fixer for no-single-promise-in-promise-methods
(#3531) (Don Isaac)
- daf559f linter: Eslint-plugin-jest/no-large-snapshot (#3436) (cinchen)
- 4c17bc6 linter: Eslint/no-constructor-return (#3321) (谭光志)
- 4a075cc linter/jsdoc: Implement require-param rule (#3554) (Yuji
Sugiura)
- 747500a linter/jsdoc: Implement require-returns-type rule (#3458)
(Yuji Sugiura)
- 6b39654 linter/tree-shaking: Support options (#3504) (Wang Wenzhe)
- 0cdb45a oxc_codegen: Preserve annotate comment (#3465)
(IWANABETHATGUY)

### Bug Fixes

- b188778 linter/eslint: Fix `require-await` false positives in
`ForOfStatement`. (#3457) (rzvxa)
- 350cd91 parser: Should parser error when function declaration has no
name (#3461) (Dunqing)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
2024-06-07 16:39:51 +08:00
Yuji Sugiura
4a075cccd6
feat(linter/jsdoc): Implement require-param rule (#3554)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md

NOTE: `config.useDefaultObjectProperties` is not implemented for now.
2024-06-07 15:58:16 +08:00
Boshen
1dbc23417d
chore: regenerate changelogs with commit id and author 2024-06-07 01:22:28 +08:00
Boshen
7ddd3a6d11
chore: change no-constructor-return to pedantic 2024-06-07 00:13:47 +08:00
rzvxa
60f89d1fcf improvement(semantic/cfg): better throw control flow. (#3473)
https://github.com/rzvxa/oxlint-ecosystem-ci/actions/runs/9306698136
2024-06-06 07:55:50 +00:00
rzvxa
987a3f36a8 improvement(linter/react): use CFG for detecting cyclic subgraphs in rules-of-hooks. (#3454) 2024-06-06 07:55:44 +00:00
rzvxa
61bae74f76 improvement(semantic/cfg): better CFG API (#3472) 2024-06-06 07:55:37 +00:00
rzvxa
3c7ee85ce4 improvement(semantic/cfg): better break and continue flow. (#3462)
This PR adds a new edge type called `Jump` to distinguish between normal edges and jumps.
There is also a control flow context which is used to keep track of cfg scopes and labels. It replaces the old `preserve_state` and `restore_state`.
It corrects some mistakes - such as labeled blocks especially labeled continue which wasn't easy to implement with the old approach - in the old control flow but other than that it is mostly refactored to have a more declarative API instead of a procedural approach.
2024-06-06 07:55:31 +00:00
Boshen
769227b7b4
chore: regenerate changelogs 2024-06-06 15:51:53 +08:00
Boshen
509ed2bcf3
ci: update prepare release crates; regenerate the changelogs 2024-06-06 14:28:51 +08:00
Yuji Sugiura
747500ac5a
feat(linter/jsdoc): Implement require-returns-type rule (#3458)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md
2024-06-06 14:11:39 +08:00
Don Isaac
1fb9d234a6
feat(linter): add fixer for no-useless-fallback-in-spread rule (#3544) 2024-06-06 13:59:42 +08:00
rzvxa
209a99d49f improvement(semantic/cfg): rework basic blocks. (#3381)
I've replaced the `BasicBlockElement` with an `Instruction` type which would keep both the instruction kind and its associated AstNodeId.
I also removed the register scheme in the control flow in favor of a simpler approach using explicit enums.

https://github.com/oxc-project/oxc/pull/3381#issuecomment-2126622774
2024-06-06 05:41:01 +00:00
Don Isaac
6506d086b3
feat(linter): add fixer for no-single-promise-in-promise-methods (#3531)
Fixes look like this:

```rs
let fix = vec![
    ("Promise.all([null]).then()", "Promise.resolve(null).then()", None),
    ("let x = await Promise.all([foo()])", "let x = await foo()", None),
    ("let x = await (Promise.all([foo()]))", "let x = await (foo())", None),
];
```

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-06 01:40:03 +08:00
Boshen
0674604d7a
chore: regenerate changelog 2024-06-06 01:29:38 +08:00
Wang Wenzhe
6b39654c80
feat(linter/tree-shaking): support options (#3504) 2024-06-03 11:28:48 +08:00
cinchen
daf559f06f
feat(linter): eslint-plugin-jest/no-large-snapshot (#3436)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/no-large-snapshots.ts)

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-06-02 22:58:28 +08:00
Dunqing
350cd9158a
fix(parser): should parser error when function declaration has no name (#3461)
https://oxc-project.github.io/oxc/playground/?code=3YCAAICNgICAgICAgICzncl%2FKeF7k4Y7upgY2l43c79%2FYxaAgA%3D%3D
2024-05-30 19:58:50 +08:00
谭光志
4c17bc6f53
feat(linter): eslint/no-constructor-return (#3321) 2024-05-30 09:06:17 +00:00
IWANABETHATGUY
0cdb45a1ff
feat(oxc_codegen): preserve annotate comment (#3465)
1. Copy tests from
efa3dd2d8e/internal/bundler_tests/bundler_dce_test.go (L3833-L3971)
2. Add option to preserve annotate comment like `/* #__NO_SIDE_EFFECTS__
*/` and `/* #__PURE__ */`
2024-05-30 15:25:23 +08:00
rzvxa
b1887782ac fix(linter/eslint): fix require-await false positives in ForOfStatement. (#3457)
closes #3456
2024-05-28 17:58:31 +00:00
Wang Wenzhe
e275659cdc
feat(linter): add oxc/no-rest-spread-properties rule (#3432)
People open this rule may have some specific purpose, I am deliberating
about whether to add a custom message.
2024-05-28 15:04:17 +00:00
Wang Wenzhe
0d2c977c11
feat(linter): add oxc/no-const-enum rule (#3435) 2024-05-28 22:50:54 +08:00
Wang Wenzhe
085f91761c
feat(linter): add oxc/no-async-await rule (#3438) 2024-05-28 21:31:56 +08:00
cinchen
ded59bc35b
feat(linter): eslint-plugin-jest/require-top-level-describe (#3439)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/require-top-level-describe.ts)

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-05-28 21:23:16 +08:00
cinchen
edaa555620
feat(linter): eslint-plugin-jest/prefer-hooks-on-top (#3437)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/prefer-hooks-on-top.ts)
2024-05-28 20:42:14 +08:00
Jelle van der Waa
b589fd612f
feat(linter/eslint): Implement no-div-regex (#3442)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/no-div-regex)
2024-05-28 09:13:11 +08:00
renovate[bot]
ea0d57f944
chore(deps): lock file maintenance rust crates (#3422)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|  |  | lockFileMaintenance | All locks refreshed |
| [insta](https://insta.rs/)
([source](https://togithub.com/mitsuhiko/insta)) |
workspace.dependencies | minor | `1.38.0` -> `1.39.0` |
| [itertools](https://togithub.com/rust-itertools/itertools) |
workspace.dependencies | minor | `0.12.1` -> `0.13.0` |
| [mimalloc](https://togithub.com/purpleprotocol/mimalloc_rust) |
workspace.dependencies | patch | `0.1.41` -> `0.1.42` |
| [napi-derive](https://togithub.com/napi-rs/napi-rs) |
workspace.dependencies | patch | `2.16.4` -> `2.16.5` |
| [ouroboros](https://togithub.com/someguynamedjosh/ouroboros) |
workspace.dependencies | patch | `0.18.3` -> `0.18.4` |
| [proc-macro2](https://togithub.com/dtolnay/proc-macro2) |
workspace.dependencies | patch | `1.0.82` -> `1.0.84` |
| [serde](https://serde.rs)
([source](https://togithub.com/serde-rs/serde)) | workspace.dependencies
| patch | `1.0.201` -> `1.0.203` |
| [trybuild](https://togithub.com/dtolnay/trybuild) |
workspace.dependencies | patch | `1.0.95` -> `1.0.96` |

🔧 This Pull Request updates lock files to use the latest dependency
versions.

---

### Release Notes

<details>
<summary>mitsuhiko/insta (insta)</summary>

###
[`v1.39.0`](https://togithub.com/mitsuhiko/insta/blob/HEAD/CHANGELOG.md#1390)

[Compare
Source](https://togithub.com/mitsuhiko/insta/compare/1.38.0...1.39.0)

- Fixed a bug in `require_full_match`.
[#&#8203;485](https://togithub.com/mitsuhiko/insta/issues/485)

- Fixed a bug that caused snapshot and module names to sometimes be
inaccurate.
[#&#8203;483](https://togithub.com/mitsuhiko/insta/issues/483)

- Insta will no longer error when removing snapshots that were already
removed. [#&#8203;484](https://togithub.com/mitsuhiko/insta/issues/484)

- Added support for trailing commas in inline snapshots.
[#&#8203;472](https://togithub.com/mitsuhiko/insta/issues/472)

- Don't pass `--color` in all cases to `libtest` any more to work around
limitations
with custom test harnesses.
[#&#8203;491](https://togithub.com/mitsuhiko/insta/issues/491)

</details>

<details>
<summary>rust-itertools/itertools (itertools)</summary>

###
[`v0.13.0`](https://togithub.com/rust-itertools/itertools/blob/HEAD/CHANGELOG.md#0130)

[Compare
Source](https://togithub.com/rust-itertools/itertools/compare/v0.12.1...v0.13.0)

##### Breaking

- Removed implementation of `DoubleEndedIterator` for `ConsTuples`
([#&#8203;853](https://togithub.com/rust-itertools/itertools/issues/853))
- Made `MultiProduct` fused and fixed on an empty iterator
([#&#8203;835](https://togithub.com/rust-itertools/itertools/issues/835),
[#&#8203;834](https://togithub.com/rust-itertools/itertools/issues/834))
- Changed `iproduct!` to return tuples for maxi one iterator too
([#&#8203;870](https://togithub.com/rust-itertools/itertools/issues/870))
- Changed `PutBack::put_back` to return the old value
([#&#8203;880](https://togithub.com/rust-itertools/itertools/issues/880))
- Removed deprecated `repeat_call, Itertools::{foreach, step,
map_results, fold_results}`
([#&#8203;878](https://togithub.com/rust-itertools/itertools/issues/878))
- Removed `TakeWhileInclusive::new`
([#&#8203;912](https://togithub.com/rust-itertools/itertools/issues/912))

##### Added

- Added `Itertools::{smallest_by, smallest_by_key, largest, largest_by,
largest_by_key}`
([#&#8203;654](https://togithub.com/rust-itertools/itertools/issues/654),
[#&#8203;885](https://togithub.com/rust-itertools/itertools/issues/885))
- Added `Itertools::tail`
([#&#8203;899](https://togithub.com/rust-itertools/itertools/issues/899))
- Implemented `DoubleEndedIterator` for `ProcessResults`
([#&#8203;910](https://togithub.com/rust-itertools/itertools/issues/910))
- Implemented `Debug` for `FormatWith`
([#&#8203;931](https://togithub.com/rust-itertools/itertools/issues/931))
- Added `Itertools::get`
([#&#8203;891](https://togithub.com/rust-itertools/itertools/issues/891))

##### Changed

- Deprecated `Itertools::group_by` (renamed `chunk_by`)
([#&#8203;866](https://togithub.com/rust-itertools/itertools/issues/866),
[#&#8203;879](https://togithub.com/rust-itertools/itertools/issues/879))
- Deprecated `unfold` (use `std::iter::from_fn` instead)
([#&#8203;871](https://togithub.com/rust-itertools/itertools/issues/871))
- Optimized `GroupingMapBy`
([#&#8203;873](https://togithub.com/rust-itertools/itertools/issues/873),
[#&#8203;876](https://togithub.com/rust-itertools/itertools/issues/876))
- Relaxed `Fn` bounds to `FnMut` in `diff_with,
Itertools::into_group_map_by`
([#&#8203;886](https://togithub.com/rust-itertools/itertools/issues/886))
- Relaxed `Debug/Clone` bounds for `MapInto`
([#&#8203;889](https://togithub.com/rust-itertools/itertools/issues/889))
- Documented the `use_alloc` feature
([#&#8203;887](https://togithub.com/rust-itertools/itertools/issues/887))
- Optimized `Itertools::set_from`
([#&#8203;888](https://togithub.com/rust-itertools/itertools/issues/888))
- Removed badges in `README.md`
([#&#8203;890](https://togithub.com/rust-itertools/itertools/issues/890))
- Added "no-std" categories in `Cargo.toml`
([#&#8203;894](https://togithub.com/rust-itertools/itertools/issues/894))
- Fixed `Itertools::k_smallest` on short unfused iterators
([#&#8203;900](https://togithub.com/rust-itertools/itertools/issues/900))
- Deprecated `Itertools::tree_fold1` (renamed `tree_reduce`)
([#&#8203;895](https://togithub.com/rust-itertools/itertools/issues/895))
- Deprecated `GroupingMap::fold_first` (renamed `reduce`)
([#&#8203;902](https://togithub.com/rust-itertools/itertools/issues/902))
- Fixed `Itertools::k_smallest(0)` to consume the iterator, optimized
`Itertools::k_smallest(1)`
([#&#8203;909](https://togithub.com/rust-itertools/itertools/issues/909))
- Specialized `Combinations::nth`
([#&#8203;914](https://togithub.com/rust-itertools/itertools/issues/914))
- Specialized `MergeBy::fold`
([#&#8203;920](https://togithub.com/rust-itertools/itertools/issues/920))
- Specialized `CombinationsWithReplacement::nth`
([#&#8203;923](https://togithub.com/rust-itertools/itertools/issues/923))
- Specialized `FlattenOk::{fold, rfold}`
([#&#8203;927](https://togithub.com/rust-itertools/itertools/issues/927))
- Specialized `Powerset::nth`
([#&#8203;924](https://togithub.com/rust-itertools/itertools/issues/924))
- Documentation fixes
([#&#8203;882](https://togithub.com/rust-itertools/itertools/issues/882),
[#&#8203;936](https://togithub.com/rust-itertools/itertools/issues/936))
- Fixed `assert_equal` for iterators longer than `i32::MAX`
([#&#8203;932](https://togithub.com/rust-itertools/itertools/issues/932))
- Updated the `must_use` message of non-lazy `KMergeBy` and
`TupleCombinations`
([#&#8203;939](https://togithub.com/rust-itertools/itertools/issues/939))

##### Notable Internal Changes

- Tested iterator laziness
([#&#8203;792](https://togithub.com/rust-itertools/itertools/issues/792))
- Created `CONTRIBUTING.md`
([#&#8203;767](https://togithub.com/rust-itertools/itertools/issues/767))

</details>

<details>
<summary>purpleprotocol/mimalloc_rust (mimalloc)</summary>

###
[`v0.1.42`](https://togithub.com/purpleprotocol/mimalloc_rust/releases/tag/v0.1.42):
Version 0.1.42

[Compare
Source](https://togithub.com/purpleprotocol/mimalloc_rust/compare/v0.1.41...v0.1.42)

##### Changes

-   MiMalloc `v2.1.6`
- Expose `usable_size` and `version`. Credits
[@&#8203;nathaniel-daniel](https://togithub.com/nathaniel-daniel).
- Link with libatomic on armv6-linux. Credits
[@&#8203;notorca](https://togithub.com/notorca).
- Add no_thp option for Linux/Android. Credits
[@&#8203;devnexen](https://togithub.com/devnexen).

</details>

<details>
<summary>napi-rs/napi-rs (napi-derive)</summary>

###
[`v2.16.5`](https://togithub.com/napi-rs/napi-rs/compare/napi-derive@2.16.4...napi-derive@2.16.5)

[Compare
Source](https://togithub.com/napi-rs/napi-rs/compare/napi-derive@2.16.4...napi-derive@2.16.5)

</details>

<details>
<summary>dtolnay/proc-macro2 (proc-macro2)</summary>

###
[`v1.0.84`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.84)

[Compare
Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.83...1.0.84)

- Documentation improvements
([#&#8203;455](https://togithub.com/dtolnay/proc-macro2/issues/455),
thanks
[@&#8203;CensoredUsername](https://togithub.com/CensoredUsername))

###
[`v1.0.83`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.83)

[Compare
Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.82...1.0.83)

- Optimize the representation of `Ident`
([#&#8203;462](https://togithub.com/dtolnay/proc-macro2/issues/462))

</details>

<details>
<summary>serde-rs/serde (serde)</summary>

###
[`v1.0.203`](https://togithub.com/serde-rs/serde/releases/tag/v1.0.203)

[Compare
Source](https://togithub.com/serde-rs/serde/compare/v1.0.202...v1.0.203)

- Documentation improvements
([#&#8203;2747](https://togithub.com/serde-rs/serde/issues/2747))

###
[`v1.0.202`](https://togithub.com/serde-rs/serde/releases/tag/v1.0.202)

[Compare
Source](https://togithub.com/serde-rs/serde/compare/v1.0.201...v1.0.202)

- Provide public access to RenameAllRules in serde_derive_internals
([#&#8203;2743](https://togithub.com/serde-rs/serde/issues/2743))

</details>

<details>
<summary>dtolnay/trybuild (trybuild)</summary>

###
[`v1.0.96`](https://togithub.com/dtolnay/trybuild/releases/tag/1.0.96)

[Compare
Source](https://togithub.com/dtolnay/trybuild/compare/1.0.95...1.0.96)

- Support Windows builds that have OUT_DIR prefixed with `\\?\`
([#&#8203;271](https://togithub.com/dtolnay/trybuild/issues/271))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Boshen <boshenc@gmail.com>
2024-05-27 01:48:50 +00:00
Boshen
19bb1c02f2 fix(website): hack schemars to render code snippet in markdown (#3417) 2024-05-26 10:36:53 +00:00
mysteryven
5e06298ec2 fix(linter): memorize visited block id in neighbors_filtered_by_edge_weight (#3407)
closes: #3396

we visit the same node too many times, I picked some result from run require-render-return rule on [timeserieseexploere.js](https://github.com/elastic/kibana/blob/main/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js)

```bash
    NodeIndex(64): 368640,
    NodeIndex(67): 737280,
    NodeIndex(70): 2949120,
    NodeIndex(73): 5971968,
    NodeIndex(76): 11943936,
    NodeIndex(43): 184320,
    NodeIndex(71): 2985984,
    NodeIndex(65): 368640,
    NodeIndex(68): 1474560,
    NodeIndex(74): 5971968,
    NodeIndex(77): 23887872,
    NodeIndex(44): 184320,
    NodeIndex(41): 73728,
    NodeIndex(35): 36864,
    NodeIndex(66): 737280,
    NodeIndex(69): 1474560,
    NodeIndex(72): 2985984,
    NodeIndex(75): 11943936,
```
2024-05-26 08:11:48 +00:00
Cameron
a61eef34a6
feat(linter) eslint-plugin-unicorn no magic array flat depth (#3411) 2024-05-26 12:16:24 +08:00
Todor Andonov
14ef4df349
feat(lint/eslint): implement require-await (#3406)
Implements https://eslint.org/docs/latest/rules/require-await.

Related to https://github.com/oxc-project/oxc/issues/479.

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-05-26 08:57:33 +08:00
Jelle van der Waa
147864cfeb
feat(linter/eslint): Implement no-useless-concat (#3363)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/no-useless-concat)

---

I haven't implemented one condition with the multiline string test case
and honestly I don't really understand why it is allowed? And also not
sure how I would implement that in oxlint.

Another issue is that maybe the output isn't great, the underlining
matches the whole BinaryExpression, for example:
```
+   ╭─[no_useless_concat.tsx:1:1]
+ 1 │ foo + `a` + `b`
+   · ───────────────
```

So maybe instead the diagnostic should get two spans passed, for each
Expression::StringLiteral or Expression::TemplateLiteral, that would
also allow the help text to show that it can be written as `"ab"`.

But an automatic fixxer would be more helpful I reckon :)

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-05-26 01:52:33 +08:00
Wang Wenzhe
5c7041bd2a
docs(linter): add docs for consistent-indexed-object-style (#3409)
I forgot to update the docs in #3126.
2024-05-25 18:34:11 +08:00
magic-akari
74b06a71da
fix(linter): Accept more valid regex (#3408)
- Closes: #3405
2024-05-25 18:33:56 +08:00
Todor Andonov
aa26ce9151
feat(linter): @typescript-eslint/consistent-indexed-object-style (#3126)
implements
https://typescript-eslint.io/rules/consistent-indexed-object-style/
2024-05-25 17:03:00 +08:00
Yuji Sugiura
b6e2d623d8
feat(linter/jsdoc): Implement require-returns-description (#3397)
Part of #1170 

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md
2024-05-24 14:09:05 +08:00
Boshen
9377a60677
chore(linter): write json schema to npm/oxlint 2024-05-24 13:28:03 +08:00
Boshen
5bf595d6f7
refactor(linter): rename variable names prefix ESLint to Oxlint 2024-05-24 12:58:27 +08:00
Boshen
ecdffcff19
feat(linter): temporary move react/require-render-return to nursery 2024-05-24 11:46:39 +08:00
mysteryven
d8c318752e refactor(linter): remove unnecessary check in eslint/no-global-assign (#3391)
Looks like we don't need check this, as unresolved references don't have `symbolId`: bb25c54b94/crates/oxc_semantic/src/builder.rs (L292-L303)
2024-05-24 02:34:18 +00:00
mysteryven
b8997f595b feat(linter): eslint/no-restricted-globals (#3390) 2024-05-24 02:30:11 +00:00
Boshen
79811ca270
feat(linter): change jsdoc/require-returns from correctness to pedantic 2024-05-24 00:13:59 +08:00
Boshen
f482ea7167
Revert "feat(linter): change jsdoc/require-render-return from correctness to pedantic"
This reverts commit 8a1db6738c.
2024-05-23 22:14:45 +08:00
Boshen
c664c6c264 fix(linter): no-new false positive when return from arrow expression (#3393) 2024-05-23 14:08:33 +00:00
Boshen
8a1db6738c
feat(linter): change jsdoc/require-render-return from correctness to pedantic 2024-05-23 21:21:27 +08:00
Jovi De Croock
fbccd1fcb2
fix(linter): only report issues on top-level fragment (#3389)
Fixes https://github.com/oxc-project/oxc/issues/3388

The snapshots were conveying this bug already on the `fail` case with
https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/react/jsx_key.rs#L410
2024-05-23 13:12:19 +00:00
Yuji Sugiura
3a5f088ca3
feat(linter/jsdoc): Implement require-returns rule (#3218)
Part of #1170

>
https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md
2024-05-23 21:12:10 +08:00
Boshen
3671b5c4d0
feat(tasks/website): code generate the linter rules 2024-05-23 15:21:37 +08:00
Boshen
ead637bf50
feat(website): generate linter configuration page 2024-05-23 12:07:17 +08:00
Boshen
57d2bcacea feat(tasks/website): start generating linter config markdown from json schema (#3386) 2024-05-22 16:09:33 +00:00
Jelle van der Waa
9744707b3b
feat(linter/eslint): Implement default_case rule (#3379)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/default-case)

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-05-22 16:49:02 +08:00
Dunqing
bb2221e4f4
fix(linter/next): false positives for non-custom font link (#3383)
fix: #3378

They only check google fonts. 

7e34b4cf98/packages/eslint-plugin-next/src/rules/no-page-custom-font.ts (L152-L154)
2024-05-22 12:01:14 +08:00
rzvxa
78e6326e48 refactor(semantic/cfg): alias petgraph's NodeIndex as BasicBlockId. (#3380)
Hides petgraph's general `NodeIndex` type behind `BasicBlockId`.
2024-05-22 03:09:38 +00:00
Boshen
fe208ddef6
feat(linter): start adding json schema for configuration file (#3375) 2024-05-22 00:35:29 +08:00
Boshen
1e84644220
chore: update toml format 2024-05-21 22:15:47 +08:00
Jelle van der Waa
74be8b146c
feat(linter/eslint): Implement no-new (#3368)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/no-new)
2024-05-21 00:28:04 +08:00
Jelle van der Waa
c588e5205c
feat(linter/eslint): Implement prefer-exponentiation-operator (#3365)
Rule Detail:

[link](https://eslint.org/docs/latest/rules/prefer-exponentiation-operator)
2024-05-20 23:04:25 +08:00
Jelle van der Waa
283d6c7bb4
feat(linter/eslint): Implement symbol-description (#3364)
Rule Detail:
[link](https://eslint.org/docs/latest/rules/symbol-description)
2024-05-20 22:51:23 +08:00
cinchen
aec613bec2
feat(linter): eslint-plugin-jest/no-duplicate-hooks (#3358)
part of https://github.com/oxc-project/oxc/issues/492

Rule Detail:
[link](https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/no-duplicate-hooks.ts)
2024-05-20 12:13:34 +08:00
mysteryven
d7849f8865 refactor(linter): find return statement by using CFG in react/require-render-return (#3353)
Maybe currently Class components are relatively few in quantity, didn't performance changed.
2024-05-19 14:59:12 +00:00
Boshen
c9d84af44e
refactor(diagnostics): s/warning/warn 2024-05-18 17:55:05 +08:00
Boshen
f13fe8a18b
feat!(linter): enforce rule severity from the cli and configuration file (#3337)
closes #2059

Breaking change:

* `--deny` / `-D` from the CLI and `error` from configuration file will
report diagnostics as severity "error".
* `--warn` / `-W` from the CLI and `warn` from configuration file will
report diagnostics as severity "warning".
2024-05-18 17:45:19 +08:00
Boshen
8388c7bd21
perf(linter): use usize for RuleEnum hash (#3336) 2024-05-18 14:12:32 +08:00
Boshen
8383b6e046 refactor(linter): remove with_rule_name from the tight loop (#3335) 2024-05-18 01:43:08 +00:00
Boshen
e4b3a3c06a feat(linter): backward compability for react-hooks and deepscan plugins (#3334)
closes #3317
2024-05-17 16:09:20 +00:00
mysteryven
a23bbf9016 fix(linter): avoid infinite loop in jest/expect-expect (#3332)
fix: #3324

I just replace `name` with a `set`, feel like this can catch more cases. And this rule needs to be [rewritten](https://github.com/oxc-project/oxc/issues/3323#issuecomment-2117623621).
2024-05-17 14:45:22 +00:00
Boshen
6c3d99a951 fix(linter/jsx-no-undef): check for globals when an identifier is undefined (#3331)
closes #3319
2024-05-17 14:20:08 +00:00
mysteryven
385965f2ff fix(linter): avoid infinite loop when traverse ancestors in jest/no_conditional_expect (#3330)
closes: #3325
2024-05-17 14:12:28 +00:00
Boshen
e241136f91 feat(cli,linter): add --disable-oxc-plugin (#3328)
closes #3316
2024-05-17 12:11:17 +00:00
Boshen
4f76cb6f38 refactor(linter): merge deepscan rules into oxc rules (#3327) 2024-05-17 11:56:06 +00:00
Boshen
95e9b6986c fix(linter): fix panic in jest/expect-expect (#3324)
closes #3323
2024-05-17 07:56:02 +00:00
rzvxa
712ee0dde8 fix(linter/react): fix false positives for async components in rules_of_hooks (#3307)
related to #3257
2024-05-16 16:38:16 +00:00
rzvxa
0864cd0115 fix(linter/react): better detection for hooks in the rules_of_hooks. (#3306)
related to #3257
2024-05-16 16:38:14 +00:00
rzvxa
95944419ec fix(linter/react): rules_of_hooks add support for property hooks/components. (#3300)
related to #3257
2024-05-16 16:38:12 +00:00
rzvxa
c8f1f79d27 fix(linter/react): rules_of_hooks resolve false positives with conditional hooks. (#3299)
related to #3071
2024-05-16 16:16:52 +00:00
Boshen
8ab9856dea feat(cli,linter): add --disable-react/unicorn/typescript-plugin (#3305)
closes #1970
2024-05-16 10:15:08 +00:00
Boshen
bd8a0ddb7f feat(linter): no-barrel-file (#3275)
![image](https://github.com/oxc-project/oxc/assets/1430279/524c8afa-a4c0-45a3-b95d-f8efd359a84f)
2024-05-16 07:54:09 +00:00
Ali Rezvani
d46538ed68
fix(linter/react): fix loop hooks false positives. (#3297)
It is a temporary fix for false positives like
[this](https://github.com/oxc-project/oxc/issues/3257#issuecomment-2110199442).
Uses the node's ancestors for now instead of the cfg.
2024-05-16 11:03:54 +08:00
Boshen
e12323f4f9 fix(linter/no-direct-mutation-state): false positive when class is declared inside a CallExpression (#3294)
fixes #3290
2024-05-15 14:07:02 +00:00
Wang Wenzhe
61281711f0
refactor(linter): rewrite react/require-render-return (#3276)
Closes: #3245

It's gone now, curious about why didn't have performance improvement.

![CleanShot 2024-05-14 at 20 57
17@2x](https://github.com/oxc-project/oxc/assets/33973865/656ef8c6-65f7-4ce4-b8a1-4f3127bb6c36)

This picture generated by running all the rules.
2024-05-15 16:40:46 +08:00
Don Isaac
5b2fc391bc
feat(linter): add use-isnan fixer for (in)equality operations (#3284)
Co-authored-by: Boshen <boshenc@gmail.com>
2024-05-15 02:20:52 +00:00
Pig Fang
56346d59da
chore(linter): expose Message:start and Message:end (#3268)
Expose the `start` and `end` field for modification in downstream
projects.
2024-05-14 08:48:05 +00:00