import-js/eslint-plugin-import

Support for named import pattern in import/named

Open

#1583 aperta il 26 dic 2019

Vedi su GitHub
 (4 commenti) (3 reazioni) (0 assegnatari)JavaScript (1540 fork)batch import
bughelp wanted

Metriche repository

Star
 (4946 star)
Metriche merge PR
 (Merge medio 138g 22h) (3 PR mergiate in 30 g)

Descrizione

Given:

// ./foo.js
export const foo = "I'm so foo"

The following Es6 syntax is considered invalid:

// ./bar.js
import { foo as bar } from './foo'

Error:

ESLint: foo not found in './foo'(import/named)

However, the following is considered valid

// ./bar.js
import * as bar from './foo'

is it done intentionally? And if so, do we have an option to disable errors?

My configuration:

{
    "env": {
        "browser": true,
        "jest": true
    },
    "parserOptions": {
        "sourceType": "module",
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "extends": [
        "airbnb",
        "plugin:prettier/recommended"
    ],
    "plugins": [
        "react"
    ],
    "rules": {
        "class-methods-use-this": 0,
        "import/no-named-as-default": 0,
        "react/jsx-filename-extension": [
            "error",
            {
                "extensions": [
                    ".js",
                    ".jsx"
                ]
            }
        ]
    }
}

Eslint version: v6.8.0

Guida contributor