[英]TSLint not working in VS Code
I added TSLint to my React/TypeScript project using the tslint VSCode extension.我使用 tslint VSCode 扩展将 TSLint 添加到我的 React/TypeScript 项目中。 I also installed both typescript and tslint globally according to TSLint docs
npm install -g tslint typescript
我还根据 TSLint docs
npm install -g tslint typescript
typescript 全局安装了 typescript 和 tslint
This is my tslint.json file:这是我的 tslint.json 文件:
{
"extends": ["tslint:latest", "tslint-react"],
"rules": {
// override tslint-react rules here
"jsx-wrap-multiline": false,
"max-line-length": false,
"no-implicit-dependencies": [true, "dev"],
"no-var-requires": false,
"indent": false
}
}
tslint-react
is a tslint extension which has to be installed separately: npm install -g tslint-react
. tslint-react
是一个 tslint 扩展,必须单独安装: npm install -g tslint-react
。 After installing, reload your VS Code window, and linting should work.安装后,重新加载 VS Code 窗口,linting 应该可以工作了。
How I found the problem: I copied your config file into a project, went to View > Output to check for errors from the tslint process, and saw this.我是如何发现问题的:我将您的配置文件复制到一个项目中,转到“查看”>“输出”以检查 tslint 进程中的错误,并看到了这一点。 (be sure to select tslint from the dropdown near the top right)
(一定要从靠近右上角的下拉菜单中选择 tslint)
Include the dependency in the package.json在 package.json 中包含依赖项
This is package.json and its working for me.这是 package.json 并且它对我有用。
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "~5.11.0",
"firebase-functions": "^1.0.0"
},
"devDependencies": {
"tslint": "^5.8.0",
"typescript": "^2.5.3"
},
"private": true
}
在 package.json "lint": "tslint --project tslint.json"
添加以下内容"lint": "tslint --project tslint.json"
为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.