我似乎无法覆盖"no-use-before-define"
的行为。我不想在定义函数之前使用过任何警告。我曾尝试在VS Code中禁用和重新启用ESLint服务,但没有成功。
.eslintrc
{
"env": {
"browser": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"airbnb",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react",
"prettier/standard",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"rules": {
"no-use-before-define": ["error", { "functions": false, "classes": true }]
}
}
.prettierrc.js
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
endOfLine: 'auto',
}
答案 0 :(得分:1)
安装多个节点模块后,我可以在一个小的.tsx文件上使用您的配置。看来解决方案只是:而不是
"no-use-before-define": ["error", { "functions": false, "classes": true }]
似乎您需要使用
"@typescript-eslint/no-use-before-define": ["error", { "functions": false, "classes": true }]
因为错误来自@typescript-eslint
。
答案 1 :(得分:0)
如果全部丢失,则可以使用以下命令为一行指定规则。
/*eslint-disable */
//It will disable all the warnings between comments
alert('eslint disabled');
//To enable just add the below line of code.
/*eslint-enable */