![](/img/trans.png)
[英]how to configure an angular project tsconfig paths[] without linting errors?
[英]How do I set an Angular project to always emit errors instead of warnings when linting?
整個問題都在標題中:)。 我環顧四周,發現 ESLint 存在一個emitError
設置,但看起來它隱藏在eslint-loader
的 Webpack 配置中,Angular 似乎沒有公開。
我錯過了什么嗎? 或者這個選項無法訪問? 有解決方法嗎?
這可以通過根據ESlint 拋出錯誤而不是警告更改用於觸發 linting 的腳本來完成
示例 eslintrc.js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir : __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
示例 package.json
{
...
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --max-warnings=0"
},
...
}
這里最重要的部分是“lint”命令,它調用 eslint 來 lint src、apps、libs,並在 0 個警告下進行測試。 這意味着所有警告都將被視為錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.