Comments (7)
I've gotten around it by putting the package.json
and node_modules
in /src
, which doesn't work for create react app...
Should be relatively easy to add to here:
https://github.com/Galooshi/import-js/blob/master/lib/findProjectRoot.js
If you wanted to start a proposal
from import-js.
@mnieber Could you give a more specific example? What's the location of the file you're importing into and what's the location of the file/module you're importing? What did you expect import statements to look like vs what do they end up looking like?
Depending on the scenario here, you could look into using https://github.com/Galooshi/import-js#importstatementformatter.
from import-js.
I've found a solution based on an undocumented feature: the .importjs-root
file. Just like package.json
this file indicates the root directory for import paths found by importjs. By placing both .importjs-root
and .importjs.js
in the src
directory, I managed to get import paths that do not start with the src/
prefix.
Maybe it's worth documenting .importjs-root
?
from import-js.
Unfortunately, my solution (described above) is not adequate because now node_modules
is no longer considered.
from import-js.
I know this is an old issue, but this is a feature I'd quite like to see.
A pet peeve of mine is that JavaScript projects always end up with hundreds of config files; and jsconfig has emerged as a bit of a standard.
I'd like to work on a PR, but I'm not experienced with the codebase, and would appreciate any hints as to where to look.
from import-js.
FYI, I'm now using the vandelay plugin in VSCode to generate the import statements. It doesn't have the "Fix all imports" feature that ImportJS has, which is very useful, but otherwise works really well.
from import-js.
I couldn't reproduce this issue. Perhaps it's been solved?
Here's what I did:
mkdir /tmp/test ; cd /tmp/test
npx create-react-app .
echo "export default 'hello'" > src/b.js
echo "console.log(b)" >> src/App.js
importjs fix src/App.js
ImportJS then went ahead and added this line:
import b from "./b.js";
Notice that it did not include the src
in the path.
I'll go ahead and close this now as I can't reproduce the issue. However, if you feel I missed something then please go ahead and reopen it and describe how to reproduce step-by-step. Thanks!
from import-js.
Related Issues (20)
- Option to import with double quotes instead of single quotes HOT 2
- Lodash alias doesn't work HOT 3
- groupImports ends up grouping namedExports separately. HOT 1
- Import maps HOT 2
- active forks HOT 3
- Unable to import files when using smart pipeline operator HOT 5
- Fails to install: node-pre-gyp? HOT 4
- when i move a personal module file to an other folder, the import suggestion of the personal module propose the old folder and the new folder HOT 2
- Config file can't be loaded inside an ES Module project HOT 1
- Move away from Flow? HOT 14
- Move to Prettier, abandon ESlint HOT 4
- Cleaning up stale issues & PRs HOT 2
- Abandon old node versions, update test matrix HOT 2
- React Imports on JSX HOT 1
- Reintroduce some ESlint rules
- Better schema validation errors
- Auto-generate configuration documentation
- Add plugin support HOT 2
- Missing CODECLIMATE_REPO_TOKEN for Github Actions
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 import-js.