问题描述
我正在尝试按照在线教程设置 tslint 以处理一个小型示例 React/Typescript 项目.当我运行 yarn lint
或只是在终端中输入 tslint --project
时,我不断收到错误
I'm trying to set up tslint to work on a small sample React/Typescript project, following a tutorial online. When I either run yarn lint
or simply enter tslint --project
in the terminal, I keep getting the error
项目的无效选项:true
我在谷歌上搜索了很多,但找不到我做错了什么.
I've done a lot of googling, and I can't find what I'm doing wrong.
我的 tslint.json
是
{
"extends": [
"tslint:recommended",
"tslint-react",
"tslint-config-prettier"
],
"rules": {
"ordered-imports": false,
"object-literal-sort-keys": false,
"no-console": false,
"jsx-no-lambda": false,
"member-ordering": false
}
}
我的package.json
是
{
"name": "something",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "parcel ./src/index.html",
"lint": "tslint --project",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"babel-preset-react": "^7.0.0-beta.3",
"parcel-bundler": "^1.12.3",
"prettier": "^1.18.2",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.0.0"
},
"dependencies": {
"@babel/core": "^7.0.0",
"@emotion/babel-preset-css-prop": "^10.0.14",
"@emotion/core": "^10.0.16",
"@emotion/styled": "^10.0.15",
"axios": "^0.19.0",
"babel": "^6.23.0",
"bulma": "^0.7.5",
"node-sass": "^4.12.0",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"typescript": "^3.5.3"
}
}
可能是我在从原始 eslint
版本转换它时弄乱了 package.json
,但此时我迷路了.非常感谢任何帮助.
It may be I've messed up the package.json
in converting this from the original eslint
version, but I am lost at this point. Any help much appreciated.
推荐答案
诀窍是需要指定 (ts) linting 的目录.因此,如果您位于项目的根目录中,
The trick is that one needs to specify the directory where one is (ts)linting. Thus if you're in the root of your project,
tslint --project '.'
成功了.
这篇关于什么产生“项目无效选项:真"?在 React 项目上运行“tslint --project"时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!