How to setup WebStorm / IntelliJ so the output from Grunt console has links into the files, in the same way a FileWatcher that calls tsc would do - intellij-idea

Using IntelliJ/WebStorm if I run tsc from a FileWatcher, my compile errors are linked to the files in the editor, such that if I double-click on a compiler error, it opens that file and takes me to the offending line of code.
However if I run Grunt, either via the integrated Grunt console, or via a FileWatcher, the compile errors do not have links and I have to manually open the file and goto the offending line number.
Is there any way to get the compile errors comming from Grunt integrated as links, like the TypeScript FileWatcher's invocation of tsc does?

When running Grunt as a file watcher, you can set up filters to make links clickable. You can use existing filters as example: open your file watcher settings, press Output Filters..., open the filter settings and copy the regular expression specified there. See http://www.jetbrains.com/webstorm/webhelp/add-filter-dialog.html

In Webstorm 8, it is not possible to apply regular expression filters on Grunt console output.
The way to go, as mentioned by lena, is to call Grunt directly via an External tool entry, and set up appropriate regex filters, such as:
For grunt-ts:
$FILE_PATH$\($LINE$,$COLUMN$\):.*
For grunt-tslint:
...$FILE_PATH$\[$LINE$,\s$COLUMN$\]:.*
Also see my comment above regarding a caveat for grunt-tslint in some environments.

I believe the '>>' added by grunt-typescript is throwing it off. Try grunt-ts (disclaimer : one of the authors) which is tested with webstorm https://github.com/grunt-ts/grunt-ts

I noticed in Webstorm 9, the built-in Grunt console was filtering/linking on typescript compile errors with grunt-typescript. I am not sure if this is a recent change or not, but it was linking this for example,
So, I went into grunt-tslint/node_modules/tslint/build/formatters, and copied proseFormatter.js to ./myproseFormatter.js. Then I tweaked it so the tslint output format would match the compile error format, by replacing square brackets with parens, and removing the whitespace between line and column number. Finally, I referenced my custom formatter in my gruntfile tslint config by adding the formatter and formattersDirectory properties:
tslint: {
options: {
configuration: grunt.file.readJSON('tslint.json'),
formatter: 'myprose',
formattersDirectory: './'
},
all: {
src: [ 'app/**/*.ts' ]
}
}
and it worked!

Related

How to debug neovim lsp custom command

I am attempting to get the volar vue language server to work in place of vetur for neovim's native lsp.
Using both lspconfig and lspinstall I was able to create a working custom install for sumneko_lua (unrelated but had to manually build due to some issues with the built-in :LspInstall lua). Below is that code duplicated and modified for an attempt at using this new vue server:
local vue_config = require'lspinstall/util'.extract_config('vuels')
vue_config.default_config.cmd = {'node', './node_modules/vscode-vue-languageservice/out/index.js', '--stdio'}
require'lspinstall/servers'.newvue = vim.tbl_extend('error', vue_config, {
install_script = [[
! test -f package.json && npm init -y --scope=lspinstall || true
npm install vscode-vue-languageservice#latest
]],
uninstall_script = nil
})
Running :LspInstall newvue installs properly, however :LspInfo shows this language server is attached to the buffer (of a .vue file) but not active. I believe the issue is with this path: ./node_modules/vscode-vue-languageservice/out/index.js. It exists, but may not be the correct entry point? The default vue ls simply has vls as the command because it provides a binary. Am I missing something in this package? I have yet to come across another language server without a single binary to pick out.
Thanks!
Can you try an absolute path to the out.js file? In my pretty elaborate config for a custom Volar install I'm using something just /home/myuser/dev/volar/packages/server/out/index.js (where the volar folder is just the whole volar cloned github repo). My full config is here
I don't think you can use relative paths like you did. I know you're assuming that the "./node_modules" means "workspace directory" but it's hard to tell in which directory nvim-lspconfig opens up those executables.
I have yet to come across another language server without a single binary to pick out.
Volar also provides a binary, it's volar-server (after running npm i -g #volar/server), it's just with a custom install (ie. alongside the real volar) you can't use it, because I assume you want to use your local install with custom code.
As for more indepth debugging/logging, you can check ~/.cache/nvim/lsp.log to see why the language server dies in detail.

Can't get es6 to work with Gulp

This is driving me insane, so I'm hoping someone might see something that I'm missing. Thank you for your help in advance.
I have a gulp file and I have installed via npm, babel-core, babel-preset-es2015, babel-preset-react. From researching online and in high hopes even though this might not be right, I have renamed the gulp file to be gulpfile.babel.js and I have created a .babelrc file with
{
"presets": ["es2015"]
}
I am using browsersync and when I launch the gulp task the html file loads, but the index.js I have includes 'import React....'. This files causing the error in the JS console that says 'Uncaught SyntaxError: Unexpected token import'.
I thought the es2015 npm packages I have should be taking care of that ES6 syntax?
In the gulp file the task that I thought was suppose to take care of that is;
// convert jsx to JS
gulp.task('babelFiles', function() {
return gulp.src('js/*.(jsx|js)')
.pipe(babel({
compact: false
}))
.pipe(gulp.dest('js'))
.pipe(browserSync.reload({
stream: true
}))
});
The gulp task that is responsible for launching this is:
// Default task
gulp.task('default', ['babelFiles', 'browserSync']);
I am puzzled as to what could be wrong here?
Any ideas would be much much appreciated!
There are two problems:
Gulp seems like doesn't support you syntax for file extension mask:
gulp.src('js/*.(jsx|js)') // not working
gulp.src('js/*.{js,jsx}') // working
You piping from js directory to js directory but since there are no matches because of the problem (1) it makes you believe the babel is not working
Update
Gulp uses glob syntaxt to match files - according to glob syntax the qualifier for amount of items should be included before ( | ) - in our case following syntax would be valid
gulp.src('js/*.#(js|jsx)')
where # means match exactly one occurrence of pattern after #.
In your case there was no qualifier presented

Load debug version of pre-built module via npm/webpack

There is a javascript library, pre-built and available on npm, that I wish to develop with/debug. In my case, it is openlayers.
In the classic way of requiring a javascript file and wanting to debug, one would just switch the script url from the production version to the debug version, ie:
to
However, when using webpack and then importing via npm:
import openlayers from 'openlayers'
Gets you the production distribution of the library, the same as the ol.js script from above.
On a side note, to stop webpack trying to parse a prebuilt library and throw a warning about that you must include something like this:
// Squash OL whinging
webpackConfig.module.noParse = [
/\/dist\/ol.*\.js/, // openlayers is pre-built
]
Back to the problem at hand: how can I conditionally load a different entry-point for a module prebuilt and imported like this?
Of course, I can do it in a hacky way. By going into the node_modules/openlayers/package.json and switching the browser field from
"browser": "dist/ol.js",
to
"browser": "dist/ol-debug.js",
Is there a way I can request a different entry point via webpack or by using a different import syntax? Do I first have to petition the library maintainers to update the browser field to allow different entry point hints to browsers, according to the spec? https://github.com/defunctzombie/package-browser-field-spec
Thoughts on a more effective way to make this happen? Yearning to be able to programmatically switch loading of the production and debug versions of a library based on env variables.
Webpack has configuration options for replacing a module into a different path: https://webpack.github.io/docs/configuration.html#resolve-alias
This resolves the openlayers import to use the debug version:
webpackConfig.resolve.alias: {
openlayers: 'openlayers/dist/ol-debug.js'
}
In my build system I have a function that takes the environment type and returns the matching webpackConfig. Based on the parameter I include the above snippet or not.
Full code: webpack-multi-config.js
I have two different (gulp-) tasks for development and production. For example the production task: webpackProduction.js
Line 1 imports the config script with production as type.
My build system is based on gulp starter.

Karma not picking the changes, have to run tests twice

I am running Jasmine tests on Karma (latest, 0.12.14) from IntelliJ IDEA (latest, 13.1.2) on OS X.
IntelliJ just uses Karma plugin that points to my karma installation: /usr/local/lib/node_modules/karma
The problem is that Karma watcher doesn't pick new changes from JS files. When I run tests again, everything is fine. It's not a huge issue (they run pretty fast), but it's annyoing to always run tests twice after you do a change.
Anybody experienced similar issue?
Add the following property to your karma.conf.js file:
usePolling: true
I put it after the autoWatch flag.
Reference: AutoWatch doesn't work #895
Finally got this to work. This is a known issue when using Karma in IntelliJ with build tools like Webpack / Gulp / etc... and that the post-processed files are outside of the files that Karma is directly serving.
The workaround is to manually modify the IntelliJ config in this file: ...\plugins\js-karma\js_reporter\karma-intellij\lib\intellijRunner.js
At or near line #75 in the runWithConfig() method, change the refresh property --> true.
See this comment for details
Had this issue in both IntelliJ and Webstorm and fixed both the same way.
In the case of using IntelliJ IDEA, maybe try
Preferences > General > Uncheck "safe write"
I am not sure if question is still actual, but i found a solution (or just a workaround).
I changed this file C:\Users\MyUser\.IntelliJIdea14\config\plugins\js-karma\js_reporter\karma-intellij\lib\intellij.conf.js a little bit here:
config.singleRun = false;
var originalAutoWatch = config.autoWatch;
//config.autoWatch = false; <-- this line
config.autoWatchBatchDelay = 0;
For sure the plugin maintainers had some reason to add this line, but for me this worked fine enough (there were isolated crashes I can't reproduce).
I am not sure about older versions of intelij but I am using 2016.3 (the latest version at the time of writing this) and it all works OK assuming karma config has autoWatch: true.
Having exactly the same problem all I have to do was to switch on Toggle auto-test in intelij and all started working fine without any other change.
Please check autoWatch property in karma config file set to TRUE.
Also if you are using Sublime Text 3 then set "atomic_save": false in your user settings as it also causes issues with watches. see here
Macros worked for me. After trying usePolling: true, modifying the intellijRunner.js, and unchecking Safe Write I still had to save or run tests twice to catch the changes.
Made a compound macro to both Save and Run File and Save and Re-Run Test. Then I overwrote each commands' shortcut via Keymap.
How to bind multiple actions to a shortcut
screenshot of macro: Save and Run test at cursor
screenshot of macro: Save and Re-run last test
screenshot of Keymap for macros

Intellij external tool does not output stdout logs from Sass

i'm using sass for my project, in intellij using sass plugin.
i want to be able to launch sass --watch from within intellij, to be able to get console feedback, with clickable lines.
i've setup an external tool in intellij with:
Program: D:\ruby\bin\sass.bat
Parameters: --watch $/FileRelativeDir$
Working directory: $ProjectFileDir$
it does compile my scss to css without problems but the stdout from sass are not reported in the intellij console. i only get stderr.
if i have an error, after a while, i get a bunch of lines at once.
so i'm guessing there is some kind of buffering happening.
redirecting 1>&2 does not solve the problem.
Here's what i get in logs
Sass::Compiler#on_updating_stylesheet callback is deprecated and will be removed in a future release. Use Sass::Compiler#on_updated_stylesheet instead, which is run after stylesheet compilation.
d:/ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.11/vendor/fssm/lib/fssm/support.rb:40: Use RbConfig instead of obsolete and deprecated Config.
and here's what i get using the same command in a console :
Sass::Compiler#on_updating_stylesheet callback is deprecated and will be removed in a future release. Use Sass::Compiler#on_updated_stylesheet instead, which is
run after stylesheet compilation.
>>> Sass is watching for changes. Press Ctrl-C to stop.
error src/main/www/css/test.scss (Line 3690: Invalid CSS after "...'); IE6 & IE7*": expected "{", was "/")
error src/main/www/css/test.scss (Line 80: Invalid CSS after "...unimplemented *": expected "{", was "/")
d:/ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.11/vendor/fssm/lib/fssm/support.rb:40: Use RbConfig instead of obsolete and deprecated Config.
(yes i have an intended error in my scss file to produce logs)
found it thanks to default ruby arguments in intellij ruby projects
you need to pass ruby the following options :
-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)
and that did the trick
Program : D:\ruby\bin\ruby.exe
Parameters : -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) d:/ruby/bin/sass -g --watch $/FileRelativeDir$
Working directory : $ProjectFileDir$