galooshi / sublime-import-js Goto Github PK
View Code? Open in Web Editor NEWSublime Text plugin for ImportJS
License: MIT License
Sublime Text plugin for ImportJS
License: MIT License
From @vini175pa on February 11, 2016 2:14
Hey, how are you doing? Some time ago, I've tested this plugin and I ran into some problems. I created an issue and I was encouraged to change some little things on the code, that later on fixed my problem. This inspired me to create my own plugin, since I was having other problems.
I'm using simple-import
a lot and I thought that maybe you could incorporate some things of simple-import
into import-js
. I'm really into React development with ES6 so I was not using import-js
because I know nothing about ruby and, until the version I was using, it didn't have an import
like ES6.
It`s a 470 lines python file. If you have some time to have a look I appreciate.
https://github.com/vini175pa/simple-import-js
Copied from original issue: Galooshi/import-js#194
Hi all,
I was trying to start using importjs, as I want to use sublime for a typescript project and when I tried to import a module by running "Importjs: fix all imports" Sublime_text totally freezes.
I also fixed my path earlier as the plugin couldn't find the importjs global installation (I use nvm) so it seems like everything is connected correctly.
OS: Ubuntu 16.04.3 LTS (xenial)
Sublime build: 3143 (stable)
Node Version: v8.2.1
Python 3 version: 3.5.2
PS. I don't use sublime that much, is there a way to get a stack trace or verbose output with it so I could help debugging the issue more??
Thank you
Hi, I'm getting the error in the title when trying to run Fix Imports.
It says it's coming from import-js.py
, line 156, which is the stdin flush.
importjs works in CLI mode without any issue.
I'm on Windows 10. Not sure what any other information to provide right now. Any ideas?
Hi! Thank you for writing this plugin, looks like it could really speed up development! I'm trying the plugin for the first time and I'm getting this error:
['/Users/alebiavati/.nvm/versions/node/v5.9.0/bin/importjs', None, '/Users/alebiavati/code/test-project/src/test.js']
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 568, in run_
return self.run(edit, **args)
File "import-js in /Users/alebiavati/Library/Application Support/Sublime Text 3/Installed Packages/ImportJS.sublime-package", line 114, in run
File "./python3.3/subprocess.py", line 819, in __init__
File "./python3.3/subprocess.py", line 1386, in _execute_child
TypeError: Can't convert 'NoneType' object to str implicitly
My configuration is this:
/Users/alebiavati/code/test-project/.importjs.json
{
"lookupPaths": ["src"],
"useRelativePaths": true,
"importDevDependencies": true,
"aliases": {
"$": "third-party-libs/jquery",
"styles": "./{filename}.scss"
}
}
and my test file is this:
/Users/alebiavati/code/test-project/src/test.js
import MainNav from './components/MainNav';
const test = MainNav;
/Users/alebiavati/code/test-project/src/components/MainNav.js
import { Component } from 'react';
export default class MainNav extends Component { }
If I run importjs from the command line I get the proper result:
$ importjs goto MainNav src/test.js
{"messages":[],"fileContent":"import MainNav from './components/MainNav';\n\nconst test = MainNav;\n","unresolvedImports":{},"goto":"src/components/MainNav.js"}
but when using the sublime plugin I get the error above. This happens if I try to use any of the importjs
commands: goto module
, import word under cursor
, or fix all imports
.
Have you ever seen something like this?
Thanks in advance for the help! and again, great plugin!!
How do I use import js? The readme doesnt say what it even does or how to use it or what to expect.
But Im really curious if I can get it to help with importing modules quickly. Especially for Angular projects (typescript)
Thanks for this package. I've been using it for a while and it's been working fine, however today it's stopped working. When I run any of the import commands it says "Running ImportJS command..." in the bar at the bottom and doesn't do anything.
Just wondering whether you have come across this before?
I've tried reinstalling the package, going through the importjs setup again, and restarting sublime but it still does the same thing.
Thanks
We have a file in our repo which, on running ImportJS: Fix all imports
will insert a line-break in the middle of the file, seemingly random. The weird thing is that when running the importjs
command in isolation on the command-line, the line-break isn't inserted. I've tried the same file in vim and it works the way expect it to work.
Here's an example git diff
after importing with the Sublime plugin:
diff --git a/app/assets/components/pages/DistrictPage/index.jsx b/app/assets/components/pages/DistrictPage/index.jsx
index d832504..b752c66 100644
--- a/app/assets/components/pages/DistrictPage/index.jsx
+++ b/app/assets/components/pages/DistrictPage/index.jsx
@@ -1,5 +1,5 @@
-const { some } = require('underscore');
const $ = require('jquery');
+const { some } = require('underscore');
const DocumentTitle = require('react-document-title');
const React = require('react');
@@ -527,7 +527,8 @@ const DistrictPage = React.createClass({
currentProfile,
district,
} = this.props;
- const canSeeVoterVerification = currentProfile.voter_verification &&
+ const canSeeVoterVerification = currentProfile.voter_verification
+&&
currentProfile.voter_verification.can_see_activity;
return (
Notice the added line-break after const canSeeVoterVerification = currentProfile.voter_verification
.
It should be noted that this file is quite large - over 1000 lines.
Hi,
I'm on Mac Os, using node 6.3.1, Sublime Text 3114.
I've followed the installation instruction and already tried the suggested troubleshooting, but I had not luck. I've manually set the path to: "/Users/foo/.nvm/versions/node/v6.3.1/bin/node"
I've tested this on a jsx file, I place the cursor under an components that I need to import, then either by hitting a shortcut or using the command palette I launch "Import word under cursor" and I get this error message:
{'fileContent': 'import React from \'react\';\n\n\nimport Header from "./Header";\n\n\nexport default class Layout extends React.Component {\n static propTypes = {\n name: React.PropTypes.string,\n };\n\n constructor(props) {\n super(props);\n }\n\n render() {\n return (\n <Header/>\n <Footer />\n );\n }\n}\n', 'command': 'word', 'commandArg': 'Footer', 'pathToFile': '/Users/foo/Projects/react-adminlte-custom/src/components/Layout.jsx'}
Traceback (most recent call last):
File "/Applications/Coding/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 568, in run_
return self.run(edit, **args)
File "import-js in /Users/foo/Library/Application Support/Sublime Text 3/Installed Packages/ImportJS.sublime-package", line 158, in run
BrokenPipeError: [Errno 32] Broken pipe
v1.3.0 on sublime 3211
the sublime-settings file isn't used.
.importjs.js works fine.
Not really a functional issue if you know where to put the settings, however the documentation doesn't point you towards using .importjs.js
Cheers
I plan on opening a PR to fix #1 and #19, but I'm not sure if there any special rules or guidelines to follow when writing the code.
Unfortunately the link to the code of conduct (http://todogroup.org/opencodeofconduct/#Import-JS/[email protected]) seems to be dead.
the plugin seems not work.
run import word under cursor
or fix all imports
just got a error message at status bar:
No JS module to import for `module_name`
I have add a .importjs.js
config file at project root directory, and enable debugger
options, but no debugger info shows at console.
thanks any help.
Hi there,
I did npm install -g import-js
, I try to use it in Sublime Text but I always have this error message.
I did put in my settings
{
"paths": ["/Users/arnaudambro/.npm/lib/node_modules/import-js/bin"]
}
but nothing changes.
Is my setting good ? I did check in the path that there is a bin
folder, and there is one.
Do we support other configuration items which are documented in https://github.com/Galooshi/import-js? for example, aliases, excludes and sortImports. I can only see there is "path" configuration in the package setting.
To reproduce:
I would expect to see all of the missing imports to be imported. Instead, I only see the ones that were prompted for. Running fix imports a second time seems to get the rest.
Keeps hanging on "Running ImportJS command…". Downgrading to 3.0.0 fixed the issue (and upgrading again reproduces the behaviour.)
Hi, call import command in a html file will add an import statement in the top of the file. It looks like that:
import { renderStatus } from './helper';
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
renderStatus
</script>
</body>
</html>
but, except it will in the script tag of the scope:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
import { renderStatus } from './helper';
renderStatus
</script>
</body>
</html>
Thanks you great work.
I am using React JS and the plugin can't import prop-types.
Some folks might not have a system node installed but are using nvm. I thought it would work to configure the executable to point to the importjs
binary installed in the .nvm
directory (e.g. /Users/foo/.nvm/versions/node/v4.4.3/bin/importjs
), but that gives us the "couldn't find executable" error message.
We could probably make this work by having Python use a login shell when executing the importjs command, but I'd like to avoid that if possible for performance reasons.
I think all of the plugins besides atom-import-js will likely need similar attention.
This is related to Galooshi/import-js#233
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.