What is producing “Invalid option for project: true” when running 'tslint --project' on a React project?

烈酒焚心 提交于 2021-02-09 09:19:29

问题


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

Invalid option for project: true

I've done a lot of googling, and I can't find what I'm doing wrong.

My tslint.json is

{
  "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
  }
}

and my package.jsonis

{
  "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"
  }
}

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.


回答1:


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 '.'

does the trick.



来源:https://stackoverflow.com/questions/57680471/what-is-producing-invalid-option-for-project-true-when-running-tslint-proj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!