简体   繁体   English

带有 Babel plugin-proposal-export-default-from 的 ESLint

[英]ESLint with Babel plugin-proposal-export-default-from

I just added this babel plugin in order to make use of that export aDefault from 'a/module' .我刚刚添加了这个babel 插件,以便使用export aDefault from 'a/module'

Works well as I can import such an export from other files but eslint isn't sparing me.效果很好,因为我可以从其他文件导入这样的导出,但 eslint 并没有放过我。 It highlights my export statement ruthlessly.它无情地突出了我的出口声明。

Do we have an eslint plugin for that, or how should I go about it?我们是否有一个 eslint 插件,或者我应该怎么做? My .eslintrc.yaml currently extends standard .我的.eslintrc.yaml目前扩展了standard .

Well, I have exhausted my options;好吧,我已经用尽了我的选择; including having babel-eslint as the parser in the eslintrc.json file.包括将babel-eslint作为eslintrc.json文件中的解析器。

In case anyone lands here with a similar issue, I decided to adapt the standard specification, with some aliasing, and forget about the babel syntax;如果有人遇到类似的问题,我决定调整标准规范,使用一些别名,并忘记 babel 语法;

// index.js

export { default as PreferredName, aNamedExport } from 'a/module';
export { default as AnotherPreferredName, anotherNamedExport } from 'another/module';

// or export all the named exports from another/module.js
export * from 'another/module'; // this won't export the default. It will also throw an error if anotherNamedExport has already been exported from another/module.js as above

.eslintrc .eslintrc

"comma-dangle": [
  "error", 
  { 
    "exports": "never",
    "imports": "never"
  }
]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有 Babel 的 ESLint:在 .eslintrc 中未找到声明的 plugin-proposal-class-properties - ESLint with Babel: plugin-proposal-class-properties not found declared in .eslintrc React Native 报错:导出命名空间应该先由`@babel/plugin-proposal-export-namespace-from 转换 - React Native error: Export namespace should be first transformed by `@babel/plugin-proposal-export-namespace-from Babel插件 - 提议装饰器未按预期工作 - Babel plugin-proposal-decorators not working as expected 错误:找不到模块“@babel/plugin-proposal-class-properties” - Error: Cannot find module '@babel/plugin-proposal-class-properties' @ babel / plugin-proposal-class-properties不起作用 - @babel/plugin-proposal-class-properties doesn't work 使用 Firebase 在 CodeSandbox 上找不到/安装 babel 插件“proposal-decorators” - Could not find/install babel plugin 'proposal-decorators' on CodeSandbox with Firebase 如何在Codesandbox中使用Babel插件提案抛出表达式? - How to use Babel Plugin Proposal Throw Expressions in Codesandbox? 如何使用 vite 启用“@babel/plugin-proposal-decorators” - How do i enable "@babel/plugin-proposal-decorators" with vite 错误:无法从“/home/dolphin/sync/source/cruise-web”找到模块“@babel/plugin-proposal-decorators” - Error: Cannot find module '@babel/plugin-proposal-decorators' from '/home/dolphin/sync/source/cruise-web' 使用eslint-plugin-compat和Babel一起使用 - Use eslint-plugin-compat alongside Babel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM