tslint

Error TS2339: Property 'entries' does not exist on type 'FormData'

前提是你 提交于 2019-12-11 00:31:47
问题 I searched on Stackoverflow and on the web, I found this thread https://github.com/Microsoft/TypeScript/issues/14813 but it does not solve my problem. I run into this error while compiling my code with ng serve --watch . Error TS2339: Property 'entries' does not exist on type 'FormData'. This part with fd.entries() triggers the error... any idea what is going on here? onFileSelected(event) { const fd = new FormData; for (const file of event.target.files) { fd.append('thumbnail', file, file

kebab-case in angular 2 selectors (tslint)

只谈情不闲聊 提交于 2019-12-11 00:06:02
问题 This is my tslint.json file: { "rulesDirectory": [ "node_modules/codelyzer" ], "rules": { "class-name": true, "comment-format": [ true, "check-space" ], "curly": true, "eofline": true, "forin": false, "indent": [ true, "spaces" ], "label-position": true, "label-undefined": true, "max-line-length": [ true, 140 ], "member-access": false, "member-ordering": [ true, "static-before-instance", "variables-before-functions" ], "no-arg": true, "no-bitwise": true, "no-console": [ true, "debug", "info",

How to ignore semicolons with “tslint:recomended”

半腔热情 提交于 2019-12-10 16:26:14
问题 I want my tslint to ignore semicolons. I would like to keep the rule "extends": "tslint:recommended" . Right now, I just can´t follow this rule, which forces me to use semicolon always, or use this other one "semicolon": [true, "never"] , which forces me to delete all semicolons. I just want to ignore them. I can do it by deleting the "extends": "tslint:recommended" but I would like to keep this rule and just ignore semicolons. tslint documentation just gives the option to keep them always or

TypeScript/TSLint: TSLint not recognizing root-relative imports, via baseUrl

孤人 提交于 2019-12-10 15:09:04
问题 I'm using root-relative imports via the baseUrl compiler option in tsconfig.json , as per this solution, but I'm having a problem where Atom IDE is showing me linting errors that look like: Cannot find module 'core/nav-menu/nav-menu.component'. The imports look like (in src/app/core/nav-menu.module.ts ): import { NavMenuComponent } from 'core/nav-menu/nav-menu.component'; TSLint in Atom isn't finding the root-relative imported files, but the Angular compiler isn't having a problem with them.

tslint one line rule misplaced 'else'

折月煮酒 提交于 2019-12-10 12:47:07
问题 I have such config in tslint.json for one line rule one-line": [true, "check-open-brace", "check-catch", "check-else", "check-whitespace" ], When I have code lines like that: if(SomethingTrue) { next("a"); } else { next("b"); } I've got warning: (one-line) file.ts[17, 9]: misplaced 'else' Why that is happens? Is it bad practice to have one line else ? 回答1: You have : else { next("b"); } Else must be one one line . So: else { next("b"); } Is it bad practice to have one line else? Just easier

Space Indentation Expected in ng lint

喜你入骨 提交于 2019-12-10 02:33:29
问题 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 ? 回答1: 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

TypeScript linter warning: no-unused-variable is deprecated; but I'm not using this config

人走茶凉 提交于 2019-12-10 01:34:52
问题 Today I see this warning in a project being refreshed after 3 months. no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead. But my tsconfig.json does not seem to use this. { "compilerOptions": { "lib": ["es6"], "module": "commonjs", "noImplicitReturns": true, "outDir": "lib", "sourceMap": true, "target": "es6", "allowJs" : true }, "compileOnSave": true, "include": [ "src" ] } Probably it's a config implicit in any of the previous configs.

How can I use TSLint in VS Code?

删除回忆录丶 提交于 2019-12-10 00:35:19
问题 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? 回答1: 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:

how to set multiple CSS style properties in typescript for an element?

大城市里の小女人 提交于 2019-12-09 09:25:37
问题 Please consider the below snippet. i need to set multiple CSS properties in typescript. for that i have tried the below code. public static setStyleAttribute(element: HTMLElement, attrs: { [key: string]: Object }): void { if (attrs !== undefined) { Object.keys(attrs).forEach((key: string) => { element.style[key] = attrs[key]; }); } } for the above code i need to pass the parameters as let elem: HTMLElement = document.getElementById('myDiv'); setStyleAttribute(elem, {font-size:'12px', color :

tslint-loader with webpack 2.1.0-beta.25

我的未来我决定 提交于 2019-12-09 08:02:34
问题 I have an angular2 Project that I compress/compile with webpack. I use tslink loader with webpack so I have tslint related configuration in webpack.config.js . module.exports = { ... tslint: { configuration: { rules: { quotemark: [true, "double"] } }, // tslint errors are displayed by default as warnings // set emitErrors to true to display them as errors emitErrors: false, // tslint does not interrupt the compilation by default // if you want any file with tslint errors to fail // set