import-js/eslint-plugin-import

Rule proposal: no-rename-default

開放

#1,041 建立於 2018年3月12日

 (27 則留言) (36 個反應) (0 位負責人)JavaScript (1,549 個分叉)batch import
acceptedhelp wantedrule proposal

倉庫指標

星標
 (5,940 顆星)
PR 合併指標
 (平均合併 138天 22小時) (30 天內合併 3 個 PR)

描述

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.

貢獻者指南