Comments (6)
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.
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.
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.
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.
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.
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)
- 💅 `noEmptyInterface` may break global augmentation HOT 1
- 🐛 Potential Bug...? HOT 2
- 📎 Implement `unicorn/prefer-array-index-of`
- 🐛 invalid char boundary in diagnostics
- 📎 Forbid `undefined` as type name
- 🐛 <WasmError> HOT 4
- 💅 [nursery/useDateNow] Incorrect applying to Date.now() to all Date.prototype.getTime HOT 2
- 💅 `lint/correctness/noStringCaseMismatch` false positives
- 💅 `lint/correctness/noUnusedVariables` false positives
- 📝 biome ci always produce errors in GHA but not locally HOT 1
- 🐛 Github Reporter not generating annotations correctly HOT 1
- 💅 `lint/complexity/noUselessFragments` crashes when applying fix in some cases
- 📎 Change `bit_flags` for `enumflags2`
- 💅 There is a false positive in the `useLiteralKeys` rule HOT 1
- 🐛 `biome lsp-proxy` hangs with certain input
- 🐛 CSS parsing and Unicode point ranges
- 🐛 Override behavior with multiple matches HOT 1
- 📎 Import sorter revamping - custom order
- ☂️ Analyzer assists
- 🐛 `npx @biomejs/biome migrate` command crashes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from biome.