Giter VIP home page Giter VIP logo

Comments (6)

minht11 avatar minht11 commented on June 12, 2024 2

I thought about it briefly, but not much before implementation, however I see few reasons:
Not quite sure overloading it is the best idea, even if implementation is similar explaining this rule and import restrictions separately is far simpler. useImportExtensions one day could be recomended by default while importRestrictions are far harder to sell.

Requiring extensions does not change behavior it is almost stylistic choice, while importRestrictions force you to rearchitect which imports you are allowed to use.

Another point that importRestrictions have been in nursery for 9months if we merge them, can one part become stable while other not? Can single be in nursery while rule as a whole not? Not a big point but still.

That said I do not have very strong preference and I can see it both ways, but it is bit more clear having them separate at least until having extensions on imports is not standard and needs more education.

from biome.

minht11 avatar minht11 commented on June 12, 2024 1

I think that we can pick extension, based on what other import extensions exist in the file or file extension itself and in most cases it will be good enough.

Regarding ./index.js given the limitations of not being able to query FS, for now pretending they do not exist, likely is also fine. Rule note can mention caveats about it. In extension requiring world implicit index.js wouldn't exist anyway.

Will try to work on implementation.

from biome.

Conaclos avatar Conaclos commented on June 12, 2024

For now, a rule is not able to query the filesystem. Do you suggest just emitting an error and always proposing appending the .js extension?

./foo could be ./foo.js or ./foo/index.js, we have no way of knowing because we cannot query the fs.

I like the conciseness of useImportExtensions.

What options to support if any?

I think you are right. We don't need any config.

from biome.

Conaclos avatar Conaclos commented on June 12, 2024

or file extension itself and in most cases it will be good enough.

Yeah I thought about that.
Anyway this could be an unsafe code fix. That's fine if it is not correct.

./index.js

There are som cases where it can only be an index such as .., ../, ., ./, and foo/.

from biome.

minht11 avatar minht11 commented on June 12, 2024

I just realized that many projects use pattern such as import "~/foo" @/foo which resolve to src/. Without tsconfig access we have no way to know. I wonder if we should add option to allow them to be treated as relative?

from biome.

ematipico avatar ematipico commented on June 12, 2024

The implementation of this rule seems to fit our rule useImportRestrictions, why didn't we consider adding the logic of the proposed rule inside useImportRestrictions? cc @minht11 @Conaclos

from biome.

Related Issues (20)

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.