Skip to content

Commit

Permalink
fix: avoid CJS interop issue
Browse files Browse the repository at this point in the history
Some compilers transpile `import plugin from "package";` into `var plugin = require("package");`,
not `var plugin = require("package").default;`.
(Maybe this is a bug of the compiler.)

Currently `export default plugin;` is transpiled to `module.exports.default = plugin;`,
but this does not work for the above case.
It will work if `export default plugin;` is transpiled to `module.export = plugin;`,
but in this case `var plugin = require("package").default;` will not work.

Adding `export { rules, configs };` will allow the both cases to work,
without breaking compatibility.
  • Loading branch information
susisu committed Jun 20, 2024
1 parent 91fff00 commit ac0bdfc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ const plugin = {
} satisfies ESLint.Plugin;

export default plugin;
export { rules, configs };

0 comments on commit ac0bdfc

Please sign in to comment.