![](/img/trans.png)
[英]jsLint still giving warning “X was used before it was defined.” even when undef is set
[英]“'React' was used before it was defined.” eslint warning
與StackOverflow上的這篇文章類似的問題,但在嘗試了我在互聯網上可以找到的所有內容后,我似乎無法擺脫此警告。 Github 問題。
Line 1:8: 'React' was used before it was defined @typescript-eslint/no-use-before-define
我嘗試將這些添加到.eslintrc.json
的規則中,但似乎都沒有刪除警告。
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off"
"no-use-before-define": [0],
"@typescript-eslint/no-use-before-define": [1]
這個問題在我的其他項目中不存在。 我試過從其他項目復制package.json
和.eslintrc.json
並重新安裝node_modules
,但它仍然存在。
有沒有人有任何其他建議來解決警告? 提前致謝!
那是因為:
這是很常見的事情,因為 TypeScript 添加了 ESLint 不知道的新功能。 第一步是在這里檢查我們的“擴展”規則列表。 擴展規則只是擴展基本 ESLint 規則以支持 TypeScript 語法的規則。 如果您在那里找到它,請試一試,看看它是否適合您。 您可以通過禁用基本規則並打開擴展規則來配置它。
所以請嘗試在您的.eslintrc.json
編寫該規則:
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
相關鏈接:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.