Commit graph

1484 commits

Author SHA1 Message Date
dalaoshu
aaaf26cee4
fix(linter): error in fixer for prefer-to-have-length (#5197)
closes #5195
2024-08-25 17:13:56 +01:00
camc314
ac7edccab3 feat(linter/unicorn): add fixer to prefer-array-some (#5153) 2024-08-25 13:25:12 +00:00
Boshen
543cad6370
refactor(codegen): remove some pub APIs 2024-08-25 13:32:55 +08:00
DonIsaac
a877e5a612 test(linter/no-unused-vars): ensure type annotations on property accessors are considered used (#5183) 2024-08-25 01:02:51 +00:00
camc314
1d01aa316f feat(linter/unicorn): add partial fixer for prefer-array-flat (#5143) 2024-08-24 22:58:38 +00:00
DonIsaac
fd1031abeb fix(linter/unicorn): breaking fixer in case statements for no-null (#5176) 2024-08-24 22:24:10 +00:00
Don Isaac
7b86ed61d1
fix(linter/unicorn): handle type casts and parens in no-null (#5175) 2024-08-24 18:18:52 -04:00
DonIsaac
7ab615220d refactor(linter/unicorn): clean up no-null (#5174) 2024-08-24 21:48:35 +00:00
DonIsaac
7886618e00 test(linter/unicorn): add fixer tests for no-null (#5173) 2024-08-24 21:48:34 +00:00
DonIsaac
b629e160db fix(linter/unicorn): improve diagnostic message for no-null (#5172)
This stack was made because of shortcomings I noticed while running `oxlint-eccosystem-ci` tests locally
2024-08-24 21:40:00 +00:00
camc314
dc9e1e233a fix(unicorn/linter) fix multiple false positives in no-useless-promise-resolve-reject (#5178)
more closely follows the implementation from unicorn's repo.

early returns if the parent is not a `return`, `yield`, or an arroy function

Closes #5125
Closes #5126
2024-08-24 21:03:31 +00:00
DonIsaac
d29042e7fc fix(linter/no-unused-vars): function expression in implicit arrow function return (#5155)
Fixes cases such as:
```ts
export const foo = () => function bar() {}
```
2024-08-24 15:49:56 +00:00
Cameron
147b37176b
fix(linter) fix bug in fixer for func names when function is async (#5167) 2024-08-24 11:30:56 -04:00
dalaoshu
1f5b6b6c82
fix(linter): bug in fixer for prefer-to-have-length (#5164) 2024-08-24 11:29:45 -04:00
Earl Chase
ba62a71975
fix(linter/react): Fixed false positive with missing key inside React.Children.toArray() for fragments (#5133)
Related: #4421 and #4945
2024-08-24 16:01:50 +08:00
DonIsaac
36e4a2875c fix(linter/no-unused-vars): panic in variable declarator usage checks (#5160)
Part of #5129
2024-08-24 04:49:30 +00:00
Cameron
22d57f9e5e
feat(linter/unicorn): add fixer to prefer-string-slice (#5150) 2024-08-23 21:37:35 -04:00
camc314
34bfaf6792 feat(linter/react): add fixer to jsx-props-no-spread-multi (#5145) 2024-08-23 23:43:53 +00:00
Cameron
2fe44153ac
feat(linter/unicorn): add fixer to no-redundant-roles (#5146) 2024-08-23 17:38:24 -04:00
Cameron
d35c6f5dfc
feat(linter/unicorn): add fixer to prefer-regexp-test (#5151) 2024-08-23 17:34:06 -04:00
Cameron
27db769b8a
feat(linter/unicorn): add fixer to text-encoding-identifier-case (#5154) 2024-08-23 17:29:19 -04:00
Cameron
7eb052e0d4
fix(linter): no-hex-escape fixer removing regex flags (#5137)
closes #5127
2024-08-23 20:32:34 +01:00
DonIsaac
1ce9630c72 feat(linter/config): implement FromIterator for LintPluginOptions (#5102)
Part of #5046
2024-08-23 18:55:58 +00:00
DonIsaac
33599b0064 refactor(linter): split options into multiple files (#5101) 2024-08-23 18:55:57 +00:00
camc314
56a68f542d fix(linter) fix bug in fixer for func-name (#5136)
closes #5128
2024-08-23 18:46:04 +00:00
DonIsaac
b894d3b33e feat(linter)!: make no-unused-vars correctness (#5081)
closes #5080
2024-08-23 13:12:59 +00:00
camc314
525d664aa9 fix(linter) false positive in jest/no-untyped-mock-factory (#5123)
part of https://github.com/oxc-project/oxc/issues/5103
2024-08-23 12:45:23 +00:00
camc314
b7ba9c01a1 fix(linter) fix bug in fixer for prefer-function-type when interface is exported (#5122)
part of https://github.com/oxc-project/oxc/issues/5103
2024-08-23 12:45:22 +00:00
Jelle van der Waa
f7958c4cc2
feat(linter/unicorn): add prefer-structured-clone (#5095) 2024-08-23 12:34:52 +01:00
Boshen
76c66b4326 fix(linter/max-lines): point span to end of file for disable directive to work (#5117)
closes #4101
2024-08-23 10:20:17 +00:00
oxc-bot
8ef85a43c0
Release oxlint v0.8.0 (#5104)
## [0.8.0] - 2024-08-23

- 5f4c9ab semantic: [**BREAKING**] Rename `SymbolTable::get_flag` to
`get_flags` (#5030) (overlookmotel)

- ce4d469 codegen: [**BREAKING**] Remove const generic `MINIFY` (#5001)
(Boshen)

- b2ff2df parser: [**BREAKING**] Remove builder pattern from `Parser`
struct (#5000) (Boshen)

- f88970b ast: [**BREAKING**] Change order of fields in CallExpression
(#4859) (Burlin)

### Features

- 2292606 linter: Typescript-eslint/no-wrapper-object-types (#5022)
(camc314)
- a0effab linter: Support more flexible config.globals values (#4990)
(Don Isaac)
- cdbfcfb linter: Start import fixer for eslint/no-unused-vars (#4849)
(DonIsaac)
- 915cb4d linter: Add dangerous fixer for oxc only used in recursion
(#4805) (camc314)
- 3f28c77 linter/eslint: Improve no-dupe-keys (#4943) (DonIsaac)
- e1582a5 linter/eslint: Improve no-duplicate-case rule (#4942)
(DonIsaac)
- f1e4611 linter/eslint-plugin-vitest: Implement no-conditional-in-test
(#4971) (dalaoshu)
- 14bf5d5 linter/eslint-plugin-vitest: Implement
no-restricted-vi-methods (#4956) (dalaoshu)
- ed9a1c4 linter/eslint-plugin-vitest: Implement
require-local-test-context-for-concurrent-snapshots (#4951) (dalaoshu)
- 7859f58 linter/eslint-plugin-vitest: Implement no-conditional-tests
(#4955) (dalaoshu)
- 841174f linter/no-unused-vars: Delete non-root arrows, skip `await`
(#5083) (Don Isaac)

### Bug Fixes

- 86d0c0c linter: Change consistent-function-scoping to suspicious
(#5010) (DonIsaac)
- 7b99386 linter: Missing closing ticks in some example blocks (#4994)
(DonIsaac)
- 9c64b12 linter: Improve no-zero-fractions rule for member expressions
and scientific notation (#4793) (Burlin)
- c43945c linter/consistent-function-scoping: Allow functions passed as
arguments (#5011) (Don Isaac)
- 9354779 linter/no-unused-vars: Give `argsIgnorePattern` the same
default behavior as `varsIgnorePattern` (#5018) (DonIsaac)
- 5a55dcf linter/no-unused-vars: `type` specifier not deleted for type
imports (#5029) (DonIsaac)
- 4081293 linter/no-unused-vars: Panic in fixer when removing
destructures (#4923) (Don Isaac)
- ddf83ff linter/react: Fixed false positive with missing key inside
React.Children.toArray() (#4945) (Earl Chase)
- 508644a linter/tree-shaking: Correct the calculation of `>>`, `<<` and
`>>>` (#4932) (mysteryven)
- e99836d linter/unicorn: Allow set spreading in no-useless-spread
(#4944) (Don Isaac)
- 5f8a7c2 oxlint: Rules in the configuration file are not being
correctly … (#4949) (dalaoshu)

### Documentation

- e331ca0 linter: Improve documentation for several rules (#4997)
(DonIsaac)
- cd9f1cd linter/consistent-function-scoping: Improve rule documentation
(#5015) (DonIsaac)

### Refactor

- eca6fdb linter: Move plugin options into separate struct (#5100)
(DonIsaac)
- 06f2d81 linter: Avoid unnecessary temp `Vec`s (#4963) (overlookmotel)
- 4cb8c37 linter: Move default_true to utils (#4947) (Don Isaac)
- ca70cc7 linter, mangler, parser, semantic, transformer, traverse,
wasm: Rename various `flag` vars to `flags` (#5028) (overlookmotel)
- 59d15c7 semantic: `root_unresolved_references` contain only
`ReferenceId` (#4959) (overlookmotel)

### Testing

- c21d735 linter/no-unused-vars: Add ignored destructuring test cases
(#4922) (Don Isaac)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-23 11:09:14 +08:00
DonIsaac
eca6fdbffe refactor(linter): move plugin options into separate struct (#5100)
Part of #5046
2024-08-23 00:01:21 +00:00
Don Isaac
841174f73c
feat(linter/no-unused-vars): delete non-root arrows, skip await (#5083)
This PR updates no-unused-var's fixer for `VariableDeclarator`s in two
ways:
1. Unused function expressions and arrow functions not declared in the
top scope
   will now be removed.
   ```ts
   // not deleted, no change
   const x = function() {}
   const y = (a) => a
   function z() {}

   // new behavior
   function foo() {            // <- not deleted
       const x = () => {}      // <- deleted
       const y = function() {} // <- this too
   }
   ```
2. Variables initialized to an `await` expression will not be deleted.
   ```ts
// unused await-initialized variables are often API calls with side
effects
   // in the real world; we don't want to delete these.
   const res = await createUser(data)
   ```
2024-08-22 11:48:27 -04:00
dalaoshu
f1e46116de
feat(linter/eslint-plugin-vitest): implement no-conditional-in-test (#4971)
Related to #4656
2024-08-22 08:15:32 +08:00
dalaoshu
14bf5d5177
feat(linter/eslint-plugin-vitest): implement no-restricted-vi-methods (#4956)
Related to #4656
2024-08-22 08:07:53 +08:00
Earl Chase
ddf83ff1b9
fix(linter/react): Fixed false positive with missing key inside React.Children.toArray() (#4945)
Closes: #4421 

Added three new functions in order to check if an element is inside of
React.Children.toArray.
Tests added for this fix are exactly the same as those used by
eslint-plugin-react.
2024-08-22 08:05:14 +08:00
DonIsaac
cd9f1cd278 docs(linter/consistent-function-scoping): improve rule documentation (#5015) 2024-08-21 00:47:17 +00:00
overlookmotel
5f4c9ab38e refactor(semantic)!: rename SymbolTable::get_flag to get_flags (#5030)
Part of #4991.
2024-08-21 00:19:58 +00:00
overlookmotel
ca70cc7c03 refactor(linter, mangler, parser, semantic, transformer, traverse, wasm): rename various flag vars to flags (#5028)
Part of #4991.
2024-08-21 00:19:58 +00:00
DonIsaac
9354779ad4 fix(linter/no-unused-vars): give argsIgnorePattern the same default behavior as varsIgnorePattern (#5018) 2024-08-21 00:15:10 +00:00
DonIsaac
5a55dcf39b fix(linter/no-unused-vars): type specifier not deleted for type imports (#5029)
fixes a bug in eslint/no-unused-vars where, when unused type imports were deleted, the `type` modifier was not.
2024-08-21 00:11:45 +00:00
camc314
2292606a1f feat(linter): typescript-eslint/no-wrapper-object-types (#5022) 2024-08-20 21:45:38 +00:00
Don Isaac
c43945c808
fix(linter/consistent-function-scoping): allow functions passed as arguments (#5011) 2024-08-20 17:00:50 -04:00
DonIsaac
86d0c0cb62 fix(linter): change consistent-function-scoping to suspicious (#5010) 2024-08-20 16:22:30 +00:00
Boshen
ce4d4698b4 feat(codegen)!: remove const generic MINIFY (#5001)
This is a premature optimization, makes the code complicated, and bloats the final binary size.

The minify option is moved to `CodegenOptions`
2024-08-20 08:13:27 +00:00
Boshen
b2ff2df5af refactor(parser)!: remove builder pattern from Parser struct (#5000)
part of #4455

use `with_options(ParseOptions { ..ParseOptions::default() })` API instead.
2024-08-20 07:40:25 +00:00
dalaoshu
ed9a1c499b
feat(linter/eslint-plugin-vitest): implement require-local-test-context-for-concurrent-snapshots (#4951)
Related to #4656

---------

Co-authored-by: Wang Wenzhe <mysteryven@gmail.com>
2024-08-20 13:41:35 +08:00
Burlin
f88970bc79
refactor(ast)!: Change order of fields in CallExpression (#4859)
fix: #4821

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-08-20 09:47:12 +08:00
DonIsaac
e331ca0a9d docs(linter): improve documentation for several rules (#4997) 2024-08-20 00:55:48 +00:00
camc314
dd38a32ba6 feat(linter) expand jsx-props-no-spread-multi to catch member expressions (#4981)
closes #4894
2024-08-19 20:32:12 +00:00
DonIsaac
7b99386071 fix(linter): missing closing ticks in some example blocks (#4994)
These broken example blocks breaks codegen for the upstream PR in this stack.
2024-08-19 20:25:14 +00:00
Don Isaac
a0effab160
feat(linter): support more flexible config.globals values (#4990)
Support `"readable", `"writable"`, and boolean values for `GlobalValue`.

I also enhanced the documentation for `OxcGlobals`

## Screenshot
<img width="797" alt="image"
src="https://github.com/user-attachments/assets/8f76de4c-4ae8-44d1-9be1-720fc3c7e0ec">
2024-08-19 16:23:47 -04:00
camc314
247120f9ad feat(linter) eslint-plugin-unicorn consistent function scoping (#4948) 2024-08-19 03:29:29 +00:00
dalaoshu
7859f58b4e
feat(linter/eslint-plugin-vitest): implement no-conditional-tests (#4955) 2024-08-18 23:23:36 -04:00
overlookmotel
06f2d818fe refactor(linter): avoid unnecessary temp Vecs (#4963)
Use iterator instead of collecting into temporary `Vec` which is then iterated over.
2024-08-19 01:32:06 +00:00
overlookmotel
59d15c7086 refactor(semantic): root_unresolved_references contain only ReferenceId (#4959)
`ScopeTree::root_unresolved_references` does not need to record `ReferenceFlag` as well as `ReferenceId` - it's never read.
2024-08-19 01:32:04 +00:00
DonIsaac
cdbfcfb39a feat(linter): start import fixer for eslint/no-unused-vars (#4849) 2024-08-18 23:10:01 +00:00
dalaoshu
5f8a7c22e4
fix(oxlint): rules in the configuration file are not being correctly … (#4949)
closes #4701 

BTW, which one should have higher priority between the rules in the
command line and those in the configuration file? Is the current design
reasonable?
2024-08-18 14:16:43 +08:00
camc314
915cb4d5a3 feat(linter): add dangerous fixer for oxc only used in recursion (#4805) 2024-08-18 01:19:37 +00:00
Don Isaac
4cb8c3771f
refactor(linter): move default_true to utils (#4947) 2024-08-17 14:09:58 -04:00
DonIsaac
3f28c77eb6 feat(linter/eslint): improve no-dupe-keys (#4943)
- make labels in diagnostics more user-friendly
- improve examples in documentation
2024-08-17 01:25:26 +00:00
DonIsaac
e1582a5dd3 feat(linter/eslint): improve no-duplicate-case rule (#4942)
- ignore parethesis when comparing case test expressions
- make labels in diagnostics more friendly
- add more examples to documentation
2024-08-17 01:21:49 +00:00
Don Isaac
e99836d7d8
fix(linter/unicorn): allow set spreading in no-useless-spread (#4944)
Closes #4872
2024-08-16 16:33:18 -04:00
mysteryven
508644a34e fix(linter/tree-shaking): correct the calculation of >>, << and >>> (#4932)
fixes: #4914
2024-08-16 02:33:48 +00:00
Burlin
9c64b12963
fix(linter): improve no-zero-fractions rule for member expressions and scientific notation (#4793) 2024-08-15 21:24:08 -04:00
Don Isaac
4081293ce7
fix(linter/no-unused-vars): panic in fixer when removing destructures (#4923)
Closes #4839
2024-08-15 17:30:33 -04:00
Don Isaac
c21d735c3d
test(linter/no-unused-vars): add ignored destructuring test cases (#4922)
Add test cases that cover #4888. I can't reproduce the issue this way,
so I'll try running oxlint as a CLI instead. These test cases will be
useful to have in our repo anyways.
2024-08-15 17:03:08 -04:00
oxc-bot
b3e189764f
Release oxlint v0.7.2 (#4909)
## [0.7.2] - 2024-08-15

### Features

- 97e38cd linter: Add fixer for unicorn/prefer-optional-catch-binding
(#4867) (heygsc)
- 93ae1c7 linter: Eslint-plugin-react jsx-props-no-spread-multi (#4866)
(keita hino)
- 0a23610 linter: Add fixer for unicorn/prefer-array-flat-map (#4844)
(heygsc)
- 13c7b1b linter/jsx-a11y: Add fixer for aria-unsupported-elements
(#4854) (DonIsaac)
- a6195a6 linter/jsx-a11y: Add fixer for anchor-has-content (#4852)
(DonIsaac)
- 4d28d03 task/website: Support render `subschemas.all_of` (#4800)
(mysteryven)

### Bug Fixes

- 21f5762 codegen: Minify large numbers (#4889) (Boshen)
- a08d7a7 linter/jsx-a11y: Reduce false negatives for html-has-lang
(#4855) (DonIsaac)
- a81ce3a linter/no-unused-vars: Do not delete function expressions when
fixing (#4848) (DonIsaac)

### Documentation

- 955a4b4 oxlint: Improve cli doc regarding fix and `-D all` (Boshen)

### Refactor

- 56f033c linter: Improve diagnostics for several jsx-a11y rules (#4853)
(DonIsaac)
- c53c210 linter/no-unused-vars: Split fixer logic into multiple files
(#4847) (DonIsaac)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-15 14:56:34 +08:00
heygsc
97e38cd493
feat(linter): add fixer for unicorn/prefer-optional-catch-binding (#4867) 2024-08-14 08:17:11 -04:00
keita hino
93ae1c78b8
feat(linter): eslint-plugin-react jsx-props-no-spread-multi (#4866)
partof: https://github.com/oxc-project/oxc/issues/1022

docs:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md
code:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/jsx-props-no-spread-multi.js
test:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/tests/lib/rules/jsx-props-no-spread-multi.js

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-08-14 12:44:46 +01:00
Boshen
21f576252a fix(codegen): minify large numbers (#4889) 2024-08-14 06:52:17 +00:00
mysteryven
4d28d037e6 feat(task/website): support render subschemas.all_of (#4800)
To solve unexpected snapshot update in #4742  : https://github.com/oxc-project/oxc/pull/4742/files#diff-4c1a03dc03cfd00f9eaecb5c66b61f4e57272c6262253f0dc82ea1b71223bac2
2024-08-14 06:12:03 +00:00
rzvxa
c164bb8b64 chore(deps): remove static_assertions dependency. (#4883) 2024-08-14 02:18:06 +00:00
heygsc
a105df3adf
chore(linter): fix comment (#4860) 2024-08-12 23:44:49 -04:00
DonIsaac
a08d7a7f94 fix(linter/jsx-a11y): reduce false negatives for html-has-lang (#4855) 2024-08-13 03:31:33 +00:00
DonIsaac
13c7b1b9d2 feat(linter/jsx-a11y): add fixer for aria-unsupported-elements (#4854) 2024-08-13 03:31:31 +00:00
DonIsaac
56f033c556 refactor(linter): improve diagnostics for several jsx-a11y rules (#4853) 2024-08-13 03:31:29 +00:00
DonIsaac
a6195a6a77 feat(linter/jsx-a11y): add fixer for anchor-has-content (#4852)
Add a conditional fix that removes `aria-hidden` from an anchor's child if there
is only a single child. This PR also fixes a false positive on hidden anchors.
It should report visible anchors with hidden content, not hidden anchors.
2024-08-13 03:31:27 +00:00
DonIsaac
a81ce3a3c7 fix(linter/no-unused-vars): do not delete function expressions when fixing (#4848)
`VariableDeclarator` fixer will no longer delete declarations that are initialized to function expressions.

```ts
// none of these get deleted
const unusedArrow = () => {}
const unusedAnon = function() {}
const unusedNamed = function foo() {}

// matches fixer behavior for function declarations
function unusedDecl() {}
```
2024-08-13 02:31:34 +00:00
DonIsaac
c53c210efc refactor(linter/no-unused-vars): split fixer logic into multiple files (#4847) 2024-08-13 02:31:33 +00:00
heygsc
0a23610d9a
feat(linter): add fixer for unicorn/prefer-array-flat-map (#4844) 2024-08-12 08:35:27 -04:00
oxc-bot
972492cc4d
Release oxlint v0.7.1 (#4835)
## [0.7.1] - 2024-08-12

### Features

- 3d40528 linter: Add fix emoji to rules table and doc pages (#4715)
(DonIsaac)
- d2734f3 linter: Start fixer for no-unused-vars (#4718) (DonIsaac)
- 070ae53 linter: Add fixer for unicorn prefer-string-replace-all
(#4801) (camc314)
- b3c3125 linter: Overhaul unicorn/no-useless-spread (#4791) (DonIsaac)
- 5992b75 linter: Implement `eslint-plugin-promise/no-return-in-finally,
prefer-await-to-then` rule (#4318) (Jelle van der Waa)
- b259f47 linter: Add fixer for unicorn/no-length-as-slice-end (#4780)
(heygsc)
- abd83fa linter: Add fixer for jsx_ally/no_aria_hidden_on_focusable
(#4772) (heygsc)
- b20e335 linter: Add fixer for eslint/no-eq-null (#4758) (heygsc)
- 2f6c3b9 linter: Add fixer for eslint/no-compare-neg-zero (#4748)
(heygsc)
- eaddc8f linter: Add fixer for eslint/func_names (#4714) (DonIsaac)
- 80557a9 linter: Add fixer for eslint/for-direction (#4679) (heygsc)
- c3c5766 linter/eslint-plugin-promise: Implement valid-params (#4598)
(Jelle van der Waa)
- c509a21 linter/eslint-plugin-vitest: Implement prefer-to-be-falsy
(#4770) (dalaoshu)
- 41f861f linter/eslint-plugin-vitest: Implement prefer-to-be-truthy
(#4755) (dalaoshu)
- cc922f4 vscode: Provide config's schema to oxlint config files (#4826)
(Don Isaac)
- f629514 website: Auto-generate rule docs pages (#4640) (DonIsaac)

### Bug Fixes

- b22ed45 linter: Improve prefer_namespace_keyword rule (#4751) (Burlin)
- db68a6c linter: Fixer for eslint/for-direction (#4727) (heygsc)
- 6273994 linter: Block in eslint/no_cond_assign (#4721) (heygsc)
- b9d6aa5 linter: Fix false positives in no-confusing-non-null-assertion
(#4665) (Renée)
- cbf08d2 linter: Skip no-multi-str on jsx attributes (#4666) (heygsc)
- a6f9f96 linter: No unused errors should be warnings (Boshen)
- 7345bc9 linter/func-names: Handle ts accessibility when reporting
missing names (#4713) (DonIsaac)

### Performance

- d191823 linter: Optmize allocations in jest fn parsing (#4787) (lucab)
- e3abdfa linter: Reduce String allocations and clones (#4673)
(DonIsaac)

### Documentation

- 4b7dfd6 linter: Correct docs for no-unused-vars (#4716) (Don Isaac)

### Refactor

- 096ac7b linter: Clean up jsx-a11y/anchor-is-valid (#4831) (DonIsaac)
- 15a0fd4 linter: Use Option to reduce nested level in
`eslint/getter-return` (#4814) (IWANABETHATGUY)
- 63f274c linter: Simplify NoObjCalls resolution logic (#4765) (lucab)
- 6708680 linter: Replace Windows-style line breaks with Unix-style in
test fixture (#4768) (overlookmotel)
- e285903 linter: Clean up eslint/func_names (#4710) (DonIsaac)

### Testing

- 8f2a566 linter: Ensure rule docs have valid syntax (#4644) (DonIsaac)
- 4dd29db linter: Add fixer test for unicorn/no-zero-fractions (#4783)
(heygsc)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-12 13:36:37 +08:00
Boshen
505d39ba0a
chore: bump deps 2024-08-12 10:12:34 +08:00
Don Isaac
cc922f4c89
feat(vscode): provide config's schema to oxlint config files (#4826)
Updates the VSCode plugin client to automatically provide our
auto-generated
JSON schema to `\.?oxlint(rc)?(\.json)?` files.
2024-08-12 09:15:47 +08:00
DonIsaac
096ac7bee5 refactor(linter): clean up jsx-a11y/anchor-is-valid (#4831) 2024-08-12 01:11:54 +00:00
camc314
4e818a434c feat(linter) support arrow functions in oxc only used in recursion (#4816) 2024-08-11 12:50:48 +00:00
DonIsaac
3d40528588 feat(linter): add fix emoji to rules table and doc pages (#4715)
Rules table:
<img width="898" alt="image" src="https://github.com/user-attachments/assets/353052aa-0af3-4c09-8441-ff79f4561ca0">

Doc pages:
<img width="918" alt="image" src="https://github.com/user-attachments/assets/cb43cb2d-15ff-41e6-8523-145cfbc3f484">
2024-08-10 22:50:47 +00:00
IWANABETHATGUY
15a0fd4f7e
refactor(linter): use Option to reduce nested level in eslint/getter-return (#4814)
1. Simplify `is_wanted_node`
2024-08-10 16:44:30 -04:00
camc314
d7fce589f8 feat(linter) add suggestion fix for oxc missing throw (#4806) 2024-08-10 16:13:44 +00:00
DonIsaac
d2734f3bc4 feat(linter): start fixer for no-unused-vars (#4718)
Start to add dangerous suggestions for `no-unused-vars`. This PR focuses on fixing unused variable declarations.
- declarations with no references of any kind will be removed with a `FixKind` of dangerous suggestion.
- declarations with some usages will be renamed when the rule is configured with certain `"varsIgnorePattern"`s with a `FixKind` of dangerous fix.
2024-08-10 15:27:12 +00:00
camc314
070ae53ad6 feat(linter): add fixer for unicorn prefer-string-replace-all (#4801) 2024-08-10 14:46:12 +00:00
DonIsaac
8f2a566f9f test(linter): ensure rule docs have valid syntax (#4644)
Adds tests for rule documentation by
1. Compiling doc markdown into HTML, which ensures docs use valid markdown syntax
2. Converts the generated HTML into JSX and parses the results with the parser, ensuring the generated HTML is valid

Has the added benefit of adding a lot of JSX test cases to the parser. I've also fixed all violations for these tests in this PR.
2024-08-10 05:03:09 +00:00
DonIsaac
b3c3125138 feat(linter): overhaul unicorn/no-useless-spread (#4791)
I got tired of seeing useless spreads on ternaries and `arr.reduce()` within my company's internal codebase so I overhauled this rule.

## Changes
- add fixer for object spreads
  ```js
  const before = { a, ...{ b, c }, d }
  const after = { a,  b, c, d } // fixer does not dedupe spaces before `b`
  ```
- recursively check for useless clones on complex expressions. This rule now catches and auto-fixes the following cases:
   ```js
  // ternaries when both branches create a new array or object
   const obj = { ...(foo ? { a: 1 } : { b: 2 }) }
  // recursive, so this can support complex cases
  const arr = [ ...(foo ? a.map(fn) : bar ? Array.from(iter) : await Promise.all(bar)) ]
  // reduce functions where the initial accumulator creates a new object or array
   const obj = { ...(arr.reduce(fn, {}) }
  ```
2024-08-10 04:50:09 +00:00
Jelle van der Waa
5992b7575e
feat(linter): implement eslint-plugin-promise/no-return-in-finally, prefer-await-to-then rule (#4318)
Part of https://github.com/oxc-project/oxc/pull/4252

---------

Co-authored-by: wenzhe <mysteryven@gmail.com>
2024-08-10 10:41:29 +08:00
DonIsaac
f62951411d feat(website): auto-generate rule docs pages (#4640)
> AI-generated description because I'm lazy
### TL;DR

This PR introduces the ability to generate documentation for linter rules and adds new methods and metadata for rule fix capabilities.

To see what this looks like, please check out https://github.com/oxc-project/oxc-project.github.io/pull/165.

## Screenshots
Hyperlinks to rule doc pages in auto-generated rules table
<img width="809" alt="image" src="https://github.com/user-attachments/assets/e09eb47d-e86a-4ed1-b1f9-5034f33c71a2">

Example of a docs page
<img width="1273" alt="image" src="https://github.com/user-attachments/assets/78f7e9e6-f4dd-4cc9-aebc-1cdd64b024ec">

### What changed?

- Added `RuleFixMeta` to indicate rule fix capabilities
- Introduced methods `is_none` and `is_pending` in `RuleFixMeta`
- Modified `render_markdown_table` in `RuleTableSection` to accept an optional link prefix
- Created new modules for rule documentation and HTML rendering
- Updated `print_rules` function to generate markdown for rules and detailed documentation pages

### How to test?

Run the `linter-rules` task with appropriate arguments to generate the markdown table and documentation pages.
Verify the generated files for correctness and that all metadata is correctly displayed.

### Why make this change?

To enhance the project documentation and provide clear rule fix capabilities, thereby improving the developer experience and easing the integration process.

---
2024-08-10 00:13:06 +00:00
lucab
d191823a0a perf(linter): optmize allocations in jest fn parsing (#4787) 2024-08-10 00:09:27 +00:00
heygsc
4dd29dbc2b
test(linter): add fixer test for unicorn/no-zero-fractions (#4783)
Add fixer test.
Some of them have not passed yet, so I have temporarily made comments as
todo.
2024-08-09 16:46:24 +03:30
Jelle van der Waa
c3c5766601
feat(linter/eslint-plugin-promise): implement valid-params (#4598) 2024-08-09 09:02:51 -04:00
heygsc
b259f47007
feat(linter): add fixer for unicorn/no-length-as-slice-end (#4780)
part of #4179 

test:
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/test/snapshots/no-length-as-slice-end.mjs.md
2024-08-09 15:11:52 +03:30
Burlin
b22ed4512d
fix(linter): improve prefer_namespace_keyword rule (#4751)
fix: #4651
This commit enhances the `prefer_namespace_keyword` rule in the
TypeScript linter: Add support for detecting and fixing nested module
declarations (e.g., module A.B {})

- Introduce helper functions `is_nest_module`, `is_valid_module`, and
`is_invalid_module` to improve code readability and maintainability
- Refactor the main `run` function to use these new helper functions
- Update test cases to cover nested module scenarios
- Improve error reporting for nested modules
2024-08-09 11:46:50 +03:30