+
Skip to content

feat(lint): implement noVueReservedProps rule #6757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 9, 2025

Conversation

mdevils
Copy link
Contributor

@mdevils mdevils commented Jul 7, 2025

Summary

Implementation of noVueReservedProps rule.

Includes an abstraction to work with Vue components.

What is supported:

  1. Finding component definitions.
  2. Collecting declarations of those components, including props, methods, computed, data.
  3. Has logic for both normal components and setup-components.

What doesn't work:

  1. Since there is no ability to know if the script tag has setup attribute, setup-components are not returned.
  2. Multiple scripts per file don't work, which makes it harder to test things.
  3. Tests are treating vue files as js files.
  4. data() method is not yet supported, need control flow graph (work in progress).
  5. setup() method is not yet supported, need control flow graph (work in progress).

These points don't prevent this rule from being compatible with eslint rule.

Test Plan

Tests are included.

Closes #6309

Copy link

changeset-bot bot commented Jul 7, 2025

🦋 Changeset detected

Latest commit: cc6e247

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

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

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

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Jul 7, 2025
@dyc3 dyc3 self-requested a review July 7, 2025 15:48
Copy link

codspeed-hq bot commented Jul 7, 2025

CodSpeed Performance Report

Merging #6757 will not alter performance

Comparing mdevils:feat/no-vue-reserved-props (cc6e247) with main (3e6ab16)

Summary

✅ 114 untouched benchmarks

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Overall looks good, but I think there is a case you have missed (correct me if i'm wrong)

It's possible to use the composition api inside a export default {} defined component. Example: https://github.com/dyc3/opentogethertube/blob/2b680f4200d9d2e00cfd67dba4b08a0edc8f2009/client/src/views/RoomList.vue#L68

<script setup> and the compiler macros are effectively syntax sugar for this way of defining components.

Comment on lines 14 to 21
pub NoVueReservedProps {
version: "next",
name: "noVueReservedProps",
language: "js",
recommended: false,
severity: Severity::Warning,
domains: &[RuleDomain::Vue],
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is the original rule recommended by the plugin? if so, we should follow that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is. Changed.

Comment on lines 41 to 56
pub enum VueComponent {
/// This is referred to as "normal script" Vue component.
/// <script> export default { props: [ ... ], data: { ... }, ... }; </script>
Normal(VueNormalComponent),
/// A component may be defined right in the createApp call.
/// createApp({ props: [ ... ], ... });
CreateApp(VueCreateApp),
/// Define Component is one of the ways to define a Vue component.
/// defineComponent({ props: [ ... ], ... });
DefineComponent(VueDefineComponent),
/// Setup component is a Vue 3 component that uses the Composition API.
/// <script setup> defineProps({ ... }); const someData = { ... }; </script>
/// FIXME: Remove `allow(dead_code)` when <script setup> is supported.
#[expect(dead_code)]
Setup(VueSetupComponent),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the code examples should go in markdown code blocks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mdevils
Copy link
Contributor Author

mdevils commented Jul 7, 2025

Overall looks good, but I think there is a case you have missed (correct me if i'm wrong)

It's possible to use the composition api inside a export default {} defined component. Example: https://github.com/dyc3/opentogethertube/blob/2b680f4200d9d2e00cfd67dba4b08a0edc8f2009/client/src/views/RoomList.vue#L68

<script setup> and the compiler macros are effectively syntax sugar for this way of defining components.

@dyc3 Thanks for reminding, I know about this case. I just need control flow for that to work. Working on it in order to support both setup() and data().

@dyc3 dyc3 added the D-Vue Domains: Vue label Jul 7, 2025
@mdevils mdevils requested a review from dyc3 July 9, 2025 11:27
@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project labels Jul 9, 2025
@mdevils
Copy link
Contributor Author

mdevils commented Jul 9, 2025

@dyc3 I believe I've addressed all the issues.

Also:

  1. Commented out some setup-related code until we have ability to parse "<script setup>" properly.
  2. Split tests into multiple files with 1 script per file.
  3. Added many comments and docs.
  4. Simplified some code and removed what was not needed.
  5. Added data_declarations_container to be used in feat(biome_js_analyze): noVueDataObjectDeclaration #6574.
  6. Removed v2 reserved names, kept v3 only.

@mdevils mdevils marked this pull request as ready for review July 9, 2025 11:39
Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Looking good!

"@biomejs/biome": minor
---

Added the rule [`noVueReservedProps`](https://biomejs.dev/linter/rules/no-vue-reserved-props/).
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Link to the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

mdevils and others added 2 commits July 9, 2025 14:41
@mdevils mdevils merged commit 13a0818 into biomejs:main Jul 9, 2025
31 checks passed
@github-actions github-actions bot mentioned this pull request Jul 9, 2025
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-Parser Area: parser A-Project Area: project D-Vue Domains: Vue L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📎 Port vue/no-reserved-props from eslint-plugin-vue
2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载