Comments (5)
It works well with VSCode, you should definitely give it a shot.
And if you have the import/order
enabled in eslint you will get a nice visual separation of local vs dependency modules which you do not get with the suggested approach.
(ignore the squiggly line in the left image for now), VSCode did linting auto fix on save automatically and reordered the imports.
from bulletproof-react.
Hi there,
Both of your suggestions are valid. I wrote a bit here about the reason why I am choosing this way:
"It is also possible to define multiple paths for various folders(such as @components, @hooks, etc.), but using @/* works very well because it is short enough so there is no need to configure multiple paths and it differs from other dependency modules so there is no confusion in what comes from node_modules and what is our source folder. That means that anything in the src folder can be accessed via @, e.g some file that lives in src/components/MyComponent can be accessed using @/components/MyComponents."
In a nutshell, I find it useful to have a symbol in front of it because it will prevent conflicts from node_modules
imports in case a folder in src
has the same name as some dependency - happens not very often, but it's nice to be sure and not to think about it ever again. In the end, it's just a matter of preference :)
from bulletproof-react.
it's just the same with a different symbol, while I was suggesting to mention that baseUrl
exists and seems to be a valid option, and either relative imports is not a big deal with modern editors
from bulletproof-react.
Chance there is an overlap with npm module is very close to zero, so it will never happen in of 99.99% cases, if happen it can be workarounded by aliasing module, and import { X } from 'components/X'
is more pleasant import to read, so I think it worth to mention this in same document. All other suggestions are very good to be picked by default, and @/ stands out here in my opinion as imperfect default
so there is no confusion in what comes from node_modules and what is our source folder.
yes, it mentioned that it's possible to do in a "confusing" way, but many people reading this don't know it's even possible and how to setup it in this way, so they cannot prefer one way over another and decide if "components/X" is confusing or not on they own
from bulletproof-react.
I understand why better to have zero chance than close to zero, and if you're sure @/ is a better practice let's close this issue
I never tried @/ myself so unsure if it's easy to configure popular editors VSCode and JetBrains to use it in autocompletion, assuming it's easy, since no info about it in the doc
from bulletproof-react.
Related Issues (20)
- bulletproof-react with file-based routing HOT 6
- Could not start on the latest version of node
- STRUCTURE - Where to store static data? HOT 1
- Logout Functionality Not working Properly - DUC-3
- suggestion for pagination
- Network Error when sign up or login? HOT 2
- Question : How to make drawer globally? HOT 3
- Where must I put these files? [React, React Native] HOT 1
- Why we need to use number for createdAt in BaseEntity class HOT 3
- CRA is unmaintained HOT 3
- Avoid barrel files
- Update react-router usage
- [minor]: Typo in ~/README.md HOT 2
- Missing Link/Example in Global Store Management
- Some links are Not found HOT 1
- Auth flow does not work with new cookies
- Logo/Mascot idea :) HOT 1
- .env validation on build
- Not sure the Validation Example Code link is going to the right place HOT 1
- rimraf and glob are deprecated
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 bulletproof-react.