[英]How to disable eslint check on development mode in reactjs
我已成功配置 eslint 以在 reactjs 項目中為每個提交(預提交鈎子)運行。 將 git commit 命令發送到終端后,它運行正常。
這是我的package.json
"scripts": {
......
"lint": "eslint src --ext .tsx .",
"lint:fix": "eslint src --ext .tsx --fix",
"precommit": "lint-staged",
"prepare": "husky install",
"format": "prettier --write \"src/**/*.tsx\"",
......
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.(ts|tsx)": [
"prettier --write .",
"eslint src --ext .tsx --fix .",
"git add ."
]
},
但是我不希望 eslint 在開發模式下檢查規則(通過運行npm run start
)。
例如,我將no-console
規則設置為error
以防止用戶在其中使用console.log
提交代碼,但是當我嘗試在開發模式下使用console.log
在console.log
中顯示日志時,它會通過 lint 拋出錯誤查看
我該如何配置它?
謝謝大家
我自己從這里找到了解決方案 Edit .env:
DISABLE_ESLINT_PLUGIN=true
或者在 package.json 中:
{
"scripts": {
"start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
"test": "DISABLE_ESLINT_PLUGIN=true react-scripts test"
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.