Git Product home page Git Product logo

Comments (6)

sparksp avatar sparksp commented on September 2, 2024

Ooo that's an interesting case there. I don't think this rule should be responsible for fixing your exposing (that's for another rule in this package perhaps) but I'll certainly take a look to remove the auto-fix in this case.

from elm-review-imports.

MartinSStewart avatar MartinSStewart commented on September 2, 2024

To be clear, I think the second example shouldn't be an error at all due to there being no good way to fix it. I agree the first example should just not have an auto-fix though.

from elm-review-imports.

sparksp avatar sparksp commented on September 2, 2024

There are a number of 'good' ways the second can be fixed... the author could choose not to expose the Subcomponent's Msg variants and fully qualify all their subcomponent use or they could choose to rename the local Msg type so there's no shadowing.

What happens if the author decides to add MsgVariantInSubComponent to a local type or import it again from another module? The compiler will then complain about a type mismatch, the author will need to prefix the module name, and the exposing becomes further pointless.

Personally, I'm not a fan of imports exposing type constructors because it makes it much harder (even than normal imports) to figure out where things are coming from.

from elm-review-imports.

jfmengels avatar jfmengels commented on September 2, 2024

I agree with @sparksp that there are multiple ways to fix the issue, qualified imports of the constructors being one of them.

But I think that the original example as it is is just fine too and that there is not a lot of ways the situation can be improved upon without potentially a lot of (manual) renaming. I therefore think the rule should not report an error in the case where the imported type is the same as a local type (and probably the same thing for values?).

from elm-review-imports.

MartinSStewart avatar MartinSStewart commented on September 2, 2024

@sparksp Fair enough, I guess I'm okay with it showing an error but not an auto-fix in the second example as well. That said, if it is an error and you're feeling particularly motivated, maybe NoModuleOnExposedName could detect this situation and suggest to the user to not have Msg(..) and instead provide qualified names to the Msg variants.

from elm-review-imports.

mthadley avatar mthadley commented on September 2, 2024

Ran into this situation as well, today.

Seems like folks have settled on "Don't report an error" in this case. Has anyone made any progress on adding that behavior to the rule?

from elm-review-imports.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.