tslint

TypeScript and Chrome Notification

馋奶兔 提交于 2019-12-05 03:45:15
I'm building a Chrome app. The app is written with TypeScript (Angular2). I would like to push notifications. Here's the code : import {Injectable} from 'angular2/core'; @Injectable() export class NotificationService { constructor() { if(Notification.permission !== 'granted') { Notification.requestPermission(); } } } When gulp build the app, it says : src/scripts/stream/notification.service.ts(6) Cannot find name 'Notification'. I tried to wrap my class inside : /* tslint:disable */ ... the code /* tslint:enable */ But it does not change anything. Is there a way with tslint.json file to tell

Space Indentation Expected in ng lint

廉价感情. 提交于 2019-12-05 02:12:17
I keep getting error "space indentation expected" while running ng lint . It is a quite amount of lines that having the same issue in my application. How can I solve this warning? Is anyone having face the similar issue ? By default ng lint expects indentation to be 2 spaces. You can change these settings in your tslint.json. If you want to use 4 spaces: "indent": [ true, "spaces", 4 ] If you want to use tabs (4 spaces wide): "indent": [ true, "tabs", 4 ] See this section of the docs for reference. If anyone came here because they're seeing this in vscode despite having a perfectly good tab at

How can I use TSLint in VS Code?

别说谁变了你拦得住时间么 提交于 2019-12-04 22:14:37
I have installed TSLint in VSCode and created a tslint.json file next to tsconfig.json . But TSLint is not working. For example, I added "curly": true to tslint.json , but when I write a if statement without curly braces, VS Code doesn't give any warning. What does this extension do? The vscode-tslint extension currently crashes silently when it encounters an invalid config-option. In my case, it was the no-trailing-comma rule which has to be changed to trailing-comma . More info here: https://github.com/Microsoft/vscode-tslint/issues/66 On a new machine, I installed VS Code tslint extension

Vue Prop has no initializer and is not definitely assigned in the constructor

白昼怎懂夜的黑 提交于 2019-12-04 18:13:07
I am using props in Vue Class components. The props are defined in the constructor without a value. This compiles and works fine, but since the latest VS Code / TSLint update, I get the following warning: Property 'tag' has no initializer and is not definitely assigned in the constructor. Vue Class Component export default class Browser extends Vue { @Prop({default: '', required:false}) tag: string created(){ console.log("the tag prop is " + this.tag) } } If I DO assign it, I get the Vue warning that you shouldn't manipulate a Prop in a child component. [Vue warn]: Avoid mutating a prop

How to make IntelliJ IDEA lint TS script in .vue?

…衆ロ難τιáo~ 提交于 2019-12-04 11:54:40
I've been working with Vue & TypeScript lately, and I just can't get this working: I'm using tslint to provide a unified code style on all TS script, and it works well for all .ts files. The problem is, that the IDE uses its default settings when linting my .vue files. Example.vue: <template> <div>Example</div> </template> <script lang="ts"> import Component from "vue-class-component"; //<-- not complaining for double-quotes import Vue from 'vue'; @Component export default class Example extends Vue {} </script> The same piece of code is resulting in a linter warning by IntelliJ IDEA if put in

How to order imports with tslint's import-ordering rule

柔情痞子 提交于 2019-12-04 08:49:22
问题 On my project tslint's "import-ordering" rule is used import CopyLensModal from './CopyLensModal'; import FetchStatus from '../../../../../state/generic/models/FetchStatus'; import FlexRow from '../../../../generic/components/FlexRow'; import Geofilter from '../../../../../state/geofilter/models/Geofilter'; import Input from '../../../../generic/components/Input'; import * as React from 'react'; import * as salert from 'sweetalert'; import { func } from '../../../../../types/func'; import {

TSLINT: Remove Missing Whitespace rule on Import

元气小坏坏 提交于 2019-12-04 07:47:54
TSLint requires an import like this... import { RouterModule } from "@angular/router"; However, my IDE imports everything like this... import {RouterModule} from "@angular/router"; Now I am sure I can configure the IDE to change this but it would seem to be easier just to turn off this rule. However, I am new to linting and I am not sure where to find the right rule to disable. I still want some enforcement of whitespace (properties etc) but just not this one. What is the proper setting to turn off just this rule? There is not a rule targeting the specific case you describe, but there is a

Tslint and node-modules errors

送分小仙女□ 提交于 2019-12-04 05:26:13
问题 I am having problems with running tests of angular using jasmine or cucumber or whatever framework. The app is written in angular 5 that uses typescript and generated by JHipster. The result of running tests is this and it seems to last hours and hours in cmd without any change: C:\Users\67563478\new_workspace\onconsup123\src\test\javascript\spec>yarn test yarn run v1.5.1 $ npm run lint && karma start src/test/javascript/karma.conf.js > oncosup@0.0.0 lint C:\Users\67563478\new_workspace

tslint how to disable error “someVariable is declared but its value is never read ”

≡放荡痞女 提交于 2019-12-03 22:03:56
I'm using tslint, and got the error. 'myVariable' is declared but its value is never read. I went to the website that documents the rules https://palantir.github.io/tslint/rules/ and searched for the string is declared but its value is never read but didn't find that text. While I can and did look for settings that might be tied to this error, it shouldn't be a guessing game. What is the configuration change needed to suppress/stop this error? Just as importantly, when I get an error in tslint that says "this happened" how can I find what setting is used to configure or change the tslint

TSLint in Visual Studio 2015/2017?

烂漫一生 提交于 2019-12-03 12:00:14
My organization uses TSLint pretty heavily for quality-checking our Typescript code, and it provides a valuable service to us! However, we use Visual Studio 2015 & 2017 as our main IDE and the only way to get the linting results it to run a gulp/grunt task which prints the output to the Task Runner Explorer console. It works, but it's slow and not the best development experience. In smaller projects on my own I've used VSCode, which has a fantastic TSLint plugin that highlights linting violations as you make them, and provides access to the auto-fixers that some TSLint rules have. Like this: