在不切换Typescript的情况下,如何修复Import/no-default-Export?

发布于 2025-02-11 19:08:56 字数 538 浏览 0 评论 0原文

我正在尝试将所有选择器放入外部JS文件中,然后在需要时将它们导入到我的页面对象中:

Home-page-selectors.js:
    export default {
      headerLinks: 'header a',
      contactUsLink: "header a[href='/contact-us']",
    }

home-page.js包括从'../test-data/home导入选择器-page-data.js'我可以做cy.get(selectors.headerlinks)之类的事情

问题是当我运行棉绒任务时,我会从homepage-- selectors.js说

错误优先命名导出导入/no-default-export

如何解决此错误?我知道我可以在Typescript中进行多种方法,但是不幸的是,由于我们使用的许多插件不兼容,因此切换到TS并不是一个选择。

I'm trying to put all my selectors in an external JS file and then import them in to my page object when I need them e.g. :

Home-page-selectors.js:
    export default {
      headerLinks: 'header a',
      contactUsLink: "header a[href='/contact-us']",
    }

Home-page.js includes import selectors from '../test-data/home-page-data.js' I can then do things like cy.get(selectors.headerLinks)

The problem is when I run my lint tasks I get an error from Home-page-selectors.js saying

error Prefer named exports import/no-default-export

How can I fix this error? I know multiple ways I can do it in TypeScript but unfortunately switching to TS isn't an option due to a number of plugins we use not being compatible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文