admin管理员组文章数量:1246585
I was wondering if an ESLint rule exists, or how to make one, that does the following:
Allows exports only in the form export default foo
and not in the form module.exports = foo
Is there a way to do this?
I was wondering if an ESLint rule exists, or how to make one, that does the following:
Allows exports only in the form export default foo
and not in the form module.exports = foo
Is there a way to do this?
Share Improve this question asked Sep 4, 2016 at 14:12 Code WhispererCode Whisperer 23.7k22 gold badges71 silver badges88 bronze badges2 Answers
Reset to default 8There are no core rules that can do this, but the following plugin rule might be what you are looking for:
https://github./benmosher/eslint-plugin-import/blob/master/docs/rules/no-monjs.md
It will report any usage of CommonJS-style modules:
Invalid:
/*eslint no-monjs: "error"*/
module.exports = foo;
Valid:
/*eslint no-monjs: "error"*/
export default foo;
module.exports is specific to Node. so add it to the env, like below
env: {
browser: true,
node: true,
es2021: true,
},
本文标签: javascriptESLintPrefer Export Default to ModuleExportsStack Overflow
版权声明:本文标题:javascript - ESLint - Prefer Export Default to Module.Exports - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740236369a2246477.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论