close

no-import-module-exports

Unreleased

Configuration

rslint.config.ts
import { defineConfig, importPlugin } from '@rslint/core';

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/no-import-module-exports': 'error',
    },
  },
]);

Disallow static import declarations in files that also use CommonJS exports. Mixing the two module systems can produce behavior that differs between Node.js, bundlers, and transpilers.

Examples of incorrect code for this rule:

import { value } from './value.js';
module.exports = value;

import value from './value.js';
exports.value = value;

Examples of correct code for this rule:

import value from './value.js';
export default value;

const value = require('./value.js');
module.exports = value;

The package entry point selected by package.json is exempt. This supports packages whose entry point imports internal ES modules and then exposes a CommonJS export. The rule does not provide automatic fixes or suggestions.

Options

exceptions

exceptions is an array of minimatch glob patterns matched against the file's absolute path. A matching file is not checked:

{
  "import/no-import-module-exports": [
    "error",
    { "exceptions": ["**/*/some-file.js"] }
  ]
}

Original Documentation