我的tslint.json中有一些需要--type-check功能的规则.WebStorm没有给我一种方法来添加命令行参数和TSLint插件.它也没有给我一种从GUI启用它的方法.
结果TSLint崩溃,TSLint插件报告错误,我看不到检查.
当我使用--type-check参数从命令行运行TSLint时,它可以工作,但我需要在IDE中进行检查.
有没有人有这种情况的解决方法?
我在运行tslint时收到以下错误,我之前没有收到..
ERROR: C:/...path..to../observable-debug-operator.ts[27, 13]: Shadowed name: 'Observable'
Run Code Online (Sandbox Code Playgroud)
我按照本教程向Observable添加了一个调试操作符,它正常工作,除了我得到这个lint错误.我一直在使用这个调试操作符一段时间没有得到lint错误,我不知道为什么我现在得到它.
这是第27行的代码,用于使用调试方法修改类型定义
declare module 'rxjs/Observable' {
interface Observable<T> { // line 27
debug: (...any) => Observable<T>;
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道我怎么能清除这个lint错误?谢谢!
我工作的公司即将启动一个新的企业 Angular 应用程序。在阅读linting 时,我读到TSLint 正在被弃用。
由于 TSLint 默认包含在 Angular 中,我开始寻找 Angular 团队必须处理弃用的任何计划。我发现了这个 GitHub 问题,这不是很有帮助。它指向我这里,我找不到任何与该问题相关的帖子。
我的问题是:
ng lint
在观看文件更改期间有没有办法运行ng serve
?为了鼓励根据Angular 2样式指南的最佳实践,我们的CI工具ng lint
在构建过程中运行,并且并不总是开发人员首先想到在提交拉取请求之前运行lint.
是否可以自定义ng serve
在重新编译过程中包含运行lint的方法或者有没有人想出的方法?如果没有,我也有兴趣知道其他人是否对这是否是一个好主意以及为什么有任何意见.
目前,针对问题/错误突出显示的eslint/tslint是超级不可见的(例如,比较Atom).几乎不可能发现问题 - 找到小绿色高亮区(见截图)
VSCode:
原子:
我的组织非常重视使用TSLint来检查我们的Typescript代码,它为我们提供了有价值的服务!但是,我们使用Visual Studio 2015和2017作为我们的主IDE,并且获得linting的唯一方法是运行gulp/grunt任务,将输出打印到Task Runner Explorer控制台.它有效,但它很慢,而不是最好的开发经验.
在我自己的小型项目中,我使用了VSCode,它具有一个出色的TSLint插件,可以突出显示linting违规,并提供对某些TSLint规则所具有的自动修复程序的访问权限.像这样:
是否可以在Visual Studio 2015/2017中获得相同的功能? 编写TypeScript代码时,即时反馈可以节省生命.
我想在.js文件和.ts文件中使用相同的样式.我知道tslint.json中有jsRules属性,但我看到它有2个问题:
任何其他方式具有相同的代码样式而不必同时维护eslint和tslint?
我想配置 Organize Imports 的订单。
现在,它将与 node_modules 相关的导入语句移动到最顶部,并将本地ts
文件移动到最底部:
普通的:
import myFunction from './myFunction';
import fs from 'fs';
console.log(fs)
console.log(myFunction)
Run Code Online (Sandbox Code Playgroud)
运行 Organize Imports 命令后:
import fs from 'fs';
import myFunction from './myFunction';
console.log(fs)
console.log(myFunction)
Run Code Online (Sandbox Code Playgroud)
我想要做的是颠倒顺序,我希望 node_modules 非常底部,本地导入非常顶部。
我怎样才能实现这种行为?
我尝试执行以下操作以node_modules
从tslint
. 但他们都没有解决这个问题。
如果是因为我调用node_modules
文件夹的方式,我很困惑。
第一次尝试- 在tsconfig.json
和中添加了以下内容tsconfig-aot.json
"exclude": [
"../node_modules/**/*",
"./node_modules/**/*",
"node_modules",
"node_modules/**/*.ts",
"**/node_modules/**/*",
"**/node_modules/**"
]
Run Code Online (Sandbox Code Playgroud)
第二次尝试- 添加exclude
到每个项目部分.angular-cli.json
"lint": [{
"project": "../../../tsconfig.json",
"exclude": "./node_modules/*" // also tried **/node_modules/**/*
},
{
"project": "../../../tsconfig-aot.json",
"exclude": "./node_modules/*"
}
],
Run Code Online (Sandbox Code Playgroud)
第三次尝试-tslint-cli
使用--exclude
选项执行
tslint --exclude node_modules --project tsconfig-aot.json
tslint --exclude node_modules --project tsconfig.json
Run Code Online (Sandbox Code Playgroud)
还是没有变化。每当我这样做时yarn webpack:build
,我仍然会从 node_modules 收到这些警告。
同样在tsconfig.json
and 中tsconfig-aot.json
,它已经有"skipLibCheck": true
更新
我安装了 …
我最近得到了一个旧的 .ts 文件并想更新它。
两个警告说:
'namespace' and 'module' are disallowed
和
The internal 'module' syntax is deprecated, use the 'namespace' keyword instead.
我阅读了有关使用标准化 ES6 样式外部模块的信息,但我不知道如何执行此操作。
我的代码如下所示:
export namespace MySpace
{
export module MyModule
{
export interface MyInterface
{
}
export class MyClass
{
}
...
}
}
Run Code Online (Sandbox Code Playgroud)
谁能给我一个提示,如何将此结构更新为实际的样式规则?
非常感谢大家!
此致
地铁
tslint ×10
typescript ×5
angular ×4
eslint ×2
angular-cli ×1
import ×1
javascript ×1
module ×1
namespaces ×1
node.js ×1
observable ×1
rxjs ×1
webstorm ×1