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

docs: Add example with object pattern to computed-property-spacing #14004

Closed

Conversation

whizzzkid
Copy link

@whizzzkid whizzzkid commented Jan 12, 2021

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

  • Documentation update
  • Bug fix (template)
  • New rule (template)
  • Changes an existing rule (template)
  • Add autofixing to a rule
  • Add a CLI option
  • Add something to the core
  • Other, please explain:

What changes did you make? (Give an overview)

I faced #14002 and added an example and wording to help others find it.

Is there anything you'd like reviewers to focus on?

the wording and the right place.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jan 12, 2021
@eslint-deprecated
Copy link

Hi @whizzzkid!, thanks for the Pull Request

The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag must be one of the following:

    The Tag is one of the following:

    • Fix - for a bug fix.
    • Update - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
    • New - implements a new feature.
    • Breaking - for a backwards-incompatible enhancement or feature.
    • Docs - changes to documentation only.
    • Build - changes to build process only.
    • Upgrade - for a dependency upgrade.
    • Chore - for anything that isn't user-facing (for example, refactoring, adding tests, etc.).

    You can use the labels of the issue you are working on to determine the best tag.

  • There should be a space following the initial tag and colon, for example 'New: Message'.

  • The first letter of the tag should be in uppercase

Read more about contributing to ESLint here

@whizzzkid whizzzkid force-pushed the fix/docs-computed-property-spacing branch from bc190dc to 79e3bca Compare January 12, 2021 22:15
Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, documenting the destructuring case is helpful! I left an inline suggestion to fix a syntax error in the example, but this'll be good to go once that's fixed.

@@ -14,6 +14,9 @@ var a = "prop";
var obj = {
[a]: "value" // computed property key in object literal (ECMAScript 6)
};

// applies to the spacing for dynamic keys (computed property key) when destructuring objects.
const ({ [a]: someProp } = obj); // someProp now maps to the value of prop.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parentheses are invalid syntax here:

Suggested change
const ({ [a]: someProp } = obj); // someProp now maps to the value of prop.
const { [a]: someProp } = obj; // someProp now maps to the value of prop.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I think I did not read this right, that syntax looks wrong, that works, when assigning to a delcared variable:

let someProp;
({ [a]: someProp } = obj);

but if we are declaring a new variable:

const { [a]: someProp } = obj;

this is mentioned in this section: Assignment without declaration

@eslint-deprecated
Copy link

Hi @whizzzkid!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag must be one of the following:

    The Tag is one of the following:

    • Fix - for a bug fix.
    • Update - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
    • New - implements a new feature.
    • Breaking - for a backwards-incompatible enhancement or feature.
    • Docs - changes to documentation only.
    • Build - changes to build process only.
    • Upgrade - for a dependency upgrade.
    • Chore - for anything that isn't user-facing (for example, refactoring, adding tests, etc.).

    You can use the labels of the issue you are working on to determine the best tag.

  • There should be a space following the initial tag and colon, for example 'New: Message'.

Read more about contributing to ESLint here

@whizzzkid whizzzkid force-pushed the fix/docs-computed-property-spacing branch from d0f1a75 to 79e3bca Compare January 15, 2021 06:16
@mdjermanovic mdjermanovic added documentation Relates to ESLint's documentation evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jan 15, 2021
@mdjermanovic
Copy link
Member

I marked this as 'evaluating' for now since there's an issue related to this change #12048 and it isn't accepted yet.

I think it's most likely that we will accept this documentation update, at least for the computed-property-spacing rule, but we should also add some test cases to confirm this behavior. It can be a separate PR.

@mdjermanovic mdjermanovic changed the title Adding example and explaination for rule: computed-property-spacing docs: Add example with object pattern to computed-property-spacing Oct 26, 2021
@eslint-github-bot
Copy link

Hi @whizzzkid!, thanks for the Pull Request

The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.
  • The first letter of the tag should be in lowercase

Read more about contributing to ESLint here

@mdjermanovic mdjermanovic added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Dec 14, 2021
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whizzzkid sorry for the delay, this PR is now accepted.

const ({ [a]: someProp } = obj); is invalid syntax, If you are still interested in finishing this, I left a suggestion to fix the syntax and align the example with other examples.

Comment on lines +17 to +19

// applies to the spacing for dynamic keys (computed property key) when destructuring objects.
const ({ [a]: someProp } = obj); // someProp now maps to the value of prop.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// applies to the spacing for dynamic keys (computed property key) when destructuring objects.
const ({ [a]: someProp } = obj); // someProp now maps to the value of prop.
var { [a]: x } = obj; // computed property key in object destructuring pattern (ECMAScript 6)

@linux-foundation-easycla
Copy link

CLA Not Signed

@eslint-github-bot
Copy link

Hi @whizzzkid!, thanks for the Pull Request

The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.
  • The first letter of the tag should be in lowercase

To Fix: You can fix this problem by running git commit --amend, editing your commit message, and then running git push -f to update this pull request.

Read more about contributing to ESLint here

@mdjermanovic
Copy link
Member

Closing due to age.

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Sep 2, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants