Skip to content

[BUG] Your babel configuration has hiccups #158

@stephen-carter-at-sf

Description

@stephen-carter-at-sf

Over at https://github.com/salesforce/eslint-config-lwc/blob/master/lib/defaults.js#L18-L26

You are missing

babelOptions.configFile = false;

which is needed so that a babel config file doesn't get picked up from the user causing havoc.

and

sourceType = undefined;

If you do not specify sourceType explicitely to undefined then ESLint 9 will fill this in by default because it sees the key doesn't exist with "commonJs" for .cjs file which babel doesn't like because of
https://github.com/babel/babel/blob/05f28c8a329d75e47baed1afce5fef33420d6d67/packages/babel-core/src/config/validation/option-assertions.ts#L132

ESLint 9 seems to be trying to set this if the user hasn't... but babel doesn't like with ESLint 9 sets.

An easy example of reproducing this is to just createa. .cjs file and use this configuration and try to run it. You'll get something like:

 ›   Error: eslint [11:19:27]: When scanning file '/Users/stephen.carter/temp/repro.cjs' with the eslint engine, ESLint gave the following error:
 ›       Parsing error: .sourceType must be "module", "script", "unambiguous", or undefined

when using a flat configuration file.

Metadata

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