Skip to content
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

Add vue/no-restricted-class rule #1639

Merged
merged 7 commits into from Sep 29, 2021
Merged

Add vue/no-restricted-class rule #1639

merged 7 commits into from Sep 29, 2021

Conversation

taobojlen
Copy link
Contributor

I had to refactor the rule somewhat from my original implementation to make it work with Typescript. This made it a bit harder to read, so any suggestions for improving that are welcome.

@taobojlen taobojlen marked this pull request as ready for review September 27, 2021 19:56
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

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

Thank you for this PR!
I wrote some comments.

docs/rules/no-restricted-class.md Outdated Show resolved Hide resolved
docs/rules/no-restricted-class.md Outdated Show resolved Hide resolved
docs/rules/no-restricted-class.md Outdated Show resolved Hide resolved
lib/rules/no-restricted-class.js Outdated Show resolved Hide resolved
lib/rules/no-restricted-class.js Show resolved Hide resolved
lib/rules/no-restricted-class.js Outdated Show resolved Hide resolved
@taobojlen
Copy link
Contributor Author

Thanks @ota-meshi for the help! Very helpful points -- I've applied your suggestions, and ensured that we handle array syntax.

yield* extractClassNames(node.left, true)
yield* extractClassNames(node.right, true)
return
}
Copy link
Member

Choose a reason for hiding this comment

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

I made a mistake in the if statement. We need to add the following:

Suggested change
}
}
if (textOnly) {
return
}

<template><div :class="''+{forbidden:true}">Content</div></template> is actually drawn as <div class="[object Object]">Content</div>.

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPjxkaXYgOmNsYXNzPVwiJycre2ZvcmJpZGRlbjp0cnVlfVwiPkNvbnRlbnQ8L2Rpdj48L3RlbXBsYXRlPiIsImltcG9ydC1tYXAuanNvbiI6IntcbiAgXCJpbXBvcnRzXCI6IHtcbiAgICBcInZ1ZVwiOiBcImh0dHBzOi8vc2ZjLnZ1ZWpzLm9yZy92dWUucnVudGltZS5lc20tYnJvd3Nlci5qc1wiXG4gIH1cbn0ifQ==

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you; fixed -- and added a test case.

Comment on lines 94 to 96
if (!textOnly) {
return
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!textOnly) {
return
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Amended.

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for your contribution!

@ota-meshi ota-meshi merged commit c2c709d into vuejs:master Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants