Commit graph

1574 commits

Author SHA1 Message Date
Boshen
cc0408b5d4 refactor(semantic): s/AstNodeId/NodeId (#5740)
part of #5689
2024-09-13 03:00:00 +00:00
overlookmotel
20a7861838 refactor(linter): shorten Option syntax (#5735)
Use `Some` instead of `Option::Some`.
2024-09-12 18:42:51 +00:00
IWANABETHATGUY
d8b612c038
refactor(oxc_linter): prefer pass Enum instead of str no_plus_plus (#5730)
1. remove redundant branch.
2024-09-12 11:43:24 -04:00
Dunqing
e9c084a705 fix(linter/no-unused-vars): false positive when a variable used as a computed member property (#5722)
close: #5671
2024-09-12 11:23:01 +00:00
oxc-bot
1dad9fa301
release(oxlint): v0.9.5 (#5724)
## [0.9.5] - 2024-09-12

### Features

- 4b04f65 linter: Implement `no-plusplus` rule (#5570) (Cam McHenry)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-12 16:59:25 +08:00
Cam McHenry
4b04f65275
feat(linter): implement no-plusplus rule (#5570)
- part of https://github.com/oxc-project/oxc/issues/479

This PR implements the `no-plusplus` rule and is more-or-less a direct
port of the ESLint version of the rule.

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-12 16:50:19 +08:00
oxc-bot
d06bab6260
release(oxlint): v0.9.4 (#5718)
## [0.9.4] - 2024-09-12

### Features

- 9ca2593 linter: Eslint/sort-keys  (#4845) (Na'aman Hirschfeld)
- 023c160 linter: Impl `Serialize` for `OxlintConfig` (#5594) (DonIsaac)
- 24d6a47 linter: Implement `eslint/no-invalid-regexp` (#5443) (Boshen)

### Bug Fixes

- af6d240 linter: Panic in consistent-function-scoping (#5613)
(DonIsaac)
- 54e2e76 linter: `react/no_set_state` + `react/no_string_refs` rules
find correct parent (#5615) (overlookmotel)
- 3b87ac4 linter: Fix no_unused_vars panic when encountering unicode
(#5582) (Boshen)

### Performance

- bfe9186 linter: Use `cow_replace` instead of `replace` (#5643)
(dalaoshu)
- e3ae5db linter: Use cow_to_ascii_lowercase/uppercase (#5637) (heygsc)
- a0370bf linter: Use cow_utils in no_script_url (#5633) (heygsc)
- 37e922c linter: `eslint/no_shadow_restricted_names` use
`run_on_symbol` (#5618) (overlookmotel)
- 0b7fccf linter: `react/no_set_state` + `react/no_string_refs` rules
reduce iteration over ancestors (#5616) (overlookmotel)
- 2c3f3fe linter: Make `jsx_key` slightly faster (#5585) (Boshen)
- cd81d12 linter: Add `should_run` to check path only once to
nextjs/no_typos (#5584) (Boshen)
- d18c896 rust: Use `cow_utils` instead (#5664) (dalaoshu)

### Documentation

- 64f9575 linter: Add plugin usage to example with configuration
(Boshen)
- 8c9179d linter: Fix typos (#5591) (Brian Donovan)

### Refactor

- 9e9435f linter: Add `LintFilter` (#5685) (DonIsaac)
- 4f70fe5 linter: Start internal/external split of LintPluginOptions
(#5660) (DonIsaac)
- 5ae9b48 linter: Start internal/external split of `OxlintOptions`
(#5659) (DonIsaac)
- c8bc6f0 linter: Use `std::ptr::eq` (#5649) (overlookmotel)
- a37c064 linter: Use `ContentHash` for `no_duplicate_case`; remove
`calculate_hash` (#5648) (Boshen)
- 0b3c1d7 linter: Start internal/external split of `OxlintConfig`
(#5595) (DonIsaac)
- 89bdf55 linter: Inline `Rule` trait default methods (#5619)
(overlookmotel)
- afea8d5 linter: Rename `Rule` trait method params (#5617)
(overlookmotel)
- 4e748b5 linter: Replace ast "compare by hash" to "compare by content"
(#5602) (dalaoshu)
- bac03e3 linter: Make fields of `LintServiceOptions` private (#5593)
(DonIsaac)
- 2661d8b linter: Jest prefer_strict_equal (#5588) (IWANABETHATGUY)
- 20d0068 oxlint: Move cli-related exports to `cli` module (#5139)
(DonIsaac)
- 067f9b5 semantic: Introduce `IsGlobalReference` trait (#5672)
(Boshen)- 26d9235 Enable clippy::ref_as_ptr (#5577) (夕舞八弦)

### Testing

- 8e79f8d linter: Add class method test cases for `oxc/no-async-await`
(#5550) (DonIsaac)
- 3835189 linter: Add test case for no_unused_vars in 3b87ac4 (Boshen)
- 5f27551 linter: Add a passing case to no_undef (#5580) (Boshen)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-12 13:56:38 +08:00
Na'aman Hirschfeld
9ca2593aaa
feat(linter): eslint/sort-keys (#4845)
This PR adds the `eslint/sort-keys` implementation as part of #479 

Note: two tests are commented out. I was not able to model this behavior
properly. I would be happy to have some assistance there.
2024-09-11 13:10:55 -04:00
Boshen
945d2744ae
chore(linter: fix snapshot 2024-09-11 21:07:23 +08:00
Boshen
64f9575ed5
docs(linter): add plugin usage to example with configuration
closes #5400
2024-09-11 20:58:29 +08:00
dalaoshu
d18c896a2c
perf(rust): use cow_utils instead (#5664)
Related to #5586 and #5662

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-09-11 18:39:30 +08:00
DonIsaac
9e9435f03b refactor(linter): add LintFilter (#5685)
Re-creation of #5329
2024-09-11 03:19:04 +00:00
Boshen
067f9b5a6f refactor(semantic): introduce IsGlobalReference trait (#5672) 2024-09-10 10:12:08 +00:00
Boshen
c6bbf94f4c feat(minifier): constant fold unary expression (#5669) 2024-09-10 07:18:54 +00:00
DonIsaac
4f70fe5abf refactor(linter): start internal/external split of LintPluginOptions (#5660)
Re-creation of #5142
2024-09-10 03:19:05 +00:00
DonIsaac
5ae9b48509 refactor(linter): start internal/external split of OxlintOptions (#5659)
re-creation of #5141
2024-09-10 03:19:04 +00:00
overlookmotel
c8bc6f0549 refactor(linter): use std::ptr::eq (#5649)
Follow-on after #5577.

`!std::ptr::eq(x, y)` is more idiomatic than `std::ptr::from_ref(x) != std::ptr::from_ref(y)`.
2024-09-09 15:28:10 +00:00
Boshen
a37c064565 refactor(linter): use ContentHash for no_duplicate_case; remove calculate_hash (#5648)
closes #5600
2024-09-09 14:01:29 +00:00
dalaoshu
bfe9186611
perf(linter): use cow_replace instead of replace (#5643)
Related to #5586
2024-09-09 22:00:33 +08:00
Boshen
6dcaae5cd8 chore(linter): move typescript/no-magic-numbers to eslint/no-magic-numbers (#5640)
closes #5614
2024-09-09 08:53:52 +00:00
heygsc
e3ae5dbb02
perf(linter): use cow_to_ascii_lowercase/uppercase (#5637)
part of #5586 

In addition, can a similar situation in the
[formatter](https://github.com/oxc-project/oxc/blob/main/crates/oxc_prettier/src/format/mod.rs#L1406-L1409)
be handled in this way?
2024-09-09 16:13:53 +08:00
DonIsaac
0b3c1d72a3 refactor(linter): start internal/external split of OxlintConfig (#5595)
Re-creation of #5140
2024-09-09 07:17:51 +00:00
overlookmotel
89bdf5536f refactor(linter): inline Rule trait default methods (#5619)
Hopefully compiler is already inlining these trivial/empty methods, but mark them `#[inline]` to make sure.
2024-09-09 07:13:55 +00:00
heygsc
a0370bf506
perf(linter): use cow_utils in no_script_url (#5633)
part of #5586 

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-09 15:06:50 +08:00
DonIsaac
023c1607b0 feat(linter): impl Serialize for OxlintConfig (#5594)
Re-creation of #5331
2024-09-09 05:13:19 +00:00
DonIsaac
af6d240559 fix(linter): panic in consistent-function-scoping (#5613)
Closes #5608
2024-09-09 01:21:49 +00:00
overlookmotel
1fa3e5687a refactor(semantic)!: rename SymbolTable::iter to symbol_ids (#5621)
`symbol_ids` is a more descriptive name.
2024-09-09 01:07:33 +00:00
overlookmotel
37e922c00f perf(linter): eslint/no_shadow_restricted_names use run_on_symbol (#5618)
This rule was implemented as a `run_once` method which just iterated over symbols. Implement using `run_on_symbol` instead to avoid the additional iteration.
2024-09-09 01:07:32 +00:00
overlookmotel
0b7fccf000 perf(linter): react/no_set_state + react/no_string_refs rules reduce iteration over ancestors (#5616)
`get_parent_es5_component` and `get_parent_es6_component` were always used together. Combine the two into a single function to only iterate over ancestors once, instead of twice.
2024-09-09 01:07:31 +00:00
overlookmotel
54e2e76d17 fix(linter): react/no_set_state + react/no_string_refs rules find correct parent (#5615)
`get_parent_es6_component` was finding *any* binding which is inside a class component, rather than parent of current node, leading to false positives.

The added test cases were not behaving correctly previously.
2024-09-09 01:07:31 +00:00
overlookmotel
afea8d5dea refactor(linter): rename Rule trait method params (#5617)
Makes no real difference. Just produces nicer naming hints in IDEs.
2024-09-08 18:36:36 +00:00
dalaoshu
4e748b5930
refactor(linter): replace ast "compare by hash" to "compare by content" (#5602)
relates #5600
2024-09-09 00:23:26 +08:00
Boshen
4a8aec1605 feat(span)!: change SourceType::js to SourceType::cjs and SourceType::mjs (#5606) 2024-09-08 14:11:02 +00:00
Boshen
63a830e08c
chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
Boshen
c370694716
chore: fix npm/oxlint/configuration_schema.json mismatch 2024-09-08 13:34:53 +08:00
DonIsaac
8e79f8d72d test(linter): add class method test cases for oxc/no-async-await (#5550)
Adds tests for class and object methods. Diagnostics for the former have incorrect spans.

```javascript
class Foo {
   // span covers `() {}`
  async foo() {}
}
```
2024-09-08 03:15:01 +00:00
DonIsaac
bac03e3b6c refactor(linter): make fields of LintServiceOptions private (#5593)
Re-creation of #5326
2024-09-08 03:10:02 +00:00
Brian Donovan
8c9179d58a
docs(linter): fix typos (#5591) 2024-09-07 18:14:38 +01:00
IWANABETHATGUY
2661d8b505 refactor(linter): jest prefer_strict_equal (#5588)
simplify code
2024-09-07 16:44:27 +00:00
Boshen
24d6a47f8b feat(linter): implement eslint/no-invalid-regexp (#5443)
closes #611

@leaysgur Kicking of `no-invalid-regexp`, feel free to take over and claim the bounty on #611 😁

I can continue if you wanna work on other stuff (getting confused in prettier land ;-))
2024-09-07 14:09:33 +00:00
Boshen
2c3f3fe9e4 perf(linter): make jsx_key slightly faster (#5585) 2024-09-07 14:03:26 +00:00
Boshen
cd81d12624 perf(linter): add should_run to check path only once to nextjs/no_typos (#5584) 2024-09-07 13:03:23 +00:00
Boshen
3835189785
test(linter): add test case for no_unused_vars in 3b87ac4 2024-09-07 20:45:40 +08:00
Boshen
3b87ac48ce fix(linter): fix no_unused_vars panic when encountering unicode (#5582)
closes #4887
2024-09-07 12:37:51 +00:00
Boshen
5f275516eb test(linter): add a passing case to no_undef (#5580)
closes #2093
2024-09-07 11:08:26 +00:00
夕舞八弦
26d9235319
refactor: enable clippy::ref_as_ptr (#5577)
#5567 
`clippy::borrow_as_ptr` is also enabled in
`oxc_traverse/src/generated/walk.rs`.
2024-09-07 18:18:55 +08:00
oxc-bot
16009c09fd
release: oxlint v0.9.3 (#5569)
## [0.9.3] - 2024-09-07

### Features

- be3a432 linter: Implement typescript/no-magic-numbers (#4745)
(Alexander S.)
- 09aa86d linter/eslint: Implement `sort-vars` rule (#5430) (Jelle van
der Waa)
- 2ec2f7d linter/eslint: Implement no-alert (#5535) (Edwin Lim)
- a786acf linter/import: Add no-dynamic-require rule (#5389) (Jelle van
der Waa)
- 4473779 linter/node: Implement no-exports-assign (#5370) (dalaoshu)
- b846432 linter/oxc: Add fixer for `erasing-op` (#5377) (camc314)
- aff2c71 linter/react: Implement `self-closing-comp` (#5415) (Jelle van
der Waa)

### Bug Fixes

- 0df1d9d ast, codegen, linter: Panics in fixers. (#5431) (rzvxa)
- cdd1a91 linter: Typescript/no-magic-numbers: remove double minus for
reporting negative bigint numbers (#5565) (Alexander S.)
- ff88c1f linter: Don't mark binding rest elements as unused in TS
function overloads (#5470) (Cam McHenry)
- 088733b linter: Handle loops in `getter-return` rule (#5517) (Cam
McHenry)
- 82c0a16 linter: `tree_shaking/no_side_effects_in_initialization`
handle JSX correctly (#5450) (overlookmotel)
- 6285a02 linter: `eslint/radix` rule correctly check for unbound
symbols (#5446) (overlookmotel)
- c8ab353 linter/tree-shaking: Align JSXMemberExpression's report
(#5548) (mysteryven)
- 5187f38 linter/tree-shaking: Detect the correct export symbol
resolution (#5467) (mysteryven)

### Performance

- 8170954 linter/react: Add should_run conditions for react rules
(#5402) (Jelle van der Waa)

### Documentation

- a540215 linter: Update docs `Examples` for linter rules (#5513)
(dalaoshu)
- 7414190 linter: Update docs `Example` for linter rules (#5479)
(heygsc)

### Refactor

- 0ac420d linter: Use meaningful names for diagnostic parameters (#5564)
(Don Isaac)
- 81a394d linter: Deduplicate code in `oxc/no-async-await` (#5549)
(DonIsaac)
- 979c16c linter: Reduce nested if statements in
eslint/no_this_before_super (#5485) (IWANABETHATGUY)
- 1d3e973 linter: Simplify `eslint/radix` rule (#5445) (overlookmotel)
- fdb8857 linter: Use "parsed pattern" in `no_div_regex` rule. (#5417)
(rzvxa)
- 2ccbd93 linter: `react/jsx_no_undef` rule `get_member_ident` do not
return Option (#5411) (overlookmotel)

### Styling

- 2a43fa4 linter: Introduce the writing style from PR #5491 and reduce
the if nesting (#5512) (dalaoshu)- d8b29e7 Add trailing line breaks to
JSON files (#5544) (overlookmotel)- 694f032 Add trailing line breaks to
`package.json` files (#5542) (overlookmotel)

### Testing

- 340b535 linter/no-unused-vars: Arrow functions in tagged templates
(#5510) (Don Isaac)
- af69393 linter/no-useless-spread: Ensure spreads on identifiers pass
(#5561) (DonIsaac)- dc92489 Add trailing line breaks to conformance
fixtures (#5541) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-07 12:28:46 +08:00
Alexander S.
cdd1a91754
fix(linter): typescript/no-magic-numbers: remove double minus for reporting negative bigint numbers (#5565)
@DonIsaac small bug I found after 10x review

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-07 11:48:24 +08:00
Don Isaac
0ac420d6f9
refactor(linter): use meaningful names for diagnostic parameters (#5564)
Also add `pending` fix labels to many rules.
2024-09-06 18:14:56 -04:00
Alexander S.
be3a432106
feat(linter): implement typescript/no-magic-numbers (#4745)
Linter rule: https://eslint.org/docs/latest/rules/no-magic-numbers
and: https://typescript-eslint.io/rules/no-magic-numbers/

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-06 20:52:13 +01:00