import-js/eslint-plugin-import

Rule proposal: no-rename-default

オープン

#1,041 opened on 2018/03/12

 (27 件のコメント) (36 件のリアクション) (0 人の担当者)JavaScript (1,549 件のフォーク)batch import
acceptedhelp wantedrule proposal

Repository metrics

Stars
 (5,940 個のスター)
PR merge metrics
 (平均マージ 138d 22h) (30d で 3 merged PRs)

説明

Consider the following:

components/foo.js:

export default class Foo extends React.Component {
    render() {
        // ...
    }
}

widgets/foo.js:

import FooComponent from '../components/foo';

export default class Foo extends BaseWidget {
    constructor() {
        super(FooComponent);
    }

    // ...
}

Foo (in components/foo.js) and FooComponent are exactly the same thing, but have been renamed via default import/export. When one thing has two or more names, it increases the difficulty of comprehending code, especially when there are many functions, classes, etc. that are renamed on import.

The proposal is to have a rule that generates a warning or error when a default import is given a different name than a default export.

コントリビューターガイド