Skip to content

Allow require() but forbid module.exports #548

Closed

Description

I'm porting a codebase to ES6. In some cases we explicitly want to use require(), because import must be at the top of the file.

For example, we sometimes write:

if (process.env.NODE_ENV == "production") {
  require('../foo.css');
}

or in tests we sometimes want to only require things at certain points. We also conditionally require polyfills.

Could we add a configuration option to allow require() inside no-commonjs? Alternatively, would it make sense to split the rule into no-commonjs-require and no-commonjs-exports?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions