tslint

[tslint]Expected a 'for-of' loop instead of a 'for' loop with this simple iteration (prefer-for-of)

馋奶兔 提交于 2019-12-08 15:40:34
问题 I have got a tslint error to my for loop when I try to resolve it it says to convert to for-of. I have seen many docs but its not helpful.How can I solve the lint error and I cannot do tslint:disable-next-line:prefer-for-of for (let i = 0; i < this.rows.length; ++i) { if (!this.rows[i].selected) { this.selectAllChecked = false; break; } } 回答1: It is asking you to use format like the following. The of keyword loops over the objects in the array instead of looping over the indexes of the array.

Prettier in VS Code formatting (new lines before arguments)

99封情书 提交于 2019-12-07 06:12:07
问题 I'm using Angular Essentials by John Papa - in particular, Tslint and Prettier. For some reason, it transforms this code this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max(Math.min(this.rM.startVA + 2 * diffY * 180 / size, 90), -90); into this this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max( Math.min( this.rM.startVA + 2 * diffY * 180 / size, 90 ), -90 ); How can i avoid it? I've tried to play with tslint.json settings: "max-line-length":

TSLint not working with CRA and TypeScript

安稳与你 提交于 2019-12-06 23:23:28
问题 I'm banging my head for hours trying to enable linting for a TypeScript project created with create-react-app. The wmonk/create-react-app-typescript repo is now deprecated Therefore, I followed these instructions from the CRA documentation The issue is that the suggested implementation above doesn't add any linting to the newly created project. So far I've tried: Installing TypeScript TSLint Plugin as an extension to my VSCode Creating a tslint.json file on my project with the following

TypeScript and Chrome Notification

眉间皱痕 提交于 2019-12-06 23:19:35
问题 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

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

霸气de小男生 提交于 2019-12-06 14:12:35
问题 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

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

徘徊边缘 提交于 2019-12-06 07:09:54
问题 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

TSLINT: Remove Missing Whitespace rule on Import

一曲冷凌霜 提交于 2019-12-06 01:15:01
问题 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

Prettier in VS Code formatting (new lines before arguments)

丶灬走出姿态 提交于 2019-12-05 12:58:19
I'm using Angular Essentials by John Papa - in particular, Tslint and Prettier. For some reason, it transforms this code this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max(Math.min(this.rM.startVA + 2 * diffY * 180 / size, 90), -90); into this this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size; this.rM.vA = Math.max( Math.min( this.rM.startVA + 2 * diffY * 180 / size, 90 ), -90 ); How can i avoid it? I've tried to play with tslint.json settings: "max-line-length": [true, 165] But that one does not affect in my case. EDIT: as following the similar issue I've tried

How do I get tslint to watch for changes in a specific folder?

微笑、不失礼 提交于 2019-12-05 05:27:13
I am using webpack 2, and it will tell me if there are compile issues with my typescript code. However, I have not figured out a way to run tslint through it and have it run with every change detected by webpack when its running in dev-server mode. I have tried getting tslint-loader working, but for each file in my project it simply tells me: /src/main.tsNo valid rules have been specified I am using it as such: rules: [ { test: /\.ts$/, enforce: 'pre', loader: 'tslint-loader', options: { configuration: { configFile: true // I have also tried setting this to "tslint.json" } } }, ... more

TSLint not working with CRA and TypeScript

自古美人都是妖i 提交于 2019-12-05 03:59:15
I'm banging my head for hours trying to enable linting for a TypeScript project created with create-react-app. The wmonk/create-react-app-typescript repo is now deprecated Therefore, I followed these instructions from the CRA documentation The issue is that the suggested implementation above doesn't add any linting to the newly created project. So far I've tried: Installing TypeScript TSLint Plugin as an extension to my VSCode Creating a tslint.json file on my project with the following config: { "rules": { "no-debugger": false, "no-console": false, "interface-name": false }, "linterOptions":