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

@taobojlen taobojlen commented Sep 27, 2021

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 Sep 27, 2021
Copy link
Member

@ota-meshi ota-meshi left a comment

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

@taobojlen taobojlen commented Sep 28, 2021

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

@taobojlen taobojlen requested a review from ota-meshi Sep 28, 2021
yield* extractClassNames(node.left, true)
yield* extractClassNames(node.right, true)
return
}
Copy link
Member

@ota-meshi ota-meshi Sep 29, 2021

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

@taobojlen taobojlen Sep 29, 2021

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.

if (!textOnly) {
return
}
Copy link
Member

@ota-meshi ota-meshi Sep 29, 2021

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

@taobojlen taobojlen Sep 29, 2021

Choose a reason for hiding this comment

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

Amended.

@taobojlen taobojlen requested a review from ota-meshi Sep 29, 2021
Copy link
Member

@ota-meshi ota-meshi left a comment

LGTM! Thank you for your contribution!

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

Successfully merging this pull request may close these issues.

None yet

2 participants