How to prevent Karma from removing a file? - karma-runner

Karma works perfect with Notepad++. When I use Visual Studio as my text editor it removes the file it is supposed to watch after I save the file. This is the output from Karma showing the error:
This is the ticket that is being presented as the solution but it doesn't fix anything.
Is there any way to setup the config file so that it still uses autoWatch (tests on every save) but doesn't remove the file if I use Visual Studio?
I've tried
running the command prompt as admin
setting autoWatchBatchDelay, in the config file, to a large number (2500)
This is my current config file:
module.exports = function (config) {
config.set({
files: [
'e2e.js'
],
autoWatch: true,
browsers: ['IE', 'Chrome'],
frameworks: ['jasmine'],
autoWatch: true,
plugins: [
'karma-ie-launcher',
'karma-chrome-launcher',
'karma-jasmine'
]
});
}

The only way that I have made this work is by watching a folder instead of a file.
In files, watch '*.js' instead of 'e2e.js'.

Related

Why the stylelint vscode extension is not working on my computer?

I follow the guide to install stylelint vscode extension, but it does not work on my computer.
I'm pretty sure that I follow all the necessary steps.
Install Extensions.
Disable the built-in linters in User setting.
Use npm to install stylelint and its standard configuration.
Create a .stylelintrc.json configuration file in the root of my project.
Run stylelint from command-line.
But the extention still not automatically validate the css, what is going wrong?
After reading the guide again, I found the setting stylelint.config and understand its definition:
Set stylelint config option. Note that when this option is enabled, stylelint doesn't load configuration files.
So I look at my vscode user setting, oh, stylelint.config: {}. After changing it to null, stylelint automatically validates the css file immediately.
Phew~
I faced the same issue. Let me share how I got it to work smoothly with Stylelint extension ver.1.2.2:
In root project folder, you should have the following structure:
/path/to/project/
.vscode/
settings.json
extensions.json
src/
.stylelintrc.json
package.json
extensions.json
From the official documentation: Starting with 1.x, vscode-stylelint will depend on having a copy of Stylelint installed in the open workspace (recommended) or globally (not recommended). If the extension doesn't seem to be linting any documents, make sure you have Stylelint installed
{
"recommendations": ["stylelint.vscode-stylelint"]
}
settings.json
{
"css.validate": false,
"less.validate": false,
"scss.validate": false,
"stylelint.validate": ["css", "scss"]
}
package.json
Some of the following packages are to detect reserved words inside sass files such us #use, #export, #global and so on. I think you don't actually need all of them, but it is my configuration.
// DevDependencies
"stylelint": "^14.6.0",
"stylelint-config-css-modules": "^4.1.0",
"stylelint-config-standard-scss": "^3.0.0",
"stylelint-scss": "^4.2.0"
.stylelintrc.json
{
"extends": ["stylelint-config-standard-scss", "stylelint-config-css-modules"],
"plugins": ["stylelint-scss"],
"rules": {
"at-rule-no-unknown": null,
"scss/at-rule-no-unknown": true
}
}
After configuring each file, remember to close vscode and open it again in order to start enjoying Stylelint!
In the extension settings, you should to check the file extensions, which it is watching:
Stylelint: Snippet
Stylelint: Validate
You can also do it through setting.json
"stylelint.snippet": [
"css",
"less",
"postcss",
"scss"
],
"stylelint.validate": [
"css",
"less",
"postcss",
"scss"
]
Open extension settings to add a configuration rules source stylelint-config-standard-scss (or whatever you installed, more here )
For example, I have this, additionally rewritten some of my rules:
"stylelint.config": {
"extends": "stylelint-config-standard-scss",
"rules": {
"no-empty-source": null,
"no-missing-end-of-source-newline": null,
"max-line-length": [
300,
{"ignore": ["comments"]}
],
"selector-combinator-space-after": "never",
"selector-combinator-space-before": "never"
}}
The same settings in the linter for the GitHub Action and in the VSCode extension are very convenient. Now I know about the problems in advance and do not wait until the build happens in the repository.
I got a new PC and installed the newest version, 1.2.1, and nothing worked - then I checked the version on the old PC, and it was at version 0.86.0. When changing the version to the older version and reloading VSC, it worked immediately.

How to exclude specific directories from "go to definition" in vscode

I use CTRL+Click (or F12) to search and open the definitions in vscode. The problem is that my files are copied to another directory called sketch as I compile my code, so when I wanna open the definition of a function, VS shows both files (the real and the copied ones in the sketch folder), and sometimes I edit the copied file by mistake!
How can I exclude some folders from the "Go To definition"?
I had the same problem in a Javascript project.
None of the following solved it for me: files.exclude, files.watcherExclude, or search.exclude.
The solution was to add jsconfig.json to my project folder:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"Backup",
"Sketch"
]
}
This example specifies two folders to exclude: "Backup", and "Sketch".
If you are using TypeScript, use a tsconfig.json file instead.
Also see https://code.visualstudio.com/docs/languages/jsconfig
Add files to C:\Users\user\AppData\Roaming\Code\User\settings.json:
"files.exclude": {
"**/sketch": true
},
Or files to exclude when searching (in files):
"files.watcherExclude": {
"**/*.x": true,
},

eslint not running for html files

It would seem the eslint extension is not startet in VSCode when I open .html files.
If I execute ESLint: Fix all auto-fixable Problems with a .html file opened I get the following message:
ESLint is not running. By default only JavaScript files are validated. If you want to validate other file types please specify them in the \'eslint.validate\' setting.
Everything is working fine when I open .js files in vscode.
I have already installed the eslint-plugin-html plugin.
Everything is working fine when I manually pass the .html file to eslint CLI, thus I gusss it's not an issue with the eslint plugin.
Here's my complete settings.json file:
{
"eslint.options": {
"extensions": [".html", ".js"]
},
"eslint.validate": [
"javascript",
{
"language": "html",
"autoFix": true
}
]
}
Here's the start of my .eslintrc.js file:
module.exports = {
env: {
browser: true,
es6: true,
},
extends: 'airbnb-base',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
"align-assignments", "html",
],
settings: {
"html/report-bad-indent": "error",
},
rules: { ...
I have already looked at eslint is running but not showing any lint errors/warnings and at How can I get ESLint to lint HTML files in VSCode? but none of the answers did help me.
Note that I do not even see the ESLint output channel as described in the screenshot here: https://stackoverflow.com/a/54138880/4349415
I can only see this ESLint output channel, telling me that the ESLint server has startet, when I open a .js file.
The issue was not with ESLint or VSCode, but with another VSCode third party extension: Mako (version 0.2.0)
https://marketplace.visualstudio.com/items?itemName=tommorris.mako
Disabling this extension fixed the ESLint support in HTML files.

How can I make Visual Studio Code use global eslint and not project eslint?

My project has eslint and it's own eslint.json file with its rules, I want to either use that my global eslint or override the project level one and just use my global eslint settings, is there a way to do that.
I currently have the following settings in my VSC
"eslint.enable": true,
"eslint.run": "onSave",
"eslint.autoFixOnSave": true,
"eslint.trace.server": "messages",
"eslint.alwaysShowStatus": true,
"eslint.options": { "configFile": "/Users/almog/.eslintrc.json" },
you can initiate eslint in your required folder by using eslint cli command elsint --init and follow the instructions and then specify the eslintrc (eg: .eslintrc.js)
setup file path in vscode "eslint.options": { "configFile": "C:\\Users\\user66\\.eslintrc.js" }

Possible to get all intellisense on .js files?

This is specific question about .js files. Not .ts files. With ts files i'm able to get it all working properly.
I made all the setup options for js files and it still doesn't work, if at all possible:
jsconfig.json in project root:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"removeComments": true,
"pretty": true,
"allowSyntheticDefaultImports": true // false doesn't change anything
},
"files": [
"typings/index.d.ts"
]
}
I also installed typings for node, and all express standard typings.
Yet, on my app.js file:
import * as express from "foo"
var app = exfprdess();
doesn't trigger any underlined error. How to get proper behavior ?
Visual Studio Code, by default, doesn't lint your code (meaning it doesn't check for errors).
Visual Studio Code can, however, lint your code, you'll just have to configure something like ESLint or JSLint.