Skip to content

Fix false positives for files other than *.svelte in svelte/no-unused-svelte-ignore rule #202

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 2 commits into from
Jul 29, 2022

Conversation

ota-meshi
Copy link
Member

@ota-meshi ota-meshi commented Jul 29, 2022

This PR fixes a false positive in the svelte/no-unused-svelte-ignore rule for JS files.
The rule should not check for files other than those parsed by svelte-eslint-parser.

I also changed the test utility so that it can target fixtures other than .svelte.

@ota-meshi ota-meshi added the bug Something isn't working label Jul 29, 2022
@ota-meshi ota-meshi requested a review from JounQin July 29, 2022 02:15
@ota-meshi ota-meshi changed the title Fix false positives for js in svelte/no-unused-svelte-ignore rule Fix false positives for files other than *.svelte in svelte/no-unused-svelte-ignore rule Jul 29, 2022
const parser =
path.extname(filename) === ".svelte"
? require.resolve("svelte-eslint-parser")
: undefined
if (config && typeof config === "object") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this check necessary? Shouldn't return Object.assign({ parser }, config, { code, filename }) always work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for let me know. I didn't notice it. I fixed it.

@@ -19,6 +19,9 @@ export default createRule("no-unused-svelte-ignore", {
},

create(context) {
if (!context.parserServices.isSvelte) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@ota-meshi ota-meshi merged commit 50d2e62 into main Jul 29, 2022
@ota-meshi ota-meshi deleted the fixx-no-unused-svelte-ignore branch July 29, 2022 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants