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

key/property rules and ObjectPattern #12048

Open
mdjermanovic opened this issue Aug 1, 2019 · 7 comments
Open

key/property rules and ObjectPattern #12048

mdjermanovic opened this issue Aug 1, 2019 · 7 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@mdjermanovic
Copy link
Member

Tell us about your environment

  • ESLint Version: 6.1.0
  • Node Version: 10.16.0
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 6,
  },
};

What did you do? Please include the actual source code causing the issue.

There are 4 rules that report ObjectPattern properties, it's probably a bug because there are no examples in the documentation and there are no test cases.

/*eslint quote-props: "error"*/
/*eslint key-spacing: "error"*/
/*eslint no-useless-computed-key: "error"*/
/*eslint computed-property-spacing: "error"*/

({
    a : foo,
    ["b" ]: bar
} = baz)

What did you expect to happen?

No warnings.

What actually happened? Please include the actual, raw output from ESLint.

4 warnings, one for each of the rules.

Are you willing to submit a pull request to fix this bug?

Yes, for whatever is decided.

quote-props and key-spacing are not working well at the moment (see PRs #12046 and #12047), I guess these fixes should be applied to skip ObjectPattern for now. A possible enhancements could be to add options later.

no-useless-computed-key and computed-property-spacing might work well already. Possible actions could be:

  • Fix to ignore ObjectPattern.
  • Or, consider this as a default behavior feature (it already is) - just modify the docs and add test cases.
  • Maybe add options instead.
@mdjermanovic mdjermanovic added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Aug 1, 2019
@g-plane g-plane added 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 Aug 3, 2019
@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Sep 3, 2019
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@mysticatea mysticatea reopened this Sep 3, 2019
@kaicataldo kaicataldo removed the auto closed The bot closed this issue label Sep 29, 2019
@kaicataldo
Copy link
Member

I think we'll need to evaluate each of these rules separately. It seems like all these rules should apply to this syntax, but they should probably be individually configurable.

key-spacing, no-useless-computed-key, computed-property-spacing, all seem fine in their default state, I think key-spacing should apply here and the other two don't apply unless someone uses a computed identifier (which apparently is valid syntax - TIL!). quote-props does seem like an outlier - I've never actually seen that out in the wild - but if it's legal, maybe it should also be on by default (with an option to turn it off?)

Example code:

const foo = { a: 'b' };

const { 'a': bar } = foo;
const { ['a']: baz } = foo;

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Oct 30, 2019
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@nzakas
Copy link
Member

nzakas commented Apr 29, 2021

@mdjermanovic what do you want to do with this issue?

@mdjermanovic
Copy link
Member Author

For computed-property-spacing, it makes the most sense to keep the current behavior and just document it (#14004 and #15423). and add tests (#15424).

@nzakas
Copy link
Member

nzakas commented Aug 14, 2023

@mdjermanovic do you want to finish this issue up?

@mdjermanovic
Copy link
Member Author

Yes, I'll check no-useless-computed-key, and then update the documentation and add tests for this rule if the behavior seems fine.

Docs and tests for computed-property-spacing have already been updated (this rule is now deprecated anyway).

quote-props and key-spacing are now deprecated, so no changes there.

@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 Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
Status: Ready to Implement
Development

No branches or pull requests

5 participants