hatch-surf/node_modules/eslint-plugin-import/docs/rules/no-import-module-exports.md
Riley Zhang df378d33ef
Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Merge GitHub main into Gitea repo (allow unrelated histories)
Resolved conflicts by taking GitHub versions for:
- .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml

Kept deploy.sh updated to:
- Pull from GitHub (primary source)
- Push to Gitea (push-mirror)
- Build from site/ directory (GitHub structure)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-25 05:20:46 +02:00

1.7 KiB

import/no-import-module-exports

🔧 This rule is automatically fixable by the --fix CLI option.

Reports the use of import declarations with CommonJS exports in any module except for the main module.

If you have multiple entry points or are using js:next this rule includes an exceptions option which you can use to exclude those files from the rule.

Options

exceptions

  • An array of globs. The rule will be omitted from any file that matches a glob in the options array. For example, the following setting will omit the rule in the some-file.js file.
"import/no-import-module-exports": ["error", {
    "exceptions": ["**/*/some-file.js"]
}]

Rule Details

Fail

import { stuff } from 'starwars'
module.exports = thing

import * as allThings from 'starwars'
exports.bar = thing

import thing from 'other-thing'
exports.foo = bar

import thing from 'starwars'
const baz = module.exports = thing
console.log(baz)

Pass

Given the following package.json:

{
  "main": "lib/index.js",
}
import thing from 'other-thing'
export default thing

const thing = require('thing')
module.exports = thing

const thing = require('thing')
exports.foo = bar

import thing from 'otherthing'
console.log(thing.module.exports)

// in lib/index.js
import foo from 'path';
module.exports = foo;

// in some-file.js
// eslint import/no-import-module-exports: ["error", {"exceptions": ["**/*/some-file.js"]}]
import foo from 'path';
module.exports = foo;

Further Reading