Commit graph

2116 commits

Author SHA1 Message Date
Boshen
8347e2225c
Release crates v0.4.0 2023-12-08 17:20:37 +08:00
Boshen
335647585d
deps(rust): bump ryu-js to v1.0.0 2023-12-08 17:15:35 +08:00
Boshen
9b849f5dd2
deps(rust): itertools 0.12.0 2023-12-08 16:54:07 +08:00
Boshen
7ebe81d7ba
chore(linter): clean up the files a little bit 2023-12-08 16:50:06 +08:00
msdlisper
d88f4f4983
feat(linter): eslint-plugin-jsx-a11y no-autofocus (#1641)
impl linter for #1141
2023-12-08 16:43:14 +08:00
Dunqing
6e5aad2639
feat(prettier): add ConditionalGroup command (#1635) 2023-12-07 20:12:45 +08:00
Cameron
86fe7e3a3d
feat(linter) eslint plugin unicorn: no useless spread (#1638) 2023-12-07 17:31:22 +08:00
Wenzhe Wang
0dec110790
refactor(prettier): move the format of Function's key to PropertyKey (#1639) 2023-12-07 17:30:48 +08:00
Miles Johnson
c6ad6603a4
feat(semantic): support scope descendents starting from a certain scope. (#1629)
@Boshen 

The `ScopeTree.descendants` function would return all scopes starting
from the root, and wasn't truly descendants from a specific scope. To
improve this, I've renamed this function to `descendants_from_root` and
have introduced a new `descendants` function that does support from a
specific scope.

Furthermore, I've introduced helper functions to `SymbolTree` to make
reading symbols/scopes easier.

To verify this functionality, I enabled the `function_name` transformer
(and fixed it), and ran some example transforms. Here's the input:

```js
let fn;

fn = function (a, b, c) {
  const d = "";
};

const func = function (arg) {
  {
    const value = "";
  }
};

const f = function (f) {};
```

And the output using _the old implementation_. Note that all function
names are suffixed with a number, this is incorrect, since it was
inheriting far too many scopes.

```js
let fn;
fn = function fn1(a, b, c) {
	const d = '';
};
const func = function func1(arg) {
	{
		const value = '';
	}
};
const f = function f2(f) {
};
```

And here's the output with the new implementation. Note that only `f` is
suffixed with a number. That's because it has a shadowed argument of the
same name.

```js
let fn;
fn = function fn(a, b, c) {
	const d = '';
};
const func = function func(arg) {
	{
		const value = '';
	}
};
const f = function f1(f) {
};
```
2023-12-07 17:29:11 +08:00
Wenzhe Wang
aa9bdeb8ee
feat(playground): add link jump to website (#1637) 2023-12-06 21:37:12 +08:00
Boshen
9018e2ad44
chore(codecov): ignore oxc_transformer and oxc_js_regex which are not ready yet 2023-12-06 19:05:42 +08:00
Boshen
5ba8398b9e
chore: update readme 2023-12-06 19:03:57 +08:00
Boshen
be731fe90c
chore: move oxc_resolver to https://github.com/oxc-project/oxc_resolver (#1636)
It is moved to https://github.com/oxc-project/oxc_resolver
2023-12-06 18:52:59 +08:00
Shinobu Hayashi
ddb3c62b87
feat(linter): eslint-plugin-jsx-a11y scope rule (correctness) (#1609)
## Summary

partof: #1141

I re-implemented scope rule for jsx_a11y in Rust same as the original JS
one, and moved also the test related to the rule to here.

originals:
- doc:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/scope.md
- code:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/rules/scope.js
- test:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__tests__/src/rules/scope-test.js
2023-12-06 18:24:29 +08:00
Boshen
2e42e10a1b
feat(resolver): add a realpath to package.json (#1634)
Using the `realpath` for resolving browser field will lead to missing
queries.

This fixes a cases where `browserField` fails to read.

---

`styled-components` is using a trick for loading browser modules:

---

7c065e0b6f/packages/styled-components/package.json (L6C1-L12C5)

```json
  "main": "dist/styled-components.cjs.js",
  "module": "./dist/styled-components.esm.js",
  "browser": {
    "./dist/styled-components.esm.js": "./dist/styled-components.browser.esm.js",
    "./dist/styled-components.cjs.js": "./dist/styled-components.browser.cjs.js"
  },
```

Module resolution has to go from `"module":
"./dist/styled-components.esm.js"`, then to `browser`'s
`"./dist/styled-components.esm.js":
"./dist/styled-components.browser.esm.js"` part in order for things to
get resolved correctly.

---

Fixtures are hard to setup for this test case due to needing symlinks,
I've created https://github.com/oxc-project/oxc_resolver for tacking
such cases.
2023-12-06 12:25:44 +08:00
Wenzhe Wang
286644714f
feat(prettier): wrap parameters in indent (#1633) 2023-12-06 10:20:31 +08:00
Wenzhe Wang
633455aba6
refactor(prettier): add print_method_value (#1632) 2023-12-06 10:16:09 +08:00
Wenzhe Wang
2aa5f7db91
feat(prettier): finish should_hug_the_only_function_parameter (#1626) 2023-12-05 22:55:12 +08:00
Don Isaac
795db7c5b7
feat(linter): cxc: no accumulating spread (#1607)
Creates a new nursery-level rule, `no-reduce-spread`, that prevents
spreading accumulator objects/arrays in `Array.prototype.reduce`.

The Tl;Dr of why this should be avoided is because it drastically
increases time/memory complexity in reductions. In general, it turns
potentially `O(1)`/`O(n)` memory operations into `O(n)`/`O(n^2)`, and
`O(n)` time into `O(n^2)`. For more details, refer to [this helpful blog
post](https://prateeksurana.me/blog/why-using-object-spread-with-reduce-bad-idea/).

Note that this rule doesn't exist in ESLint's default rule set or any
other ESLint plugin, although it looks like [there's been some interest
in it in the past](https://github.com/vercel/style-guide/issues/18).
Since there is no reference implementation to compare against, and thus
this could potentially have bugs, I've decided to make this a
nursery-level rule until we're sure it's stable and useful.

---

Edit: 

- [ ] Sync with Biome -
https://biomejs.dev/linter/rules/no-accumulating-spread/

---------

Co-authored-by: Cameron Clark <cameron.clark@hey.com>
2023-12-05 17:25:40 +08:00
IWANABETHATGUY
b5f8a65352
refactor: improve pattern match of prefer-reflect-apply (#1630) 2023-12-05 15:18:50 +08:00
RiESAEX
c8e2ef62a8
feat(linter): eslint-plugin-unicorn: explicit-length-check (#1617)
[Rule](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/explicit-length-check.md)
#684 
It's harder than I thought.
Test cases that require a vue parser have been skipped
Some test case needs
[getStaticValue](https://github.com/eslint-community/eslint-utils/blob/main/src/get-static-value.mjs#L672)
to pass.
2023-12-05 13:55:56 +08:00
Ken-HH24
519b5f266b
feat(linter): eslint-plugin-unicorn prefer-reflect-apply(style) (#1628)
[prefer-reflect-apply](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-reflect-apply.md)
for #684 .
2023-12-05 13:52:49 +08:00
Wenzhe Wang
bb4a2c7930
chore: fix typo (#1627) 2023-12-04 21:52:50 +08:00
Boshen
32504cadb7
feat(linter): add a perf category (#1625)
relates to #1607
2023-12-04 17:31:34 +08:00
dependabot[bot]
09618e9db0
chore(deps): bump the dependencies group with 2 updates (#1623) 2023-12-04 15:26:44 +08:00
dependabot[bot]
5e4bc65741
chore(deps): bump CodSpeedHQ/action from 1 to 2 (#1624)
Bumps [CodSpeedHQ/action](https://github.com/codspeedhq/action) from 1
to 2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/codspeedhq/action/releases">CodSpeedHQ/action's
releases</a>.</em></p>
<blockquote>
<h2>v2.0.0</h2>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/CodSpeedHQ/action/compare/v1...v2.0.0">https://github.com/CodSpeedHQ/action/compare/v1...v2.0.0</a></p>
<p>This major update greatly simplifies the action and moves all the
core logic to the <a
href="https://github.com/CodSpeedHQ/runner">https://github.com/CodSpeedHQ/runner</a>
repo.</p>
<p>Updating is as easy as changing <code>CodSpeedHQ/action@v1</code> to
<code>CodSpeedHQ/action@v2</code>.</p>
<h2>What's changed</h2>
<ul>
<li>feat: integrate the native runner with a composite action by <a
href="https://github.com/art049"><code>@​art049</code></a> and <a
href="https://github.com/adriencaccia"><code>@​adriencaccia</code></a>
in <a
href="https://redirect.github.com/CodSpeedHQ/action/pull/86">CodSpeedHQ/action#86</a></li>
</ul>
<h3>Breaking changes</h3>
<ul>
<li><code>upload_url</code> input is now <code>upload-url</code></li>
<li><code>pytest-codspeed</code> is no longer installed automatically by
this action</li>
</ul>
<h2>v1.8.1</h2>
<h2>What's Changed</h2>
<ul>
<li>fix: update apt registry before installing valgrind by <a
href="https://github.com/adriencaccia"><code>@​adriencaccia</code></a>
in <a
href="https://redirect.github.com/CodSpeedHQ/action/pull/80">CodSpeedHQ/action#80</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/CodSpeedHQ/action/compare/v1.8.0...v1.8.1">https://github.com/CodSpeedHQ/action/compare/v1.8.0...v1.8.1</a></p>
<h2>v1.8.0</h2>
<h2>What's Changed</h2>
<h3>Added</h3>
<ul>
<li>Add the <code>working-directory</code> input parameter by <a
href="https://github.com/art049"><code>@​art049</code></a> in <a
href="https://redirect.github.com/CodSpeedHQ/action/pull/77">CodSpeedHQ/action#77</a></li>
</ul>
<h3>Internals</h3>
<ul>
<li>Update documentation examples by <a
href="https://github.com/adriencaccia"><code>@​adriencaccia</code></a>
in <a
href="https://redirect.github.com/CodSpeedHQ/action/pull/76">CodSpeedHQ/action#76</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/CodSpeedHQ/action/compare/v1.7.1...v1.8.0">https://github.com/CodSpeedHQ/action/compare/v1.7.1...v1.8.0</a></p>
<h2>v1.7.1</h2>
<h2>🎉 What's Changed</h2>
<ul>
<li>Prepare for release on GitHub Action Marketplace</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/CodSpeedHQ/action/compare/v1.7.0...v1.7.1">https://github.com/CodSpeedHQ/action/compare/v1.7.0...v1.7.1</a></p>
<h2>v1.7.0</h2>
<h2>🎉 What's Changed</h2>
<ul>
<li>
<p>A <a href="https://github.com/CodSpeedHQ/valgrind-codspeed">fork of
valgrind</a> is now used, allowing us to <a
href="https://docs.codspeed.io/features/trace-generation/">generate
execution traces</a> with Node and Python.</p>
</li>
<li>
<p>V8 flags previously set as an environment variable
<code>CODSPEED_V8_FLAGS</code> are now handled directly by the
integration library and injected to Nodejs through our <a
href="https://github.com/CodSpeedHQ/action/blob/main/dist/bin/node">custom
node executable</a>.</p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/CodSpeedHQ/action/blob/main/CHANGELOG.md">CodSpeedHQ/action's
changelog</a>.</em></p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="3cb272459e"><code>3cb2724</code></a>
Release v2.0.1 🚀</li>
<li><a
href="6790ba286f"><code>6790ba2</code></a>
feat: simplify action output</li>
<li><a
href="0c6eabe26d"><code>0c6eabe</code></a>
fix: quiet the codspeed-runner installation</li>
<li><a
href="4f1d7b4ec1"><code>4f1d7b4</code></a>
Release v2.0.0 🚀</li>
<li><a
href="de30d2b7e6"><code>de30d2b</code></a>
chore: use full version in script and stop relying on pnpm</li>
<li><a
href="5a53587953"><code>5a53587</code></a>
chore(ci): add multiline check</li>
<li><a
href="e2bcafd32c"><code>e2bcafd</code></a>
feat: integrate the native runner with a composite action</li>
<li><a
href="e8372ebb5f"><code>e8372eb</code></a>
chore: update readme with vitest</li>
<li>See full diff in <a
href="https://github.com/codspeedhq/action/compare/v1...v2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=CodSpeedHQ/action&package-manager=github_actions&previous-version=1&new-version=2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-04 15:26:27 +08:00
Miles Johnson
6cbc5dd75b
feat(transformer): Start on function_name transform. (#1510)
Co-authored-by: Boshen <boshenc@gmail.com>
2023-12-04 13:35:44 +08:00
Don Isaac
4e05d1809f
ci(e2e): lint DefinitelyTyped/DefinitelyTyped (#1621)
Closes #1216
2023-12-04 10:32:06 +08:00
IWANABETHATGUY
872e8ad4ae
feat: eslint-plugin-unicorn (recommended) prefer-node-protocol (#1618)
part of https://github.com/oxc-project/oxc/issues/684
2023-12-03 17:06:47 +00:00
Cameron
f74fa975b1
feat(linter) eslint plugin unicorn: prefer number properties (#1614) 2023-12-03 16:24:40 +00:00
IWANABETHATGUY
0a9c548332
feat(playground): bidirectional inspect ast node (#1619)
1. Before we implement inspect the source code via the related AST node.

2. This pull request implemented the reverse process, you can inspect
the related ast node by clicking the source code, also it would scroll
the corresponding ast node into the viewport after you click source
code.
2023-12-04 00:18:54 +08:00
Cameron
e881ee253c
feat(linter) eslint plugin unicorn: no array foreach (#1613) 2023-12-03 16:17:37 +00:00
Wenzhe Wang
cfe207fb53
feat(tasks): ignore some invalid cases and support read parser from source text (#1616) 2023-12-03 21:17:47 +08:00
Cameron
eaffb1d87c
feat(linter) eslint plugin unicorn: no array reduce (restriction) (#1610) 2023-12-03 17:03:23 +08:00
Wenzhe Wang
9af24842a8
fix(tasks): escape more special characters (#1615)
We also need escape `$` and `\`:
9527e65a38/packages/snapshot/src/port/inlineSnapshot.ts (L78-L94)
2023-12-03 16:56:18 +08:00
Shinobu Hayashi
b573036035
feat(linter): eslint-plugin-jsx-a11y iframe-has-title rule (correctness) (#1589)
## Summary

partof: #1141

I re-implemented iframe-has-title rule for jsx_a11y in Rust same as the
original JS one, and moved also the test related to the rule to here.

originals:
- doc:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/iframe-has-title.md
- code:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/rules/iframe-has-title.js
- test:
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/__tests__/src/rules/iframe-has-title-test.js
2023-12-03 15:30:30 +08:00
Wenzhe Wang
2f90ca1b54
fix(tasks): find the right output to diff (#1596) 2023-12-03 15:29:13 +08:00
Cameron
b7b3073f3f
feat(prettier) port should_break_after_operator (#1606) 2023-12-02 20:40:25 +08:00
Ken-HH24
967aa35526
feat(linter): eslint-plugin-unicorn require-array-join-separator(style) (#1608)
Try to implement require-array-join-separator for #684
2023-12-02 11:26:14 +00:00
Cameron
502d61dc9f
fix(prettier) fix use chain formatting (#1605) 2023-12-02 15:44:25 +08:00
Boshen
811b219b27
feat(prettier): add parens to new class {} (#1604) 2023-12-01 21:36:01 +08:00
Boshen
bb61f10399
feat(prettier): handle parens for (x % y) % z (#1603) 2023-12-01 21:29:56 +08:00
Cameron
b4e90a723a
feat(prettier): implement has_comment, improve blank lines when printing arrays (#1601) 2023-12-01 20:52:26 +08:00
Cameron
deac95e274
feat(prettier): print blank lines when printing array concisely (#1600) 2023-12-01 20:48:10 +08:00
Boshen
f4f392e19f
feat(prettier): add parens to left of instanceof (#1602) 2023-12-01 19:08:45 +08:00
Cameron
66452c95f5
fix(prettier) print computed object property key correctly (#1599) 2023-12-01 18:36:38 +08:00
Cameron
0134211b6f
fix(prettier) use print_assignment for ObjectProperty (#1598) 2023-12-01 18:32:03 +08:00
Boshen
da87b9b29e
feat(prettier): binaryish expressions with parens (#1597) 2023-12-01 13:52:22 +08:00
Ken-HH24
ba5b13da2c
feat(linter): eslint-plugin-unicorn no-unreadable-array-destructuring (style) (#1594)
Try to implement `no-unreadable-array-destructuring` for #684
2023-12-01 09:57:20 +08:00
Boshen
e3c54b92c9
fix(prettier): object pattern in function parameters (#1595) 2023-11-30 23:49:24 +08:00