From 63875c80b6e332ceed56c296d9399b0dc0f9106e Mon Sep 17 00:00:00 2001 From: Harshit Nagila Date: Sun, 4 Oct 2026 13:59:14 +0530 Subject: [PATCH] docs(lint): document no-commonjs rule --- lint/rules/no-commonjs.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lint/rules/no-commonjs.md diff --git a/lint/rules/no-commonjs.md b/lint/rules/no-commonjs.md new file mode 100644 index 000000000..e05dffe6b --- /dev/null +++ b/lint/rules/no-commonjs.md @@ -0,0 +1,28 @@ +--- +tags: [] +--- + +Disallows CommonJS export assignments through `exports` and `module.exports`. + +Use ECMAScript module exports instead. For a named export, declare or export the +binding with `export`; for a default export, use `export default`. + +**Invalid:** + +```typescript +exports.answer = 42; +module.exports = function answer() { + return 42; +}; +module.exports.answer = 42; +``` + +**Valid:** + +```typescript +export const answer = 42; + +export default function answer() { + return 42; +} +```