import-js/eslint-plugin-import

Support for named import pattern in import/named

Open

#1,583 建立於 2019年12月26日

在 GitHub 查看
 (4 留言) (3 反應) (0 負責人)JavaScript (4,946 star) (1,540 fork)batch import
bughelp wanted

描述

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

貢獻者指南