Skip to content

Support sourceType: commonjs #519

@nzakas

Description

@nzakas

For flat config, we have introduced the concept of sourceType: commonjs to make it easier to deal with CommonJS files.

In order to make this work, ESLint will have to switch sourceType to script and then enable ecmaFeatures.globalReturn. This is an exception case, as sourceType is passed as-is to every parser except for Espree.

To remove this exception case, I'd like to implement sourceType: commonjs in Espree, which would effectively be another way of specifying ecmaFeatures.globalReturn with one exception: the sourceType property of Program nodes would be set to commonjs instead of script.

This would not be a breaking change because everything else behaves the same as it does right now. The only difference in behavior would be when sourceType:commonjs is passed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions