Edwin Lim
2ec2f7d829
feat(linter/eslint): implement no-alert ( #5535 )
...
Contributing to #479 !
Rule Details: [link](https://eslint.org/docs/latest/rules/no-alert )
Am new to the internals of parsers and linters so I kept the
implementation similar to ESLint's source code
Commented out the `globalThis` test cases in the pass array meant for
pre-ES2020 before `globalThis` was introduced, having clarified in the
Discord that it's ok to treat the built-in `globalThis` as always
present.
---------
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-06 08:40:20 -04:00
dalaoshu
a540215c91
docs(linter): update docs Examples for linter rules ( #5513 )
2024-09-06 07:23:06 -04:00
Cam McHenry
ff88c1fc07
fix(linter): Don't mark binding rest elements as unused in TS function overloads ( #5470 )
...
- Fixes https://github.com/oxc-project/oxc/issues/5406
This implements a fix for the `BindingRestElement` symbol, which is
currently unhandled and gets automatically marked as unused. If we
happen to find that it is a child of declaration, then we will
automatically allow the binding rest element.
The code for this was based on what we currently do in
`is_allowed_param_because_of_method`:
5187f384cb/crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs (L258)
I opted not to refactor this to re-use the same code though, as I think
the duplication is still incidental and the implementations could
diverge in the future.
2024-09-06 08:30:28 +01:00
Boshen
1bed5ce2a5
chore: run cargo +nightly fmt to sort imports ( #5503 )
...
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
dalaoshu
2a43fa4efd
style(linter): introduce the writing style from PR #5491 and reduce the if nesting ( #5512 )
...
Related to #5491
2024-09-06 11:19:48 +08:00
Cam McHenry
088733b3c8
fix(linter): handle loops in getter-return rule ( #5517 )
...
- Fixes https://github.com/oxc-project/oxc/issues/3935
Prior to this, it didn't seem like we were correctly continuing to
search the graph after we encountered a backedge (loop). Now, when
encountering a cycle, we will not automatically break or prune the
search.
2024-09-06 06:29:04 +03:30
Don Isaac
340b535715
test(linter/no-unused-vars): arrow functions in tagged templates ( #5510 )
...
Closes #5391
2024-09-05 14:55:39 -04:00
renovate
d9a1b610a7
chore(deps): update dependency rust to v1.81.0 ( #5502 )
...
This PR contains the following updates:
| Package | Update | Change |
|---|---|---|
| [rust](https://redirect.github.com/rust-lang/rust ) | minor | `1.80.1` -> `1.81.0` |
---
### Release Notes
<details>
<summary>rust-lang/rust (rust)</summary>
### [`v1.81.0`](https://redirect.github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1810-2024-09-05 )
[Compare Source](https://redirect.github.com/rust-lang/rust/compare/1.80.1...1.81.0 )
\==========================
<a id="1.81.0-Language"></a>
## Language
- [Abort on uncaught panics in `extern "C"` functions.](https://redirect.github.com/rust-lang/rust/pull/116088/ )
- [Fix ambiguous cases of multiple `&` in elided self lifetimes.](https://redirect.github.com/rust-lang/rust/pull/117967/ )
- [Stabilize `#[expect]` for lints (RFC 2383),](https://redirect.github.com/rust-lang/rust/pull/120924/ ) like `#[allow]` with a warning if the lint is *not* fulfilled.
- [Change method resolution to constrain hidden types instead of rejecting method candidates.](https://redirect.github.com/rust-lang/rust/pull/123962/ )
- [Bump `elided_lifetimes_in_associated_constant` to deny.](https://redirect.github.com/rust-lang/rust/pull/124211/ )
- [`offset_from`: always allow pointers to point to the same address.](https://redirect.github.com/rust-lang/rust/pull/124921/ )
- [Allow constraining opaque types during subtyping in the trait system.](https://redirect.github.com/rust-lang/rust/pull/125447/ )
- [Allow constraining opaque types during various unsizing casts.](https://redirect.github.com/rust-lang/rust/pull/125610/ )
- [Deny keyword lifetimes pre-expansion.](https://redirect.github.com/rust-lang/rust/pull/126762/ )
<a id="1.81.0-Compiler"></a>
## Compiler
- [Make casts of pointers to trait objects stricter.](https://redirect.github.com/rust-lang/rust/pull/120248/ )
- [Check alias args for well-formedness even if they have escaping bound vars.](https://redirect.github.com/rust-lang/rust/pull/123737/ )
- [Deprecate no-op codegen option `-Cinline-threshold=...`.](https://redirect.github.com/rust-lang/rust/pull/124712/ )
- [Re-implement a type-size based limit.](https://redirect.github.com/rust-lang/rust/pull/125507/ )
- [Properly account for alignment in `transmute` size checks.](https://redirect.github.com/rust-lang/rust/pull/125740/ )
- [Remove the `box_pointers` lint.](https://redirect.github.com/rust-lang/rust/pull/126018/ )
- [Ensure the interpreter checks bool/char for validity when they are used in a cast.](https://redirect.github.com/rust-lang/rust/pull/126265/ )
- [Improve coverage instrumentation for functions containing nested items.](https://redirect.github.com/rust-lang/rust/pull/127199/ )
- Target changes:
- [Add Tier 3 `no_std` Xtensa targets:](https://redirect.github.com/rust-lang/rust/pull/125141/ ) `xtensa-esp32-none-elf`, `xtensa-esp32s2-none-elf`, `xtensa-esp32s3-none-elf`
- [Add Tier 3 `std` Xtensa targets:](https://redirect.github.com/rust-lang/rust/pull/126380/ ) `xtensa-esp32-espidf`, `xtensa-esp32s2-espidf`, `xtensa-esp32s3-espidf`
- [Add Tier 3 i686 Redox OS target:](https://redirect.github.com/rust-lang/rust/pull/126192/ ) `i686-unknown-redox`
- [Promote `arm64ec-pc-windows-msvc` to Tier 2.](https://redirect.github.com/rust-lang/rust/pull/126039/ )
- [Promote `wasm32-wasip2` to Tier 2.](https://redirect.github.com/rust-lang/rust/pull/126967/ )
- [Promote `loongarch64-unknown-linux-musl` to Tier 2 with host tools.](https://redirect.github.com/rust-lang/rust/pull/126298/ )
- [Enable full tools and profiler for LoongArch Linux targets.](https://redirect.github.com/rust-lang/rust/pull/127078/ )
- [Unconditionally warn on usage of `wasm32-wasi`.](https://redirect.github.com/rust-lang/rust/pull/126662/ ) (see compatibility note below)
- Refer to Rust's \[platform support page]\[platform-support-doc] for more information on Rust's tiered platform support.
<a id="1.81.0-Libraries"></a>
## Libraries
- [Split core's `PanicInfo` and std's `PanicInfo`.](https://redirect.github.com/rust-lang/rust/pull/115974/ ) (see compatibility note below)
- [Generalize `{Rc,Arc}::make_mut()` to unsized types.](https://redirect.github.com/rust-lang/rust/pull/116113/ )
- [Replace sort implementations with stable `driftsort` and unstable `ipnsort`.](https://redirect.github.com/rust-lang/rust/pull/124032/ ) All `slice::sort*` and `slice::select_nth*` methods are expected to see significant performance improvements. See the [research project](https://redirect.github.com/Voultapher/sort-research-rs ) for more details.
- [Document behavior of `create_dir_all` with respect to empty paths.](https://redirect.github.com/rust-lang/rust/pull/125112/ )
- [Fix interleaved output in the default panic hook when multiple threads panic simultaneously.](https://redirect.github.com/rust-lang/rust/pull/127397/ )
<a id="1.81.0-Stabilized-APIs"></a>
## Stabilized APIs
- [`core::error`](https://doc.rust-lang.org/stable/core/error/index.html )
- [`hint::assert_unchecked`](https://doc.rust-lang.org/stable/core/hint/fn.assert_unchecked.html )
- [`fs::exists`](https://doc.rust-lang.org/stable/std/fs/fn.exists.html )
- [`AtomicBool::fetch_not`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicBool.html#method.fetch_not )
- [`Duration::abs_diff`](https://doc.rust-lang.org/stable/core/time/struct.Duration.html#method.abs_diff )
- [`IoSlice::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance )
- [`IoSlice::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance_slices )
- [`IoSliceMut::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance )
- [`IoSliceMut::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance_slices )
- [`PanicHookInfo`](https://doc.rust-lang.org/stable/std/panic/struct.PanicHookInfo.html )
- [`PanicInfo::message`](https://doc.rust-lang.org/stable/core/panic/struct.PanicInfo.html#method.message )
- [`PanicMessage`](https://doc.rust-lang.org/stable/core/panic/struct.PanicMessage.html )
These APIs are now stable in const contexts:
- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/char/fn.from_u32\_unchecked.html ) (function)
- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/primitive.char.html#method.from_u32\_unchecked ) (method)
- [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes )
- [`CStr::from_ptr`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.from_ptr )
<a id="1.81.0-Cargo"></a>
## Cargo
- [Generated `.cargo_vcs_info.json` is always included, even when `--allow-dirty` is passed.](https://redirect.github.com/rust-lang/cargo/pull/13960/ )
- [Disallow `package.license-file` and `package.readme` pointing to non-existent files during packaging.](https://redirect.github.com/rust-lang/cargo/pull/13921/ )
- [Disallow passing `--release`/`--debug` flag along with the `--profile` flag.](https://redirect.github.com/rust-lang/cargo/pull/13971/ )
- [Remove `lib.plugin` key support in `Cargo.toml`. Rust plugin support has been deprecated for four years and was removed in 1.75.0.](https://redirect.github.com/rust-lang/cargo/pull/13902/ )
<a id="1.81.0-Compatibility-Notes"></a>
## Compatibility Notes
- Usage of the `wasm32-wasi` target will now issue a compiler warning and request users switch to the `wasm32-wasip1` target instead. Both targets are the same, `wasm32-wasi` is only being renamed, and this [change to the WASI target](https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html ) is being done to enable removing `wasm32-wasi` in January 2025.
- We have renamed `std::panic::PanicInfo` to `std::panic::PanicHookInfo`. The old name will continue to work as an alias, but will result in a deprecation warning starting in Rust 1.82.0.
`core::panic::PanicInfo` will remain unchanged, however, as this is now a *different type*.
The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html ) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html ) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.
- The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html ) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order ) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
<a id="1.81.0-Internal-Changes"></a>
## Internal Changes
These changes do not affect any public interfaces of Rust, but they represent
significant improvements to the performance or internals of rustc and related
tools.
- [Add a Rust-for Linux `auto` CI job to check kernel builds.](https://redirect.github.com/rust-lang/rust/pull/125209/ )
</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 was generated by [Mend Renovate](https://mend.io/renovate/ ). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
2024-09-05 16:57:47 +00:00
heygsc
7414190ada
docs(linter): update docs Example for linter rules ( #5479 )
...
fix : #5458
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-05 21:54:20 +08:00
Jelle van der Waa
a786acff41
feat(linter/import): add no-dynamic-require rule ( #5389 )
...
Rule Detail:
[link](https://github.com/import-js/eslint-plugin-import/blob/v2.29.1/docs/rules/no-dynamic-require.md )
2024-09-05 09:39:25 -04:00
IWANABETHATGUY
979c16c486
refactor(linter): reduce nested if statements in eslint/no_this_before_super ( #5485 )
2024-09-05 13:21:18 +00:00
dalaoshu
bc7be70077
chore(linter/react_perf): improve docs for react_perf rules ( #5481 )
...
Please fill in the "why this is bad" section
_Originally posted by @DonIsaac in
https://github.com/oxc-project/oxc/pull/5360#discussion_r1739617907_
2024-09-05 09:20:55 -04:00
rzvxa
0df1d9d97b
fix(ast, codegen, linter): panics in fixers. ( #5431 )
...
Closes #5434
https://github.com/oxc-project/oxlint-ecosystem-ci/actions/runs/10685877915/job/29619941099
2024-09-05 05:59:22 +00:00
rzvxa
90facd3657
feat(ast): add ContentHash trait; remove noop Hash implementation from Span ( #5451 )
...
closes #5283
Also removes the noop Hash implementation on `Span` in favor of a real implementation.
2024-09-05 07:20:04 +03:30
mysteryven
5187f384cb
fix(linter/tree-shaking): detect the correct export symbol resolution ( #5467 )
...
fixes : #5455
2024-09-05 03:05:46 +00:00
overlookmotel
cba93f52d0
feat(ast)!: add ThisExpression variants to JSXElementName and JSXMemberExpressionObject ( #5466 )
...
Close #5352 .
Add to AST:
* `JSXElementName::ThisExpression` (`<this>`)
* `JSXMemberExpressionObject::ThisExpression` (`<this.foo>`, `<this.foo.bar>`)
2024-09-05 02:06:20 +00:00
overlookmotel
82c0a167c4
fix(linter): tree_shaking/no_side_effects_in_initialization handle JSX correctly ( #5450 )
...
#5223 altered `JSXElementName` so `JSXElementName::Identifier` is used only for non-reference JSX names (e.g. `<div>`). `JSXElementName::IdentifierReference` is used where the name is a reference (e.g. `<Foo>`). Similarly `JSXMemberExpressionObject`'s `object` is always an `IdentifierReference` now.
So, the net result is that `JSXIdentifier` is now never a reference, it's just the JSX equivalent of `IdentifierName`. So I don't think `JSXIdentifier` can ever have side-effects.
This PR:
1. Removes `impl ListenerMap for JSXIdentifier`
2. Adds `impl ListenerMap for JSXMemberExpression` and makes sure the root `IdentifierReference` (`Foo` in `<Foo.bar.qux>`) is visited.
2024-09-05 02:06:19 +00:00
overlookmotel
87c5df2226
refactor(ast)!: rename Expression::without_parentheses ( #5448 )
...
Rename `without_parenthesized` to `without_parentheses`. Both are hard-to-spell words, but "without parenthesized" does not make sense.
2024-09-05 01:25:00 +00:00
overlookmotel
6285a02274
fix(linter): eslint/radix rule correctly check for unbound symbols ( #5446 )
...
`SymbolTable::get_symbol_id_from_name(name).is_none()` is not always correct, because it will return `false` if there is a binding *anywhere* in the AST with that name, whereas what we actually want to know is whether *this* `IdentifierReference` is referring to a global or not.
Instead, look up whether this reference is resolved or not using `SymbolTable::is_global_reference`.
The 3 test cases added were not working prior to this change.
2024-09-05 01:18:24 +00:00
overlookmotel
1d3e973f10
refactor(linter): simplify eslint/radix rule ( #5445 )
...
Refactor to remove duplicate logic.
2024-09-04 16:52:27 +00:00
rzvxa
fdb8857630
refactor(linter): use "parsed pattern" in no_div_regex rule. ( #5417 )
...
Part of #5416 , Paves the road for upcoming refactors by adding the `oxc_regular_expression` dependency and a helper method for ease of access.
2024-09-04 14:00:47 +00:00
Jelle van der Waa
aff2c71423
feat(linter/react): implement self-closing-comp ( #5415 )
...
Rule Detail:
[link](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md )
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-04 10:00:23 -04:00
Jelle van der Waa
81709549d9
perf(linter/react): add should_run conditions for react rules ( #5402 )
2024-09-04 08:37:15 -04:00
dalaoshu
f89c776ac4
chore(linter/vitest): improve docs for vitest rules ( #5428 )
2024-09-04 08:29:57 -04:00
dalaoshu
4473779074
feat(linter/node): implement no-exports-assign ( #5370 )
2024-09-03 07:53:14 -04:00
rzvxa
59abf27d95
feat(ast, parser): add oxc_regular_expression types to the parser and AST. ( #5256 )
...
closes #5060
2024-09-03 02:36:37 +00:00
camc314
b8464325e7
feat(linter/oxc): add fixer for erasing-op ( #5377 )
...
adds a fixer for `erasing-op` (replace the binary expression with `0`)
2024-09-03 00:46:55 +00:00
overlookmotel
2ccbd9361b
refactor(linter): react/jsx_no_undef rule get_member_ident do not return Option ( #5411 )
...
Small tidy-up after #5358 . `get_member_ident` now always returns a value, never `None`, so no need for it to return an `Option`.
2024-09-02 18:42:02 +00:00
Dunqing
1aa49af010
feat(ast)!: remove JSXMemberExpressionObject::Identifier variant ( #5358 )
...
close : #5353
`JSXMemberExpressionObject::Identifier` is dead code.
2024-09-02 18:35:39 +00:00
oxc-bot
953344dd42
Release oxlint v0.9.2 ( #5401 )
...
## [0.9.2] - 2024-09-02
### Features
- f81e8a1 linter: Add `oxc/no-async-endpoint-handlers` (#5364 )
(DonIsaac)
- b103737 linter: Improve no-accumulating-spread (#5302 ) (camc314)
- 9c22ce9 linter: Add hyperlinks to diagnostic messages (#5318 )
(DonIsaac)
- 1967c67 linter/eslint: Implement no-new-func (#5360 ) (dalaoshu)
- b867e5f linter/eslint-plugin-promise: Implement catch-or-return
(#5121 ) (Jelle van der Waa)
- 8d781e7 linter/oxc: Differentiate between array/object in
`no-accumulating-spread` loop diagnostic (#5375 ) (camc314)
- db55444 linter/oxc: Add fixer for `double-comparisons` (#5378 )
(camc314)
- e5c755a linter/promise: Add `spec-only` rule (#5124 ) (Jelle van der
Waa)
- 4c0861f linter/unicorn: Add fixer for `prefer-type-error` (#5311 )
(camc314)
- 084c2d1 linter/vitest: Implement prefer-to-be-object (#5321 )
(dalaoshu)
### Bug Fixes
- 11b93af linter/unicorn: Consistent-function-scoping false positive on
assignment expression (#5312 ) (Arian94)
### Performance
- f052a6d linter: `react/jsx_no_undef` faster check for unbound
references (#5349 ) (overlookmotel)
- 05636b7 linter: Avoid unnecessary work in `jsx_a11y/anchor_is_valid`
rule (#5341 ) (overlookmotel)
### Refactor
- afb038e linter: `react/jsx_no_undef` use loop instead of recursion
(#5347 ) (overlookmotel)
- fe62687 linter: Simplify skipping JSX elements in
`unicorn/consistent_function_scoping` (#5351 ) (overlookmotel)
- 381d9fe linter: Shorten code in `react/jsx_no_useless_fragment`
(#5350 ) (overlookmotel)
- 83b9a82 linter: Fix indentation in
`nextjs/no_script_component_in_head` rule (#5338 ) (overlookmotel)
- 89f0188 linter: Improve docs for `react/jsx_no_target_blank` rule
(#5342 ) (overlookmotel)
- 57050ab linter: Shorten code in
`jsx_a11y/aria_activedescendant_has_tabindex` rule (#5340 )
(overlookmotel)
- ed31d67 linter/jest: Fix indentation in code comment (#5372 ) (camc314)
- 2499cb9 linter/oxc: Update rule docs for `erasing-op` (#5376 )
(camc314)
- 69493d2 linter/oxc: Improve diagnostic for `no-accumulating-spread` in
loops (#5374 ) (camc314)
- 024b585 linter/oxc: Improve code comment for `no-accumulating-spread`
(#5373 ) (camc314)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-02 20:30:22 +08:00
dalaoshu
084c2d166c
feat(linter/vitest): implement prefer-to-be-object ( #5321 )
...
Related to #4656
2024-09-01 19:09:36 +08:00
camc314
2499cb9785
refactor(linter/oxc): update rule docs for erasing-op ( #5376 )
...
updates the rule docs to align with the template:
a266b45167/tasks/rulegen/template.txt (L13)
2024-09-01 06:23:25 +00:00
camc314
8d781e7dff
feat(linter/oxc): differentiate between array/object in no-accumulating-spread loop diagnostic ( #5375 )
...
when reporting diagnotics for code such as
```ts
let foo = {};
for (let i = 0; i < 10; i++) {
foo = { ...foo, [i]: i };
}
```
we do not currently differentiate the diagnostic message between object/array.
this PR changes this to help the user fix ths issue
2024-08-31 20:52:05 +00:00
camc314
69493d2987
refactor(linter/oxc): improve diagnostic for no-accumulating-spread in loops ( #5374 )
...
when reporting diagnotics for code such as
```ts
let foo = {};
for (let i = 0; i < 10; i++) {
foo = { ...foo, [i]: i };
}
```
we do not currently report **where** the accumulator is defined.
since this is constant for `Array.prototype.reduce`, it is not necessary.
however for loops, it makes sense to add this span to clearly show the user where the accumator is defined.
2024-08-31 20:52:05 +00:00
camc314
024b58506e
refactor(linter/oxc): improve code comment for no-accumulating-spread ( #5373 )
...
mentioned here: https://github.com/oxc-project/oxc/pull/5302#discussion_r1735759462
it's not exactly clear why we check that it's a `let` declaration kind.
2024-08-31 20:52:04 +00:00
camc314
db554447aa
feat(linter/oxc): add fixer for double-comparisons ( #5378 )
2024-08-31 20:48:59 +00:00
camc314
ed31d67b51
refactor(linter/jest): fix indentation in code comment ( #5372 )
...
previously, `test('...` was indented, making it look like it was inside a block statement/callback.
this PR corrects this by fixing the indentation
2024-08-31 18:56:25 +00:00
Arian94
11b93af0d1
fix(linter/unicorn): consistent-function-scoping false positive on assignment expression ( #5312 )
...
fixes #5159 and any other named function assigned to a property like:
```js
const foo = {};
foo.bar = function fooBar() {}
```
---------
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2024-08-31 19:41:25 +01:00
DonIsaac
f81e8a126e
feat(linter): add oxc/no-async-endpoint-handlers ( #5364 )
...
Adds `no-async-endpoint-handlers` rules, which bans async functions used as endpoint handlers in Express applications. These do not get caught by Express' error handler, causing the server to crash with an unhandled process rejection error.
```js
app.use(async (req, res) => {
const foo = await api.getFoo(req.query) // server panics if this function rejects
return res.json(foo)
})
```
I could not find this rule implemented in any ESLint plugin, but this is a problem I see quite often and I'm tired of dealing with it. I've added it to `oxc` for now, but we should consider adding an `express` or `api` plugin in the future.
2024-08-31 16:59:52 +00:00
Jelle van der Waa
b867e5f16b
feat(linter/eslint-plugin-promise): implement catch-or-return ( #5121 )
...
Rule detail:
[link](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/catch-or-return.md )
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-08-31 17:04:06 +01:00
Jelle van der Waa
e5c755a7a6
feat(linter/promise): add spec-only rule ( #5124 )
...
Rule Detail:
[link](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/spec-only.md )
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-08-31 11:38:47 -04:00
dalaoshu
1967c6730b
feat(linter/eslint): implement no-new-func ( #5360 )
...
Related to #479
---------
Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-08-31 11:37:03 -04:00
camc314
4c0861f694
feat(linter/unicorn): add fixer for prefer-type-error ( #5311 )
2024-08-31 05:17:47 +00:00
DonIsaac
180b1a17fb
feat(ast): add Function::name() ( #5361 )
2024-08-31 03:45:45 +00:00
overlookmotel
afb038e93e
refactor(linter): react/jsx_no_undef use loop instead of recursion ( #5347 )
2024-08-30 17:48:05 +00:00
overlookmotel
fe62687bf1
refactor(linter): simplify skipping JSX elements in unicorn/consistent_function_scoping ( #5351 )
...
Follow-on after #5223 . We're trying to ignore JSX identifiers, so there's no point walking downwards from `JSXElementName`, as all we'll find is JSX identifiers that we want to ignore.
2024-08-30 15:11:50 +00:00
overlookmotel
381d9fe624
refactor(linter): shorten code in react/jsx_no_useless_fragment ( #5350 )
...
Shorten code. Also do the enum match first, as its cheaper than a string comparison.
2024-08-30 15:06:46 +00:00
overlookmotel
f052a6d666
perf(linter): react/jsx_no_undef faster check for unbound references ( #5349 )
...
Follow-on after #5223 .
Now that we are getting an `IdentifierReference` with a `reference_id`, we can use that ID for a faster lookup of whether the reference is bound or not.
2024-08-30 14:56:55 +00:00
overlookmotel
83b9a8240e
refactor(linter): fix indentation in nextjs/no_script_component_in_head rule ( #5338 )
2024-08-30 09:01:14 -04:00
overlookmotel
89f018889d
refactor(linter): improve docs for react/jsx_no_target_blank rule ( #5342 )
2024-08-30 09:00:43 -04:00