Skip to content

Comments

fix(linter/unicorn): consistent-function-scoping false positive on assignment expression#5312

Merged
camc314 merged 6 commits intooxc-project:mainfrom
Arian94:fix/5159
Aug 31, 2024
Merged

fix(linter/unicorn): consistent-function-scoping false positive on assignment expression#5312
camc314 merged 6 commits intooxc-project:mainfrom
Arian94:fix/5159

Conversation

@Arian94
Copy link
Contributor

@Arian94 Arian94 commented Aug 28, 2024

fixes #5159 and any other named function assigned to a property like:

const foo = {};
foo.bar = function fooBar() {}

@github-actions github-actions bot added the A-linter Area - Linter label Aug 28, 2024
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 28, 2024

CodSpeed Performance Report

Merging #5312 will not alter performance

Comparing Arian94:fix/5159 (0f68456) with main (f81e8a1)

Summary

✅ 28 untouched benchmarks

@Boshen Boshen requested a review from camc314 August 29, 2024 00:48
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@camc314 camc314 requested a review from DonIsaac August 31, 2024 16:02
@DonIsaac DonIsaac self-assigned this Aug 31, 2024
@camc314 camc314 assigned camc314 and unassigned DonIsaac Aug 31, 2024
@camc314 camc314 changed the title fix(linter): eslint-plugin-unicorn consistent-function-scoping false error on assignment expression fix(linter/unicorn): consistent-function-scoping false error on assignment expression Aug 31, 2024
@camc314 camc314 changed the title fix(linter/unicorn): consistent-function-scoping false error on assignment expression fix(linter/unicorn): consistent-function-scoping false positive on assignment expression Aug 31, 2024
@camc314 camc314 merged commit 11b93af into oxc-project:main Aug 31, 2024
@oxc-bot oxc-bot mentioned this pull request Sep 2, 2024
Boshen added a commit that referenced this pull request Sep 2, 2024
## [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 <[email protected]>
DonIsaac added a commit that referenced this pull request Sep 16, 2024
…orn/consistent-function-scoping``` (#5675)

This is to fix the cases mentioned in the comment section of #5365.

In short, it will report these as PASS test cases:

```js
let inner;

function foo1() {
  inner = function() {}
}
function foo2() {
  inner = function() {}
}
```

```js
let inner;

function outer() {
  inner = function() {}
}
```

And report these below as FAIL test cases:

```js
let inner;

function foo1() {
  inner = function smth() {}
}
function foo2() {
  inner = function bar() {}
}
```

```js
let inner;

function outer() {
  inner = function inner() {}
}
```

The case below was already done in #5312 but mentioned in #5365. It is a
FAIL case as well:
```js
function outer() {
  const inner = function inner() {}
}
```

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Don Isaac <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(linter): false positive in consistent-function-scoping in AssignmentExpressions

3 participants