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

feat: warn unused exports #3802

Merged
merged 2 commits into from
Oct 27, 2019

Conversation

tanhauhau
Copy link
Member

Fix #1547

  • Added referenced_from_script to track referenced from script as opposed to reference from template
  • Warn only !referenced && !referenced_from_script
  • Refactor on the post walk, to group the ast walk together, combining the extract_import, extract_export and warn_on_undefined_store_value_references into 1 walk.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests tests with npm test or yarn test)

Sorry, something went wrong.

@Rich-Harris Rich-Harris merged commit d03a5de into sveltejs:master Oct 27, 2019
@Rich-Harris
Copy link
Member

💯

@stalkerg
Copy link
Contributor

oops, export const stateName; not working for component, you should set up something.
Also, in my case, it's a bad warning. (I have some unused props from the router and to prevent runtime warning I put it)

@tanhauhau
Copy link
Member Author

hi @stalkerg not sure I get what you are trying to say.

export const stateName; is not a valid JS syntax, because you must initialise a const.

@tanhauhau tanhauhau deleted the tanhauhau/warn-unused-exports branch November 12, 2019 09:57
@stalkerg
Copy link
Contributor

I am using ASR routing, this solution put "asr" property into any component and very often I have no reason to use it. Also, ASR aggregate params from all routing levels and push down it and set as props, and these props also often not needed in my component.
If I remove export let asr; I will see a warning in the browser because you will try to set not existent props.
But now if I keep this "export" I will see warning about unused variables.

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.

Warn on unused data
3 participants