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

Fix no-unused-collection: should not fire if collection is exported #244

Merged
merged 7 commits into from Jun 30, 2021

Conversation

yassin-kammoun-sonarsource
Copy link
Contributor

Fixes #197

} else if (definition.type === 'Parameter') {
return false;
}
return node?.parent?.type.indexOf('Export') === 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

why not simply startsWith instead?

@@ -61,7 +61,24 @@ function collectUnusedCollections(
});
}

function isExported(variable: TSESLint.Scope.Variable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a lot of point in all this logic here. I suggest following:

  const definition = variable.defs[0];
  return definition && definition.node.parent?.parent?.type.startsWith('Export');

@sonarcloud
Copy link

sonarcloud bot commented Jun 30, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

95.5% 95.5% Coverage
0.0% 0.0% Duplication

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.

no-unused-collections should not fire if collection is exported
3 participants