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
Update: Check indentation for multi-line chained properties (refs #1801) #5940
Conversation
LGTM |
Thank you for your pull request. It looks like this may be your first contribution to a jQuery Foundation project, if so we need you to sign our Contributor License Agreement (CLA). 📝 Please visit http://contribute.jquery.org/CLA/ to sign. After you signed, the PR is checked again automatically after a minute. If there's still an issue, please reply here to let us know. If you've already signed our CLA, it's possible your git author information doesn't match your CLA signature (both your name and email have to match), for more information, check the status of your CLA check. |
I've signed the CLA and the information provided appears to match my git author information. Not sure if there's something up with the automatic CLA checker thingy or if I'm just Doing It Wrong somehow... |
There's going to definitely be people that will prefer this: var a = foo.bar()
.baz()
.bip()
.bap(); ...instead of: var a = foo.bar()
.baz()
.bip()
.bap(); It may be possible to write a rule smart enough to distinguish between that and other cases where it may make sense to indent-by-two rather than align, but I suspect there will be many edge cases. Indentation of Maybe I'm overthinking it? |
(Rebased against master, conflicts resolved, force pushed.) |
Looks like the Travis failure was a bitbucket issue? |
@Trott Thanks a lot. I think implementation looks good. CC: @BYK
|
21fe90b
to
8017738
Compare
@gyandeeps Thanks! I think I've addressed each of your requests at this point. One question: Should there be a setting to disable the indentation check on chained properties and/or a setting to ignore the indentation but to guarantee alignment? The idea is to enable people using the
|
I actually have some concerns:
_.map(something, somethingElse)
.filter(lalala) |
If you can set it to |
@Trott - disagree. This is clearly related to indentation. Aligning from the left-most side is always indent-related. |
@BYK @gyandeeps what's the next step here? |
I haven't changed my position and @Trott seems to be fed up with my insistence :D |
@BYK Nah, not fed up. Just fell of my radar... |
LGTM |
Rebased against master, resolved the resulting conflict in the documentation file, force pushed. |
LGTM |
|
This seems like a very confusing incremental step towards that. If that's your goal, then I think we should start with a new issue describing all the changes you want to make. I don't like the idea of using this task as a backdoor for significant changes to this rule. |
@nzakas so is your preference to make this like the others and then file a separate ticket to make a transition for all (in a backwards-compatible manner)? If so I can live with that. |
@BYK yup, exactly. |
Alright, removing my reservations about how the option is coded for this PR then. I'll file a new ticket once this is completed. |
@BYK so is this ready to merge? |
|
||
var dot = context.getTokenBefore(node.property); | ||
|
||
if (dot.type === "Punctuator" && dot.value === ".") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic here is a bit confusing to me. Why are we checking the dot additionally? Here's what I think:
- If the dot is on the previous line, we only need to check the
MemberExpression
node
. - If the dot is on the same line with
MemberExpression
, then we only need to check the dot's indentation.
Am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everywhere else, the checking for whether the node is the first item on the line is delegated to the check*
functions, so I was following that pattern. They all just send everything to check*()
and let that function figure out if it's the first thing on the line and needs to be checked or not.
Your suggested logic would work just fine too. If that would be less confusing, I can do that instead.
Sorry for the late review. I have a few concerns around how the |
@BYK I've responded to the concerns/questions you raised inline. Do those responses satisfy your concerns? If not, I'm happy to keep working at this... |
LGTM |
@kaicataldo Merge conflict resolved. @kaicataldo @BYK Let me know if there's anything I can do to get this un-stalled. |
@Trott Thanks! @eslint/eslint-team Friendly ping to make sure this doesn't get lost |
@Trott can you rebase? |
😭 So close!
I can't wait to enforce
GL @Trott I'm cheering for you over here. |
…nt#1801) The end user can choose whether and how much to indent.
LGTM |
LGTM. I think the open questions are minor ones, so it seems like we can go with this and then see what feedback we get. Thanks @Trott for sticking with this, I know it's been a long journey and we really appreciate your patience. |
I don't fully understand the technicalities of semver, but adding this made our lint fail. And I can't fix it by simply setting MemberExpression to a different default because I sometimes indent these lines and sometimes don't. (Well I could fix it with inline rules, but that's a nasty hack.) This should've been a new rule, or delayed to sermver major. 👎 |
@curiousdannii Please read our README for information on our semver policy. The short version is, we will sometimes release CI-breaking changes under semver-minor if they are new features for a rule (with opt-in configuration) or if they are bugfixes that will result in more errors being reported. We may have erred in this case, but I want to make sure it is understood that CI-breaking changes are not considered semver-major in all cases here. If you want to avoid CI breaks, you can always use tilde ranges in your dependency configuration. If you have questions/concerns, please stop by our Gitter chat. Thanks! |
@platinumazure I did think that that would probably be the case. But there should still be a way to disable the MemberExpression check. |
Absolutely. We do have an issue and multiple proposed PRs available, so On Jul 29, 2016 3:58 PM, "Dannii Willis" notifications@github.com wrote:
|
The end user can choose whether and how much to indent.
vs.
and so forth...