1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +02:00

Fix ESLint config around files w/ CommonJS imports (#14380)

The `parserOptions.sourceType` config option in `.eslintrc.js` is used
to distinguish files that use ESM imports vs. files that do not.
The `import` plugin, specifically the `import/ambiguous` rule behaves
differently depending on this value. If a file is marked with
`sourceType` of `"module"`, then this rule will attempt to ensure that
the file does indeed have ESM imports and/or exports; otherwise it does
nothing.

In other words, files that use CJS imports are *not* "modules" according
to this setting, and therefore should not be marked with a `sourceType`
of `"module"`. This means we do not have to turn off the
`import/ambiguous` rule, as it will no longer trip up on these types of
files.
This commit is contained in:
Elliot Winkler 2022-04-21 12:41:00 -06:00 committed by GitHub
parent 095cc94ed0
commit c25c0432ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,14 +44,6 @@ module.exports = {
path.resolve(__dirname, '.eslintrc.babel.js'),
path.resolve(__dirname, '.eslintrc.typescript-compat.js'),
],
parserOptions: {
sourceType: 'module',
},
rules: {
// This rule does not work with CommonJS modules. We will just have to
// trust that all of the files specified above are indeed modules.
'import/unambiguous': 'off',
},
settings: {
'import/resolver': {
// When determining the location of a `require()` call, use Node's