![](/img/trans.png)
[英]Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated
[英]How to resolve @typescript-eslint/no-var-requires error. Error while adding @axe-core/react
我已通過以下方式將axe-core/react添加到我的項目中:
npm install --save-dev @axe-core/react
現在,我在index.tsx中添加了以下代碼以啟動並運行它:
if (process.env.NODE_ENV !== 'production') {
const axe = require('@axe-core/react');
axe(React, ReactDOM, 1000);
}
現在,如果我導航到 localhost,頁面會顯示編譯錯誤,並顯示以下消息:
src\index.tsx
Line 14:17: Require statement not part of import statement @typescript-eslint/no-var-requires
此錯誤發生在以下行:
const axe = require('@axe-core/react');
否則如何導入?
PS:我嘗試做類似的事情:
import foo = require("foo")
但仍然沒有運氣。
更換線路
const axe = require('@axe-core/react');
和
import axe from '@axe-core/react';
解決了我的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.