![](/img/trans.png)
[英]JSX not allowed in files with extension ' .js' with eslint-config-airbnb
[英]“fetch” is undefined and “localStorage” is undefined , on using eslint-config-airbnb in react.js
我想使用airbnb的eslint修改我的代碼結構。 我已按照eslint-config-airbnb中給出的這些說明進行了操作 。 在啟動命令npm run lint
,結果'fetch' is not defined
為'fetch' is not defined
'localStorage' is not defined
。
我已經解決了這個github問題 ,但是仍然顯示錯誤,因為相同的'fetch is not defined'
。 有什么解決方案嗎?
您可以使用globals
配置.eslintrc
文件。
將此添加到您的.eslintrc
文件。
"globals": {
"localStorage": true,
"fetch": true
}
無需將其添加為例外,只需將其添加到您的.eslintrc
, eslint
就會知道它是什么:
"env": {
"browser": true
}
您可以嘗試通過window
對象訪問fetch
和localStorage
。
window.fetch
, window.localStorage
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.