How can I get ESLint to recognize aggregate export namespaces?

Viewed 489

The Situation

I have a NodeJS project that uses Babel and ESLint (6.8).

I'm using the relatively new syntax for aggregate exports (export * as name1 from …;).

The Code

constants.js

export const x = 5
export const y = 6

index.js

export * as constants from './constants'

sandbox.js

import { constants } from './index'
console.log(constants.x)

When I run babel-node sandbox.js everything works just fine, and the value for x (5) is rendered.

.eslintrc

{
  "extends": "airbnb-base",
  "parser": "babel-eslint",
  "env": {
    "es6": true,
    "node": true,
    "jest": true
  }
}

.babelrc

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "node": "13.10"
        }
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-proposal-export-namespace-from"
  ]
}

The Problem

ESLint seems to be confused by my aggregate export, rendering the following error when I lint:

sandbox.js
  1:10  error  constants not found in './index'  import/named

The Question

How do I get ESLint to recognize that the named aggregate does in fact exist? I would like to be able to still benefit from the import/named checks overall.

0 Answers
Related