Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule to enforce default import naming #1143

Open
wants to merge 1 commit into
base: master
from

Conversation

@mic4ael
Copy link

mic4ael commented Jul 24, 2018

This rule enforces a specific naming for default imports.

Fixes #1041.
Closes indico/indico#3329

@coveralls

This comment has been minimized.

Copy link

coveralls commented Jul 24, 2018

Coverage Status

Coverage increased (+0.08%) to 96.593% when pulling 56d9aaf on mic4ael:rename-default-import into 112a0bf on benmosher:master.

@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 9ea1200 to 072305c Jul 24, 2018
Copy link
Collaborator

ljharb left a comment

This isn't quite what was discussed in #1041.

docs/rules/rename-default-import.md Outdated Show resolved Hide resolved
docs/rules/rename-default-import.md Outdated Show resolved Hide resolved
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch 2 times, most recently from af337e7 to db0623e Jul 24, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Jul 24, 2018

Updated ;)

@ljharb ljharb changed the title Add rule to enforce default import aliases Add rule to enforce default import naming Jul 24, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Jul 30, 2018

So I guess it is not gonna be accepted unless I make it conform to the propositions listed in the linked issue?

@ThiefMaster

This comment has been minimized.

Copy link

ThiefMaster commented Aug 3, 2018

How is this related to #1041? That issue seems to be about enforcing the same name a library uses to export its default with (e.g. export default function foo() {}) while this one is simply about enforcing a name chosen by whoever configures eslint.

@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from db0623e to a138319 Aug 10, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Aug 30, 2018

Any update on this?

docs/rules/rename-default-import.md Outdated Show resolved Hide resolved
docs/rules/rename-default-import.md Outdated Show resolved Hide resolved
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from a138319 to 2b5dde9 Sep 3, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Sep 19, 2018

Any update on this one?

docs/rules/rename-default-import.md Outdated Show resolved Hide resolved
docs/rules/rename-default-import.md Outdated Show resolved Hide resolved
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 2b5dde9 to 11361eb Sep 24, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Sep 24, 2018

Updated. Let me know what you think.

tests/src/rules/rename-default-import.js Outdated Show resolved Hide resolved
tests/src/rules/rename-default-import.js Show resolved Hide resolved
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch 2 times, most recently from f0f7cef to 7f2fcef Sep 26, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Sep 28, 2018

Let me know what you think now

@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Oct 4, 2018

Any update on this? ;)

@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 7f2fcef to 73969b6 Oct 15, 2018
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch 2 times, most recently from 62c11b4 to 0da6220 Oct 16, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Oct 16, 2018

Updated once again.

Copy link
Collaborator

ljharb left a comment

What happens with import * as Something from 'prop-types'?

docs/rules/rename-default-import.md Show resolved Hide resolved
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
src/rules/rename-default-import.js Show resolved Hide resolved
src/rules/rename-default-import.js Outdated Show resolved Hide resolved
@ljharb ljharb added the semver-minor label Oct 19, 2018
@ljharb ljharb requested review from benmosher and jfmengels Oct 19, 2018
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch 2 times, most recently from cc09571 to 9d13214 Oct 26, 2018
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 9d13214 to 90b311a Nov 28, 2018
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Jan 7, 2019

Hey, what is the state of this PR at the moment?

@ljharb

This comment has been minimized.

Copy link
Collaborator

ljharb commented Jan 7, 2019

It's awaiting review from a second collaborator.

@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 90b311a to e96d5fa Feb 7, 2019
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Feb 7, 2019

Maybe there is another collaborator that we could ask for a review?

@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from e96d5fa to d0bcc54 Mar 7, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from d0bcc54 to 48d2286 Apr 10, 2019
@mic4ael

This comment has been minimized.

Copy link
Author

mic4ael commented Apr 10, 2019

Hm, just a casual reminder that this PR is still awaiting a review ;)

@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 48d2286 to fc3eba0 Apr 17, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from fc3eba0 to b00a204 Apr 25, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from b00a204 to 7eebed9 May 14, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 7eebed9 to 47f0ebd May 27, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 47f0ebd to 10c9964 Jun 5, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 10c9964 to d2150ff Jun 18, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from d2150ff to ee943bb Jul 2, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from ee943bb to d1fc6f0 Jul 19, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from d1fc6f0 to 9715080 Sep 2, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 9715080 to 47de844 Sep 18, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 47de844 to 68a276f Oct 21, 2019
@mic4ael mic4ael force-pushed the mic4ael:rename-default-import branch from 68a276f to 56d9aaf Oct 21, 2019
@@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]
- Add [`rename-default-import`] rule: Enforce default import naming

This comment has been minimized.

Copy link
@ljharb

ljharb Jan 7, 2020

Collaborator
Suggested change
- Add [`rename-default-import`] rule: Enforce default import naming
- Add [`rename-default-import`] rule: Enforce default import naming ([#1143], thanks [@mic4ael])

and the appropriate links for the PR and your username

test({
code: `import {default as propTypes, foo} from 'prop-types';`,
options: [{'prop-types': 'PropTypes'}],
output: `import {default as PropTypes, foo} from 'prop-types';`,

This comment has been minimized.

Copy link
@ljharb

ljharb Jan 7, 2020

Collaborator

i'm a little concerned with making this autofixable, if you won't be updating all the other places ijn the file where this variable is referenced (and it might not be safe to update it, if it's used in something like const obj = { PropTypes };).

"rules": {
"import/rename-default-import": [
"warn", {
"prop-types": "PropTypes", // key: name of the module, value: desired binding for default import

This comment has been minimized.

Copy link
@ljharb

ljharb Jan 7, 2020

Collaborator

what validates that the RHS of this object is a valid JS identifier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.