Skip to content

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Dec 28, 2025

Summary

This adds noVueArrowFuncInWatch, a port of https://eslint.vuejs.org/rules/no-arrow-functions-in-watch.html

Only the code fix was generated by AI.

Test Plan

snapshots, also checked the test cases for the source rule

Docs

@changeset-bot
Copy link

changeset-bot bot commented Dec 28, 2025

🦋 Changeset detected

Latest commit: 361fe64

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor Author

dyc3 commented Dec 28, 2025

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Dec 28, 2025
@dyc3 dyc3 force-pushed the dyc3/no-vue-arrow-in-watch branch from a8e3c24 to 67c592b Compare December 28, 2025 18:32
@dyc3 dyc3 marked this pull request as ready for review December 28, 2025 18:32
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

This rule would benefit from more tests

/// }
/// </script>
/// ```
///
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to add a link to the official docs

impl Rule for NoVueArrowFuncInWatch {
type Query = Semantic<AnyPotentialVueComponent>;
type State = JsArrowFunctionExpression;
type Signals = Box<[Self::State]>;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need a box here. A Vec should be enough

Copy link
Contributor Author

@dyc3 dyc3 Dec 29, 2025

Choose a reason for hiding this comment

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

Every other rule like this uses a Box though

Copy link
Member

Choose a reason for hiding this comment

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

True that, but I'm not sure we ever proved that it's faster. It's fine, we can keep it.

However , why do we need multiple signals? Why isn't Option<State> enough for this rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's how our Vue component querying works currently. We query for something that looks like a component, and then we can extract things from it. This makes it so we don't flag things that aren't in vue components.

It would be better if we could provide better queries though.

Comment on lines +14 to +16
handler: (val, oldVal) => {
console.log('new: %s, old: %s', val, oldVal)
}
Copy link
Member

Choose a reason for hiding this comment

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

Add a test with arrow functions without body e.g.

{
  foo: () => ()
}

/* should generate diagnostics */
export default {
watch: {
foo: (val, oldVal) => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add more cases?

  • async token
  • TypeScript types
  • generator token

@dyc3 dyc3 changed the base branch from dyc3/use-vue-v-for-key to graphite-base/8602 December 28, 2025 21:34
@dyc3 dyc3 force-pushed the dyc3/no-vue-arrow-in-watch branch from 67c592b to 361fe64 Compare January 2, 2026 04:13
@dyc3 dyc3 force-pushed the graphite-base/8602 branch from 391e88a to 9a8c98d Compare January 2, 2026 04:13
@dyc3 dyc3 changed the base branch from graphite-base/8602 to main January 2, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants