Commit graph

1966 commits

Author SHA1 Message Date
Boshen
4d8a08d2ac feat(minifier): improve constant evaluation (#8252) 2025-01-05 12:41:57 +00:00
camc314
3c534aeb5a refactor(linter): refactor LintBuilder to prep for nested configs (#8034)
More simplification/preparations for nested configurations:

1. renames `LinterBuilder` to `ConfigStoreBuilder`
2. moves the `options` logic out of `LintBuilder`
3. make `ConfigStoreBuilder::build()` return a result (currently always returns OK, but it will return errors when nested config is implemented

The next steps to implement nested config which i hope to do in the next week are:
1. refactor the `from_oxlintrc` to accept a file path
2. introduce a new method on `ConfigStoreBuilder` (name TBC) that walks all child directories, collecting `.oxlintrc` files. these will be put into `ConfigStore` as a hash map of path > config.
2025-01-05 04:08:26 +00:00
Boshen
2f52f333fa feat(minifier): minsize !!!foo ? bar : baz -> foo ? baz : bar (#8244) 2025-01-04 09:10:22 +00:00
Boshen
ce2b5a994b chore(minifier): disable RemoveUnusedCode (#8243)
A lot of edge cases fail in test262 and monitor-oxc.
2025-01-04 08:49:20 +00:00
Boshen
ad9a0a9c4a feat(mininifier): minimize variants of a instanceof b == true (#8241) 2025-01-04 06:04:52 +00:00
Boshen
ccdc039f54 feat(minifier): always put literals on the rhs of equal op 1==x => x==1 (#8240) 2025-01-04 04:07:54 +00:00
Boshen
bf0fbcea6e refactor(minifier): improve constant fold numbers (#8239)
Ported esbuild's implementation
2025-01-04 03:30:20 +00:00
Cameron
39353b22e9
feat(minifier): improve minimizing conditionals (#8238) 2025-01-04 08:36:54 +08:00
camc314
c90fc16bba feat(minifier): restore conditional minification and fix edge case (#8235)
This restore's the changes made in #8233, but fixing the edge cases.

If the conditional expression is not a child of an `IfStatementTest`, `WhileStatementTest`, `DoWhileStatementText` or `ExpressionStatementExpression`, we must coerce the test to a boolean.
2025-01-03 14:20:42 +00:00
Boshen
6c8ee9fdef feat(minifier): remove last redundant return statement (#8234) 2025-01-03 12:24:57 +00:00
Boshen
a698deff51 fix(minifier): fix incorrect return value for (x ? true : y) (#8233)
Need to check if the return value is used or not:

```
function foo() {
    return foo ? true : bar; // no transformed
}

foo ? true : bar; // transformed to `foo || bar;`
```
2025-01-03 11:58:28 +00:00
Boshen
51f47926ef feat(minifier): minimize foo ? foo : bar and foo ? bar : foo (#8229) 2025-01-03 10:55:59 +00:00
Boshen
6e2ec17d51 feat(minifier): statement fusion switch cases; improved minimize exit poitns (#8228) 2025-01-03 10:07:04 +00:00
Boshen
574a2428fd feat(minifier): minimize all variants of typeof x == 'undefined' (#8227) 2025-01-03 07:05:55 +00:00
Boshen
2041477f51 feat(minifier): fold if(x)return;y -> if(!x)y (#8226) 2025-01-03 05:24:53 +00:00
Alexander S.
37d31ecef9
fix(tasks/lint_rules): sync unicorn rules with eslint rules (#8224)
👀 promise/spec-only is implemented but not found in their rules
👀 unicorn/consistent-existence-index-check is implemented but not found
in their rules
👀 unicorn/prefer-math-min-max is implemented but not found in their
rules

> [!WARNING]
> This comment is maintained by CI. Do not edit this comment directly.
> To update comment template, see
https://github.com/oxc-project/oxc/tree/main/tasks/lint_rules

This is tracking issue for `eslint-plugin-unicorn`.


There are 120(+ 17 deprecated) rules.

- 24/113 recommended rules are remaining as TODO
- 7/7 not recommended rules are remaining as TODO


To get started, run the following command:

```sh
just new-unicorn-rule <RULE_NAME>
```

Then register the rule in `crates/oxc_linter/src/rules.rs` and also
`declare_all_lint_rules` at the bottom.


## Recommended rules

<details open>
<summary>
  : 89, 🚫: 0 / total: 113
</summary>

| Status | Name | Docs |
| :----: | :--- | :--- |
| | unicorn/better-regex |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/better-regex.md
|
|  | unicorn/catch-error-name |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/catch-error-name.md
|
|  | unicorn/consistent-empty-array-spread |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/consistent-empty-array-spread.md
|
|  | unicorn/consistent-function-scoping |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/consistent-function-scoping.md
|
|  | unicorn/empty-brace-spaces |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/empty-brace-spaces.md
|
|  | unicorn/error-message |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/error-message.md
|
|  | unicorn/escape-case |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/escape-case.md
|
| | unicorn/expiring-todo-comments |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/expiring-todo-comments.md
|
|  | unicorn/explicit-length-check |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/explicit-length-check.md
|
|  | unicorn/filename-case |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/filename-case.md
|
| | unicorn/import-style |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/import-style.md
|
|  | unicorn/new-for-builtins |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/new-for-builtins.md
|
|  | unicorn/no-abusive-eslint-disable |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-abusive-eslint-disable.md
|
|  | unicorn/no-anonymous-default-export |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-anonymous-default-export.md
|
| | unicorn/no-array-callback-reference |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-array-callback-reference.md
|
|  | unicorn/no-array-for-each |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-array-for-each.md
|
| | unicorn/no-array-method-this-argument |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-array-method-this-argument.md
|
| | unicorn/no-array-push-push |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-array-push-push.md
|
|  | unicorn/no-array-reduce |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-array-reduce.md
|
|  | unicorn/no-await-expression-member |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-await-expression-member.md
|
|  | unicorn/no-await-in-promise-methods |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-await-in-promise-methods.md
|
|  | unicorn/no-console-spaces |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-console-spaces.md
|
|  | unicorn/no-document-cookie |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-document-cookie.md
|
|  | unicorn/no-empty-file |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-empty-file.md
|
| | unicorn/no-for-loop |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-for-loop.md
|
|  | unicorn/no-hex-escape |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-hex-escape.md
|
|  | unicorn/no-instanceof-array |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-instanceof-array.md
|
| | unicorn/no-invalid-fetch-options |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-invalid-fetch-options.md
|
|  | unicorn/no-invalid-remove-event-listener |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-invalid-remove-event-listener.md
|
|  | unicorn/no-length-as-slice-end |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-length-as-slice-end.md
|
|  | unicorn/no-lonely-if |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-lonely-if.md
|
|  | unicorn/no-magic-array-flat-depth |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-magic-array-flat-depth.md
|
|  | unicorn/no-negated-condition |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-negated-condition.md
|
|  | unicorn/no-negation-in-equality-check |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-negation-in-equality-check.md
|
|  | unicorn/no-nested-ternary |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-nested-ternary.md
|
|  | unicorn/no-new-array |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-new-array.md
|
|  | unicorn/no-new-buffer |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-new-buffer.md
|
|  | unicorn/no-null |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-null.md
|
|  | unicorn/no-object-as-default-parameter |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-object-as-default-parameter.md
|
|  | unicorn/no-process-exit |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-process-exit.md
|
|  | unicorn/no-single-promise-in-promise-methods |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-single-promise-in-promise-methods.md
|
|  | unicorn/no-static-only-class |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-static-only-class.md
|
|  | unicorn/no-thenable |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-thenable.md
|
|  | unicorn/no-this-assignment |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-this-assignment.md
|
|  | unicorn/no-typeof-undefined |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-typeof-undefined.md
|
|  | unicorn/no-unnecessary-await |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-unnecessary-await.md
|
| | unicorn/no-unnecessary-polyfills |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-unnecessary-polyfills.md
|
|  | unicorn/no-unreadable-array-destructuring |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-unreadable-array-destructuring.md
|
|  | unicorn/no-unreadable-iife |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-unreadable-iife.md
|
|  | unicorn/no-useless-fallback-in-spread |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-useless-fallback-in-spread.md
|
|  | unicorn/no-useless-length-check |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-useless-length-check.md
|
|  | unicorn/no-useless-promise-resolve-reject |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-useless-promise-resolve-reject.md
|
|  | unicorn/no-useless-spread |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-useless-spread.md
|
|  | unicorn/no-useless-switch-case |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-useless-switch-case.md
|
|  | unicorn/no-useless-undefined |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-useless-undefined.md
|
|  | unicorn/no-zero-fractions |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-zero-fractions.md
|
|  | unicorn/number-literal-case |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/number-literal-case.md
|
|  | unicorn/numeric-separators-style |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/numeric-separators-style.md
|
|  | unicorn/prefer-add-event-listener |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-add-event-listener.md
|
| | unicorn/prefer-array-find |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-array-find.md
|
|  | unicorn/prefer-array-flat-map |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-array-flat-map.md
|
|  | unicorn/prefer-array-flat |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-array-flat.md
|
| | unicorn/prefer-array-index-of |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-array-index-of.md
|
|  | unicorn/prefer-array-some |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-array-some.md
|
| | unicorn/prefer-at |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-at.md
|
|  | unicorn/prefer-blob-reading-methods |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-blob-reading-methods.md
|
|  | unicorn/prefer-code-point |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-code-point.md
|
|  | unicorn/prefer-date-now |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-date-now.md
|
| | unicorn/prefer-default-parameters |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-default-parameters.md
|
|  | unicorn/prefer-dom-node-append |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-dom-node-append.md
|
|  | unicorn/prefer-dom-node-dataset |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-dom-node-dataset.md
|
|  | unicorn/prefer-dom-node-remove |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-dom-node-remove.md
|
|  | unicorn/prefer-dom-node-text-content |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-dom-node-text-content.md
|
|  | unicorn/prefer-event-target |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-event-target.md
|
| | unicorn/prefer-export-from |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-export-from.md
|
|  | unicorn/prefer-includes |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-includes.md
|
| | unicorn/prefer-keyboard-event-key |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-keyboard-event-key.md
|
|  | unicorn/prefer-logical-operator-over-ternary |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-logical-operator-over-ternary.md
|
|  | unicorn/prefer-math-trunc |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-math-trunc.md
|
|  | unicorn/prefer-modern-dom-apis |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-modern-dom-apis.md
|
|  | unicorn/prefer-modern-math-apis |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-modern-math-apis.md
|
| | unicorn/prefer-module |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-module.md
|
|  | unicorn/prefer-native-coercion-functions |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-native-coercion-functions.md
|
|  | unicorn/prefer-negative-index |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-negative-index.md
|
|  | unicorn/prefer-node-protocol |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-node-protocol.md
|
|  | unicorn/prefer-number-properties |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-number-properties.md
|
| | unicorn/prefer-object-from-entries |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-object-from-entries.md
|
|  | unicorn/prefer-optional-catch-binding |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-optional-catch-binding.md
|
|  | unicorn/prefer-prototype-methods |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-prototype-methods.md
|
|  | unicorn/prefer-query-selector |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-query-selector.md
|
|  | unicorn/prefer-reflect-apply |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-reflect-apply.md
|
|  | unicorn/prefer-regexp-test |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-regexp-test.md
|
|  | unicorn/prefer-set-has |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-set-has.md
|
|  | unicorn/prefer-set-size |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-set-size.md
|
| | unicorn/prefer-spread |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-spread.md
|
|  | unicorn/prefer-string-raw |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-string-raw.md
|
|  | unicorn/prefer-string-replace-all |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-string-replace-all.md
|
|  | unicorn/prefer-string-slice |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-string-slice.md
|
|  | unicorn/prefer-string-starts-ends-with |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-string-starts-ends-with.md
|
|  | unicorn/prefer-string-trim-start-end |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-string-trim-start-end.md
|
|  | unicorn/prefer-structured-clone |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-structured-clone.md
|
| | unicorn/prefer-switch |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-switch.md
|
| | unicorn/prefer-ternary |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-ternary.md
|
| | unicorn/prefer-top-level-await |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-top-level-await.md
|
|  | unicorn/prefer-type-error |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-type-error.md
|
| | unicorn/prevent-abbreviations |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prevent-abbreviations.md
|
| | unicorn/relative-url-style |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/relative-url-style.md
|
|  | unicorn/require-array-join-separator |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/require-array-join-separator.md
|
|  | unicorn/require-number-to-fixed-digits-argument |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/require-number-to-fixed-digits-argument.md
|
|  | unicorn/switch-case-braces |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/switch-case-braces.md
|
| | unicorn/template-indent |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/template-indent.md
|
|  | unicorn/text-encoding-identifier-case |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/text-encoding-identifier-case.md
|
|  | unicorn/throw-new-error |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/throw-new-error.md
|

 = Implemented, 🚫 = No need to implement

</details>


## Not recommended rules

<details open>
<summary>
  : 0, 🚫: 0 / total: 7
</summary>

| Status | Name | Docs |
| :----: | :--- | :--- |
| | unicorn/consistent-destructuring |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/consistent-destructuring.md
|
| | unicorn/custom-error-definition |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/custom-error-definition.md
|
| | unicorn/no-keyword-prefix |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-keyword-prefix.md
|
| | unicorn/no-unused-properties |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/no-unused-properties.md
|
| | unicorn/prefer-json-parse-buffer |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/prefer-json-parse-buffer.md
|
| | unicorn/require-post-message-target-origin |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/require-post-message-target-origin.md
|
| | unicorn/string-content |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/rules/string-content.md
|

 = Implemented, 🚫 = No need to implement

</details>


## Deprecated rules

<details >
<summary>
  : 0, 🚫: 0 / total: 17
</summary>

| Status | Name | Docs |
| :----: | :--- | :--- |
| | unicorn/import-index |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#import-index
|
| | unicorn/no-array-instanceof |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#no-array-instanceof
|
| | unicorn/no-fn-reference-in-iterator |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#no-fn-reference-in-iterator
|
| | unicorn/no-reduce |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#no-reduce
|
| | unicorn/no-unsafe-regex |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#no-unsafe-regex
|
| | unicorn/prefer-dataset |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-dataset
|
| | unicorn/prefer-event-key |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-event-key
|
| | unicorn/prefer-exponentiation-operator |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-exponentiation-operator
|
| | unicorn/prefer-flat-map |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-flat-map
|
| | unicorn/prefer-node-append |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-node-append
|
| | unicorn/prefer-node-remove |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-node-remove
|
| | unicorn/prefer-object-has-own |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-object-has-own
|
| | unicorn/prefer-replace-all |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-replace-all
|
| | unicorn/prefer-starts-ends-with |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-starts-ends-with
|
| | unicorn/prefer-text-content |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-text-content
|
| | unicorn/prefer-trim-start-end |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#prefer-trim-start-end
|
| | unicorn/regex-shorthand |
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v55.0.0/docs/deprecated-rules.md#regex-shorthand
|

 = Implemented, 🚫 = No need to implement

</details>
2025-01-03 11:39:51 +08:00
Boshen
2da4365fbe feat(parser): missing initializer in destructuring declaration inside for loop head (#8222)
closes #8220
2025-01-02 14:02:49 +00:00
Boshen
9c1afa4729 feat(minifier): optional catch binding when catch param is unused (#8221) 2025-01-02 13:20:49 +00:00
Boshen
2786dea164 feat(minifier): add RemoveUnusedCode (#8210) 2025-01-02 12:50:21 +00:00
Cameron
cd274eeb02
feat(minifier): minimize logical exprs (#8209) 2025-01-02 18:32:20 +08:00
Boshen
cd349a312d chore(tasks/coverage): do not run minifier in script mode (#8213) 2025-01-01 14:56:43 +00:00
Boshen
05be1fc639 fix(minifier): remove incorrect fold Expression::AssignmentExpression (#8211) 2025-01-01 05:44:01 +00:00
camc314
4ae15df042 feat(minifier): imprve more conditional expr minification with boolean lit (#8208) 2025-01-01 02:31:18 +00:00
camc314
3202b4fed0 feat(minifier): imprve conditional expr minification with boolean lit (#8207) 2025-01-01 02:31:18 +00:00
camc314
3b4501183c feat(minifier): handle conditional expr with boolean lit (#8206) 2025-01-01 02:31:17 +00:00
camc314
4c2059af29 feat(minifier): reverse negated conditional exprs (#8205) 2025-01-01 02:31:17 +00:00
Dunqing
e5ee38fdf1 chore(transformer): enable class-properties plugin (#7750)
Done!
2024-12-31 12:30:58 +00:00
Dunqing
0592a8b43f feat(transformer/class-properties): transform private in expression (#8202)
This PR support transforms `#prop in object` in class-properties to cover https://www.npmjs.com/package/@babel/plugin-transform-private-property-in-object  plugin does
2024-12-31 12:30:58 +00:00
Dunqing
80c16526fb chore(transformer): enable Babel's private-property-in-property plugin tests (#8201) 2024-12-31 12:30:57 +00:00
Dunqing
3c77ed1af1 feat(transform-conformance): support enabling all class-related plugins when any of them are enabled in update_fixtures (#8200)
The `class-properties` plugin supports all class-related plugins, so we need to ensure that once any of them are enabled, we also enable all class-related plugins.
2024-12-31 12:30:57 +00:00
Dunqing
ad77ad5c12 feat(transformer/class-properties): transform static/instance accessor methods (#8132)
This PR supports transforming private `getter` or `setter` methods, and the output is a little different from Babel's output, For example:

Input:
```js
class Cls {
  #prop = 0;

  get #accessor() {
    return this.#prop;
  }
  set #accessor(v) {
    console.log(arguments);
    this.#prop = v;
  }

  constructor() {
    console.log(this.#accessor)
    [this.#accessor] = [1];
  }
}
```

[Babel's output](https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=MYGwhgzhAEDCIwN4ChrQMQAcBOB7T0AvNAAwDcyq0A5gKYAuGYwwtUu2AFAJTQpppsDAK7YAdtHoALAJYQAdFjyYKaAL5UIDJizYQOnAG69-A4LjH6QteSFzVOYbNWEBbWmPoRuqgdLmKOPhE0Ia-GlTmlvTYwsD0BiZUaFFWNnYO_grozKzs2NzJ0ADaWYq5ehwAuiHFAIxV4cgaQA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&evaluate=false&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=&prettier=false&targets=&version=7.26.4&externalPlugins=%40babel%2Fplugin-transform-class-properties%407.25.9%2C%40babel%2Fplugin-transform-private-methods%407.25.9%2C%40babel%2Fplugin-external-helpers%407.25.9&assumptions=%7B%7D):
```js
var _prop = new WeakMap();
var _Cls_brand = new WeakSet();
class Cls {
  constructor() {
    babelHelpers.classPrivateMethodInitSpec(this, _Cls_brand);
    babelHelpers.classPrivateFieldInitSpec(this, _prop, 0);
    console.log(babelHelpers.classPrivateGetter(_Cls_brand, this, _get_accessor));
    [babelHelpers.classPrivateGetter(_Cls_brand, this, _get_accessor)] = [1];
  }
}
function _get_accessor(_this) {
  return babelHelpers.classPrivateFieldGet(_prop, _this);
}
function _set_accessor(_this2, v) {
  var _arguments = [].slice.call(arguments, 1);
  console.log(_arguments);
  babelHelpers.classPrivateFieldSet(_prop, _this2, v);
}
```

Oxc's output:
```js
var _prop = new WeakMap();
var _Cls_brand = new WeakSet();
class Cls {
        constructor() {
                babelHelpers.classPrivateMethodInitSpec(this, _Cls_brand);
                babelHelpers.classPrivateFieldInitSpec(this, _prop, 0);
                console.log(_get_accessor.call(babelHelpers.assertClassBrand(_Cls_brand, this)));
                [babelHelpers.toSetter(_set_accessor.bind(babelHelpers.assertClassBrand(_Cls_brand, this)), [])._] = [1];
        }
}
function _get_accessor() {
        return babelHelpers.classPrivateFieldGet2(_prop, this);
}
function _set_accessor(v) {
        console.log(arguments);
        babelHelpers.classPrivateFieldSet2(_prop, this, v);
}
```

### Main difference
```diff
// Babel
+ console.log(babelHelpers.classPrivateGetter(_Cls_brand, this, _get_accessor));
+ [babelHelpers.classPrivateGetter(_Cls_brand, this, _get_accessor)] = [1];

+ function _get_accessor(_this) {
+   return babelHelpers.classPrivateFieldGet(_prop, _this);
+ }

+ function _set_accessor(_this2, v) {
+   var _arguments = [].slice.call(arguments, 1);
+   console.log(_arguments);
+   babelHelpers.classPrivateFieldSet(_prop, _this2, v);
+ }

// Oxc
-  console.log(_get_accessor.call(babelHelpers.assertClassBrand(_Cls_brand, this)));- -
-  [babelHelpers.toSetter(_set_accessor.bind(babelHelpers.assertClassBrand(_Cls_brand, this)), [])._] = [1];

- function _get_accessor() {
-   return babelHelpers.classPrivateFieldGet2(_prop, this);
- }

- function _set_accessor(v) {
-   console.log(arguments);
-   babelHelpers.classPrivateFieldSet2(_prop, this, v);
- }
```

From the main differences, we can see that Babel handles `getter` and `setter` methods using `classPrivateGetter` and `classPrivateSetter` helper functions, which causes all use `this` and `arguments` needs to rewrite to use a temp var instead in `getter` and `setter` methods. This is unnecessary and is not an efficient transformation for us.

Instead, I adapt binding a `this` instead of passing in `this`, this way we don't need to rewrite anything. We can't control the `helper` library for now, so I just transformed the AST to bind `this`, in the future, we can create a helper function to do the same thing.
2024-12-31 12:30:56 +00:00
Dunqing
e405f79577 feat(transformer/class-properties): transform static private method invoking (#8117) 2024-12-31 12:30:56 +00:00
Dunqing
3303e9986b feat(transformer/class-properties): insert statements after statement of class expression (#8116) 2024-12-31 12:30:55 +00:00
Dunqing
0cc71cf5e3 feat(transformer/class-properties): transform super expressions and identifiers that refers to class binding in private method (#8106)
All private methods will be moved out of class, so we need to transform all `super` expressions in private methods and transform identifiers that refer to class binding.
2024-12-31 12:30:55 +00:00
Dunqing
58ed83242a feat(transformer/class-properties): transform private field expression which invokes private method (#8102) 2024-12-31 12:30:53 +00:00
Dunqing
f14567a658 feat(transformer/class-properties): transform callee which invokes private method (#8100)
transform call expression's callee if it invokes a private method
2024-12-31 12:30:52 +00:00
Dunqing
13349ef1b8 feat(transformer/class-properties): transform private methods (#8099)
This PR support transforms private methods in a class, moving all of them to after the `class`
2024-12-31 12:30:52 +00:00
Dunqing
6af5870a7d chore(transformer): enable Babel's private-methods plugin tests (#8098)
part of #8052
2024-12-31 12:30:51 +00:00
Cameron
bf266e13b0
feat(minifier): try collapse conditional to logical or expr (#8197) 2024-12-31 15:59:08 +08:00
Boshen
06e1780b8c feat(minifier): improve StatementFusion (#8194) 2024-12-31 01:13:24 +00:00
Boshen
42e211ad6b feat(minifier): only constant fold numbers when result is smaller (#8092) 2024-12-31 00:56:51 +00:00
branchseer
f88acb331b
fix(parser): allow line breaks between const and enum (#8193)
https://www.typescriptlang.org/play/?ts=5.7.2#code/MYewdgzgLgUApmArgWwAQEFUG8C+Mg
2024-12-31 08:45:17 +08:00
翠 / green
cef8eb8077
feat(minifier): change foo?.['bar'] to foo?.bar (#8176)
ChainExpression's `expression` field is `ChainElement` and not
`Expression` so the previous code did not run for optional chainings.
2024-12-30 16:47:56 +08:00
Boshen
cfb51f2551 refactor(minifier): fuse ast passes (#8184) 2024-12-29 14:57:20 +00:00
Boshen
8149e34bf0 feat(minifier): optional catch binding when es target >= es2019 (#8180) 2024-12-29 12:27:33 +00:00
Boshen
ad146bbb90 feat(codegen): print real newline when \n is inside template literals (#8178) 2024-12-29 12:20:47 +00:00
sapphi-red
75d5f17dbd
fix(minifier): minify string PropertyKey (#8177)
#8169 added `if self.in_fixed_loop` in `try_compress_property_key`. Because `exit_property_key` was not called for `PeepholeOptimizations`, `try_compress_property_key` was never called.

refs #8147
2024-12-29 07:49:42 +00:00
sapphi-red
fc43ec530e
feat(minifier): fold string.length / array.length (#8172) 2024-12-29 07:14:13 +00:00
Boshen
29dc0dc070 feat(minifier): change foo['bar'] -> foo.bar (#8169) 2024-12-29 04:09:42 +00:00
翠 / green
3c5718d68b
feat(minifier): fold typeof foo == undefined into foo == undefined when possible (#8160) 2024-12-29 11:49:57 +08:00