Typescript: How to supress any semicolon warnings - tslint

I want to be like all the cool kids so I desperately want to use typescript. Is there a way to suppress the Unnecessary semicolon warnings, other than not putting in unnecessary semicolons? I don't want tslint complaining either way about semicolons.
My tslint.json:
{
"defaultSeverity": "warning",
"extends": [
"tslint:recommended"
],
"linterOptions": {
"exclude": [
"node_modules/**",
"src/plugins/**"
]
},
"rules": {
"quotemark": [true, "single"],
"indent": [true, "spaces", 2],
"interface-name": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"no-consecutive-blank-lines": false,
"member-access": [true, "no-public"],
"semicolon": [true, "never"],
"trailing-comma": "ignore",
"no-console": false
}
}

The problem turned out to be the tslint extension for vscode.
vscode-tslint has been deprecated and suggests this extension vscode-typescript-tslint-plugin be used in its place.
This post led me to the solution.

Related

My Angular tsconfig does not detect my Cypress types

My Angular tsconfig does not detect my Cypress 12.3 types. I've tried all kinds of things to get this working, short of starting my Cypress project over (which I suspect would work).
My code runs fine but I cannot resolve this situation pictured here in my IDE:
At the moment, my cypress/tsconfig.json looks like this:
{
"extends": "../tsconfig.spec.json",
"files": [
"../cypress/**/*.ts",
"../cypress.config.ts",
"../node_modules/cypress"
],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress", "node", "jasmine-expect", "chai"]
}
}
The above config is trying to prefer jasmine expect type over chai expect, which I REQUIRE.
Ok, I found the solution. Must be careful about using files rather than include/exclude:
{
"extends": "../tsconfig.spec.json",
"include": [
"**/*.ts",
"../cypress.config.ts",
"../node_modules/cypress"
],
"exclude": [
"../src/**/*.ts"
],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress", "node", "jasmine-expect"]
}
}

Please tell me why I am constantly getting a settings sync fail error message when I open VS code

I made the mistake of following a youtube video to improve setup of VS code, after making the adjustments I always get the settings sync error message. I click on show error file, and highlights the editor.fontSize line. I cannot see anything wrong with it personally:
{
"workbench.colorTheme": "Cobalt2",
"security.workspace.trust.untrustedFiles": "open",
"window.zoomLevel": 1,
"liveServer.settings.donotShowInfoMsg": true,
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modificationsIfAvailable",
"html.format.indentInnerHtml": true,
"[css]": {
"editor.defaultFormatter": "michelemelluso.code-beautifier"
},
"sync.gist": "7aea226d700927d0abdecbd3c2260369",
"sync.autoDownload": true,
"sync.quietSync": true,
"liveSassCompile.settings.watchOnLaunch": true,
"liveSassCompile.settings.formats": [
{
"format": "expanded",
"extensionName": ".css",
"savePath": "/css/style.css"
},
]
}
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.guides.bracketPairs": true,
"editor.guides.bracketPairsHorizontal": true,
"editor.wordWrap": "on",
"workbench.iconTheme": "vscode-icons"
I have tried uninstalling many many times and all my settings get restored and never go back to default. I have tried advice here as to making some changes from other peoples similar problems, but nothing seems to work. Any assistance would be greatly appreciated, this pops up any time I try to make a settings change also.
try to delete this section
"sync.gist": "7aea226d700927d0abdecbd3c2260369",
"sync.autoDownload": true,
"sync.quietSync": true,

Add refrrence for custom commands declaration in Cypress.io

I added some custom commands to my project and I also added a declaration file. According to Cypress's documentation, they say "To include the new ".d.ts" file into IntelliSense, I could update tsconfig.json", so I did and I don't know what is wrong...
the tsconfig file :
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"allowJs": true,
"strict": true,
"baseUrl": ".",
"paths": {
"cypress": [
"../node_modules"
],
"support": [
"../support"
]
},
"types": [
"cypress",
"support"
],
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"**/*.ts",
"**/*.d.ts"
],
"exclude": [
"config/config.js"
]
}
Refer to the Cypress Real World App, a payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows.
The cypress/global.d.ts file demonstrates how to add type declarations for custom commands and tasks and cypress/tsconfig.json has additional TypeScript configuration.

Don't require semicolon in singleline block

Eslint for semicolons has option omitLastInOneLineBlock:
"semi": ["error", "always", { "omitLastInOneLineBlock": true }],
I'd like to use similar setting with tslint. How can I configure it?
Here is my tslint.json:
{
"defaultSeverity": "error",
"extends": [
"tslint:latest",
"tslint-react"
],
"jsRules": {},
"rules": {
"no-unused-expression": [true, "allow-fast-null-checks"]
},
"rulesDirectory": []
}

TypeScript error: "Cannot find name" in Visual Studio

I've seen a lot of threads and discussions about that but I'm not getting to fix the issue. This is my post from some days ago.
One of the purposes of typings is to avoid the use of <reference> tags, right?
But if I don't use it, Visual Studio complains:
Visual Studio stops complaining once I reference browser.d.ts.
Here is my tsconfig:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"files": [
],
"exclude": [
"node_modules",
"wwwroot"
]
}
I also tried removing the "files" property from the tsconfig as suggested here, but if I do this, I get compilation error in other typescript files inside the ambient folder of typings.
The code runs and all is fine, but I want to understand if I'm doing something wrong or if it's a Visual Studio problem.
For those who might have the same issue in the future:
I fixed the issue. The secret is to exclude the "files" property from tsconfig and in the "excluded" section add the folder "typings".
The tsconfig should now look like that:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"typings",
"node_modules",
"wwwroot"
]
}
In my case I fixed adding "jasmine" into "types" section in tsconfig.json. Like this:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"typings",
"node_modules",
"wwwroot"
],
"types": ["jasmine"]
}

Resources