I am new to JavaScript and wanted to set up my work environment. My problems might be basic or I look totally in the wrong direction so please advise me.
I am used to work with Sublime 3 and wanted to use it for writing JS code as well.
I spend half of a day on reserach for various autocomplete/support plugins for JavaScript but none of them seems to be working properly. Topics on subject are either outdated or misleading.
For example, none of them recognizes basic objects like:
document. or window.onload etc. (there is no autocompletion although it would be highlighted properly).
I tried:
JavaScript Enchancements and Completions - they don't work. I have read that there are some issues with running those two on Windows
Babel - doesn't have autcomplete
So in the end my question is: How do I set up Sublime and JavaScript or how can I get basic autocompletion in for JavaScript in Sublime 3?
Some suggestions
You can use JSHint
You can use Ternjs
You can use Emmet
You can use SublimeCodeIntel
You can use Zen Coding
Generate .sublime-completion file manually
Adding Snippets Custom/PackageControl/GitHub
Have you tried LSP? It works for both ST3 and ST4.
https://github.com/sublimelsp/LSP-typescript
Related
My team and I took over a legacy project with only partially implemented i18n. Now we'd like to find all hardcoded strings in the project. Can you guys think of a regex, plugin (VS Code other other) or script/tool for this?
Interestingly, searching for this issue turns up mostly desktop programming languages.
You can use the VS Code extension i18n Ally: https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally
I'm also working on a text extraction project and this has made things a lot faster. If you highlight static/hardcoded text there is a shortcut action you can use that prompts you to create a corresponding key for the text and moves the text to your json file, speeds things up a lot. I created a keyboard shortcut for it like so:
{
"key": "shift+cmd+i",
"command": "i18n-ally.extract-text"
}
Back to your immediate question, the extension has a beta feature for detecting hardcoded strings that is pretty useful. One issue I have with it is I can't figure out yet if there's a way to stop it from detecting inline CSS strings; it would be nice to ignore all that.
Some of the features are experimental/in beta so I can't vouch for it being error proof, but so far it's been very useful for me. Hope that's helpful.
I know that the prediction and autocomplete work on javascripts own functions but they don't seem to work if I try to use it with foreign libraries. Do I need to tell VSC where those .js-files are that should be included?
It works on my own created functions btw. which is not really helpful when you're mostly working on other libraries..
The most similar question I've found so far has no working answers to it: Visual Studio Code enable suggestion code JavaScript like in WebStorm
Any library that has proper JSDoc would support auto completion in VS Code. Since glMatrix has it, it could be done without a problem.
Here's working image:
I am using Webstorm 7.0.3 to develop Node.Js. I have used Webstorm successfully for Html/Js apps, but for whatever reason, the code-coloring and error-highlighting does not exist in my Node.Js app that does for my Html/Js. For example, simple syntax errors don't highlight as desired.
You can see the difference in the two:
Html formatting:
Node Formatting:
While I know this is not a super critical thing, it makes it hard to debug as I code. Anyone know why it's different? I've searched Webstorms, but couldn't find anything.
Thanks in advance!
Most likely the node_modules folder is added to javascript libraries (WebStorm prompts you to configure a library on project opening). Javascript files in libraries have the inspections and error/syntax highlighting turned off by default. You can still enable them for particular file using the Hector icon in the lower right corner (http://www.jetbrains.com/webstorm/webhelp/changing-highlighting-level-for-the-current-file.html)
You can change your formatting this way:
var A = { foo: 'bar'
, forgotThatComma: false
}
So if you ever miss a comma, it would be obvious (see npm style guide for details).
I'm using Visual Studio 2012 and the JsLint plugin.
Is there a better way to use JsLint for inline javascript in CSHTML files?
If I try to select the javascript text and run the tools just on the selection I get a bunch of errors related to spacing (e.g. "var should be on column 13, not 9"). This happens because the IDE indents the javascript code inside the <script>tags.
I get errors on variables that are rendered from razor code like this: result = #Html.Raw(JsonConvert.SerializeObject(Model));
I currently just copy the code onto an empty .js file and run the tool from there, but it's kinda of nuisance to be switching.
What would be the best configuration (or alternate plugin) to work easier with jsLint validation on this scenario?
Resharper is the best tool I've used for javascript coding. It works very well and highlights the majority of the issues that you'd be looking for with JsLint, though it's not nearly as comprehensive of course.
On the other hand, I'd be concerned about the amount of javascript you're writing in a view. If you have that much, perhaps you should consider moving it out of your views into standalone files.
I think you just need to open up the options pane. I'm using the VS.2010 version, but my Tools >>> JSLint Options menu option opens up the following settings pane:
You're running into JSLint without the white option set to true.
You might want to steal some of the other settings I've got above to remove some of the more draconian rules. The above works very well for me. ;^)
I've just setup Eclipse with Aptana Studio 3 and have been trying to get code completion / code hinting / autocomplete to work with mixed results.
I've followed the instructions here: http://wiki.appcelerator.org/display/tis/JavaScript+Library+Support
What I have discovered through testing is that when you install the .sdocml file and nothing else in a new project, it works fine.
As soon as I add a local copy of Dojo into the project the code hinting no longer works correctly.
I tried excluding the directory from view with a filter but that excludes it from the server so you can't use it. I've also tried removing the Dojo folder from Indexing but that changes nothing either.
If I load Dojo from a CDN, like Google, then I can use code completion.
The issue is that Eclipse picks up a parsed reference to dojo instead of the one from the sdocml file.
The problem seems, so far, to be confined to typing 'dojo.' but 'dijit.' and 'dojox.' work okay, maybe because of the parent-child relationship between those sub-libraries, if I were to guess.
I don't know if this is an Aptana bug or an Eclipse bug, but either way, it's a problem.
Does anyone know how to prioritize the code hinting sources and / or exclude certain directories from being a hinting source? Or is there another solution?
Thanks in advance,
Ken
Edit: Now that I have more code in the test project hinting does not work at all for 'dojo.' but still works fine for 'dojox.' and 'dijit.'. Only native JS methods hinting is available as a subset of 'dojo.'