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

What should we do about imports that exceed the 120-char line limit? #139

Closed
pixelzoom opened this issue Mar 26, 2020 · 7 comments
Closed
Assignees

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Mar 26, 2020

What should we do about imports that exceed the 120-char line limit?

Slack developer channel:

Jesse Greenberg 7:44 AM
WebStorm wants to format this import statment like
import EnergySkateParkColorScheme
from '../../../../../energy-skate-park/js/energy-skate-park/common/view/EnergySkateParkColorScheme.js';
Is that right? I thought I disabled all auto wrapping but maybe I am missing a setting somewhere?

Sam Reid 8:31 AM
checking…
8:33
That happened for me too
8:35
I changed the “Settings=>Editor=>Code STyle => Javascript => Wrapping and Braces => Hard Wrap at” from 120 to 999 and the problem went away:
8:35
image

Jesse Greenberg 8:52 AM
Thanks! That fixed it for me too.

Sam Reid 9:27 AM
Perhaps we should check in that change to the code style?

Jesse Greenberg 9:40 AM
Before checking in, I noticed increasing the "Hard wrap at" setting pushed the visual guide (ruler) out that many characters too. I added another visual guide at 120 characters. I don't want to make everyone's visual guides go away.

Michael Kauzmann:octopus: 10:13 AM
Yes I don't think that changing that setting is worth it for just the wrapping import statement.

Chris Malley 10:33 AM
The 120-char line limit has not been a hard limit, up to developer discretion, and I'd hate to change that. I see the limit being applied when I auto-import or Organize imports. I do not see the limit applied when I format code. My vote would be to live with it for imports, since (most) are added by the IDE, and typically collapsed.

Jesse Greenberg 10:35 AM
Cool, I agree with that and it sounds good to me

@zepumph
Copy link
Member

zepumph commented Mar 26, 2020

My vote would be to live with it for imports, since (most) are added by the IDE, and typically collapsed.

I'm not sure what @pixelzoom's opinion is from this. Does "live with it" mean to be okay with having a long import split on two lines?

I personally feel like having the "hard wrap" setting in my IDE, and I would rather not turn it off.

@pixelzoom
Copy link
Contributor Author

Sorry... To clarify, "live with it" means I'm fine with the 120-char line limit being applied to imports "since (most) are added by the IDE, and typically collapsed."

@jonathanolson
Copy link
Contributor

It's tricker to design a lot of automated things (reordering imports, parsing imports for string detection, etc.) around multi-line imports, so some code would need to change. I have a preference to have single-line imports.

@samreid
Copy link
Member

samreid commented Apr 2, 2020

I agree, single lines seem preferable for tooling support.

@chrisklus
Copy link
Contributor

From 4/2/20 dev meeting:

We agree single line seems preferable. @jessegreenberg is going to update phet-code-style.xml to not hard wrap at 120, but still have a visual guide at 120 characters. He's also going to create a lint rule that flags two-line import statements.

jessegreenberg added a commit to phetsims/circuit-construction-kit-black-box-study that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/circuit-construction-kit-dc that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/gene-expression-essentials that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/masses-and-springs-basics that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/gravity-force-lab-basics that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/energy-skate-park-basics that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/density-buoyancy-common that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/resistance-in-a-wire that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/molecules-and-light that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/plinko-probability that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/gravity-force-lab that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/circuit-construction-kit-ac that referenced this issue Apr 3, 2020
jessegreenberg added a commit to phetsims/circuit-construction-kit-ac that referenced this issue Apr 3, 2020
@jessegreenberg
Copy link
Contributor

This is done. A new lint rule "single-line-import" has been added that enforces this, and above commits outside of chipper were made where the lint rule found import statements on multiple lines. Over slack I said

Hello all - the phet-idea-codestyle.xml was changed for #139, so please be aware of the following.

  • If you use WebStorm/IntelliJ, please pull phet-info, then re-import phet-idea-codestyle.xml so your IDE conforms to this change.
  • A new lint rule was introduced to keep imports on one line.
  • Commits are being pushed to 19 repos with this formatting change.

Closing.

@pixelzoom
Copy link
Contributor Author

pixelzoom commented Apr 3, 2020

A note about the above commit, for posterity...

I was curious about what specifically changed, so looked at 5e263c1. The entire file had changed! @samreid pointed out that it was a formatting issue. (The formatting of the code-style file is wrong. Oh, the irony.). So I reformatted the file, confirmed that only 2 lines had really changed, and pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants