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?
There are no core rules that can do this, but the following plugin rule might be what you are looking for:
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
It will report any usage of CommonJS-style modules:
Invalid:
/*eslint no-commonjs: "error"*/
module.exports = foo;
Valid:
/*eslint no-commonjs: "error"*/
export default foo;