$ npm run lint
/Users/john/test/src/index.ts
274:35 warning 'event' is defined but never used #typescript-eslint/no-unused-vars
You may want to use a different formatter to have the problems printed in a way that lets you open the respective lines by clicking on a link in the terminal.
This should work out of the box:
npx run lint -- --format=visualstudio
and print
/Users/john/test/src/index.ts(274,35): warning #typescript-eslint/no-unused-vars : 'event' is defined but never used
Or this one:
npx run lint -- --format=unix
which prints
/Users/john/test/src/index.ts:274:35: 'event' is defined but never used [Warning/#typescript-eslint/no-unused-vars]
To avoid specifying the formatter manually every time, you could add them directly to the "lint" script defined in the file package.json, e.g.:
"scripts": {
...
"lint": "eslint . --format=visualstudio",
...
},
The terminal isn't smart enough to do that. For it to hyperlink straight to a location in a file, the path would have to be immediately followed by a colon and the location, i.e. /Users/john/test/src/index.ts:274:35.
Instead, you might consider installing a plugin, or configuring an existing one, to show lint results in the Problems view. VSCode will then link straight to the location. I don't have any recommendations since I don't work in TypeScript myself, but FWIW, the Python extension can do that, for example with the Pylama linter enabled.
Related
(not sure if I asked this earlier somewhere, but I can't find it)
Earlier I found out how to create a usable entry on the VSCode settings menu (also usable in settings.json) by editing these VSCode source files:
vscode/src/vs/editor/common/config/editorOptions.ts
Adding a variable in export interface IEditorOptions.
Adding an enum in export const enum EditorOption.
Adding an item in export const EditorOptions.
vscode/src/vs/editor/common/standalone/standaloneEnums.ts
Adding an enum to export enum EditorOption.
I don't know if that's the correct way, I just copied other options.
I hadn't yet figured out how to access the new entry's value from the function I wanted to use it in (I had already implemented the functionality, just without the option).
I then got sidetracked and forgot about this.
Now when I try to build it I'm getting an error (it builds fine without the changes).
running yarn --cwd <mydir> run gulp vscode-linux-x64
gives Error: monaco.d.ts is no longer up to date. Please run gulp watch and commit the new file.
I'm not sure exactly how I'm supposed to run gulp watch here. I don't know anything about yarn or gulp (I'm just using the VSCode contributor instructions), and running yarn --cwd <mydir> run gulp watch doesn't fix the problem.
It sounds like vscode/src/vs/monaco.d.ts being read by the build process before being written/updated, because its timestamp changes. I'm not sure if that's my fault and/or if it's a red herring.
Does anyone know what I should be doing here? Has anyone here modified the settings menu?
Is there any documentation out there for modifying the settings menu? (I had a look, didn't find anything).
This is a long post, sorry.
I have been trying to start a project, using Rust, but ran into a problem: it just does not work correctly on Linux in VSCode/Atom.
Wasted 3 days, searching online, trying different tutorials/videos - nothing worked + most of the material is from 2017. I have tried Matrix chat, but no one knew what to do. Git too has no solution as people keep suggesting very random things, like "change this variable in toml file to something else, and back again"
Git: https://github.com/rust-lang/rls-vscode/issues/513
I installed (and re-installed rust many times in the last 3 days), and it works just fine from the terminal, but not in the Editor.
Two Issues:
Editors don't see any crates, so you can't run your code from the editor.
Autocomplete does not work (only works on std, not on extra crates you add).
What I did (out of many other things):
install Rust (on Manjaro and Debian computers): curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Tried stable, beta, nightly (for racer)
Just did a clean install again:
stable installed - rustc 1.40.0 (73528e339 2019-12-16)
Rust is installed now. Great!
Installed Rust (rls) rust-lang.rust extension in VSCode (and rust in Atom)
Created a new project: cargo new test_proj and added new rand = "0.6" to [dependencies] and used cargo build. It did build rand
Added "rust-client.enableMultiProjectSetup": true to the settings file to avoid a warning: A Cargo.toml file must be at the root of the workspace in order to support all features. Alternatively set rust-client.enableMultiProjectSetup=true in settings. by Rust (rls)
I also install 'code runner' extension that I use with Python, C++, and Java, to run the code from within the editor.
So now I have just the main func and it runs just fine from the editor:
Now I add rand and it seems to work, and does SOME auto-completion...
But now it stops working:
OK, I will finish the code and try running it, And now we can't run it anymore as the crate is missing:
OK, let's try Ctrl + Shift + B and try cargo build:
For some odd reason, it is looking in /media/Work/Work/rust_code and not in /media/Work/Work/rust_code/test_proj/
One last thing: let's try running in the terminal:
So it does work just fine.
Sorry for the long post, but I have wasted 3 days now and it still can't get it up and running. Did anyone manage to set this up at all?
It has to be Atom or VSCode as I have all of the other languages/projects setup there + VSCode is listed on the official Rust website, so I presume it should work.
Basically, out of two editors (VSCode and Atom), that have Debugging capabilities, unlike Intellij Rust, both don't work for me and I just can't code in Rust as tools are literally broken/not mature enough for productive work. Please let me know if I am wrong and it is just a case of one little flag, that everyone forgets to mention, is missing in some config.
Short Version
Assuming I understand the issue correctly. Then the various build issues boil down to different ways you're trying to build the project, and attempting to do so in different directories.
TL;DR: The directory you have open in VSCode is the rust_code directory. Close it and instead open rust_code/test_proj. Now the Rust: cargo build (or Rust: cargo run) should work.
Long Version
Editors don't see any crates, so you can't run your code from the editor.
The Rust: cargo build task isn't working, because the directory you have open isn't a "Rust project" (Cargo package), it's a directory containing another directory, which is a Rust project.
Looking at your screenshot shows this, look at how the top line says rust_code/test_proj:
When you execute the task, Cargo is complaining that rust_code/Cargo.toml doesn't exist, which is true since it's located in rust_code/test_proj/Cargo.toml
If you look at the output of this screenshot, you can see that is the case:
Here you're executing cargo run manually. But the important difference is that you're inside the rust_code/test_proj directory.
Lastly simply executing rustc main.rs is failing since you aren't passing the arguments needed. So rustc doesn't know anything about your dependencies.
Try executing cargo build -v then you can see all the arguments that Cargo is passing to rustc.
Autocomplete does not work (only works on std, not on extra crates you add).
Try and open a directory that contains a Cargo.toml, then code completion should work for dependencies. If I don't, then I get the following notification, and code completion only works for the standard library as you said. That being said, RLS is weird sometimes.
If I had to guess, then I think RLS compiles the code, and at some stage extracts the needed information. Thus if the code doesn't compile, then code completion could be affected. But this is 100% an educated guess.
Alternatively, I have heard praise about using IntelliJ + the Rust plugin, but I haven't used it myself yet.
I have figured out one part: problems with running your code from within the VSCode. I had to modify default code-runner command for rust:
Original command:
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
Changed to:
"rust": "if [ $(basename $dir) = 'examples' ]; then cargo run --example $fileNameWithoutExt; else cargo run; fi",
And now it works, and I can run my code quickly.
Part 2: Autocomplete still is very very bad, unfortunately. I am using RLS. there is this thing racer. Is it a better choice?
Alternatively, I have heard praise about using IntelliJ + the Rust
plugin, but I haven't used it myself yet.
As I mentioned in my previous post, IntelliJ, free edition does not have a debugger from what I can see. I need it.
I am wondering how people get a good autocomplete from Rust?
I'm trying to start an ionic server with --no-open enabled on run ionic serve, as described in ionic CLI documentation.
But, in the generated file I need to use npm run ionic:serve. I'm trying to add an extra parameter on file package.json like:
"ionic:serve": "ionic-app-scripts serve --no-open"
It doesn't works.
Maybe, there is some property in file ionic.config.json that allows me to do it.
So, I have two questions:
How can I avoid to open a browser window using npm run ionic:serve?
Where can I find a complete list of all available properties and their valid values applied to file ionic.config.json?
The correct parameter is --nobrowser instead of --no-open as described in the documentation.
I've noticed the parameter in the github repository of ionic-app-scripts.
I have added some extensions in vscode and after that, every time I open/switch to a tab with a C file, I am getting a dropdown with three error messages about not being able to activate analyzers. Why?
Here are the extensions:
and here are the error messages:
That should be caused by c/c++ Advanced lint module, well the same error can be caused by others modules, those errors occur, when you don't have those modules that you are getting warning about installed, in this case Clang, CppCheck, and flexeLint. Well for the two first you can download and install them from here:
clang: http://clang.llvm.org/ (go to download section)
cppCheck: http://cppcheck.sourceforge.net/
flexlint: here the bad news, that's not a free product, and some kind of expensive. http://www.gimpel.com/html/flex.htm
for those programs, once installed, by default should be added to the system path environment variable (if not you can do it yourself, cppcheck don't add automatically to path in windows), the thing if they are added to the path, vscode or the calling plugin here "c/c++ Advanced lint", will recognize them, because will test if the command is recognized at the console level. If you don't want to add those tools to path, you can still specify in parameters the path to those tools executables, for that you can follow the instruction for every module here they are :
cppCheck : https://marketplace.visualstudio.com/items?itemName=matthewferreira.cppcheck (using this setting cppcheck.cppcheckPath:)
clang: (clang.executable) see here: https://marketplace.visualstudio.com/items?itemName=mitaki28.vscode-clang
flexlint: (c-cpp-flylint.flexelint.executable)
and of course setting the path to executable in each one of those settings.
well you can also check that : https://marketplace.visualstudio.com/items?itemName=jbenden.c-cpp-flylint
it's so often that plugins depends on others programs, on which you need to install manually, and every time, you need to read the documentation for the module to be installed, to see what configuration you need to do.
for the warning about flexlint you can disable it by adding this to the user settings :
"c-cpp-flylint.flexelint.enable": false
that disable completely the use of flexlint, and so the plugin will not search for it. I'm not sure, may be setting cppcheck is sufficient, otherwise you have that to set. I personally have that set. Of course unless you count to buy the product and then just set the path.
hope you all, all the best!
I want to set my Grunt.js file to launch my MAMP server on grunt serve.
I have been trying to use this tutorial here to do this:
https://coderwall.com/p/kwne-g
I was then planning to use this tutorial to set up grunt watch:
http://darrenhall.info/development/yeoman-and-mamp
Now I am having trouble with step one. I have successfully installed grunt exec. However, grunt claims not to be able to find the task 'serverup'.
Here is my code:
grunt.task.run([
'clean:server',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'serverup',
'watch',
'serverdown'
]);
If you followed the examples at the link, it looks like your targets should be exec:serverup and exec:serverdown for the tasks to work.
The problem here and with many other Grunt related questions is that without the full Gruntfile, "answers" are largely guesses. Configuration, task loading, and task registration are all related and without seeing all three, it is difficult to say "this is the answer".
Given that, here's a checklist I use for problems like this when using Grunt and packages from NPM:
Is the code that supports the task installed? Did I forget npm install? Did I miss
errors on install (check npm-debug.log if it exists)?
Have I correctly used grunt.loadNpmTasks for the plugin? Is the line in my Gruntfile and
did I get the plugin name spelled correctly? Did I or my IDE accidentally use to
grunt.loadTasks when I need loadNpmTasks?
Have I correctly named/used grunt.registerTask for the task? If I need to call a
specific target for a task, do I have the the name correctly specified?
If there are paths involved and things are broken, do I have my globbing patterns correctly specified? If a cwd
is involved, do I have the other paths or files correctly specified?
Did I get the configuration right? (This is where things get too plugin-specific for a
checklist.)