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

[feat] prefer shorthand properties #12864

Closed
loynoir opened this issue May 13, 2022 · 1 comment
Closed

[feat] prefer shorthand properties #12864

loynoir opened this issue May 13, 2022 · 1 comment
Labels
scope:out-of-scope Posted issue is not in scope of Prettier

Comments

@loynoir
Copy link

loynoir commented May 13, 2022

Prettier 2.6.2
Playground link

# Options (if any):

Input:

import { xyz as xyz } from 'xyz'
var o = { a: a, b: b, c: c };
export { foo as foo }

Output:

import { xyz as xyz } from 'xyz'
var o = { a: a, b: b, c: c };
export { foo as foo }

Expected behavior:

import { xyz } from 'xyz'
var o = { a, b, c };
export { foo }

Situation

Given

  • { X }

When

  • <F2> twice to rename reference

Becomes

  • { Y: Y } or { Y as Y }.

Why

Would be nice if prettier can make them shorthand again, as short-handify after rename-reference is not part of language server protocol.

Related Doc

https://babeljs.io/docs/en/babel-plugin-transform-shorthand-properties

@thorn0
Copy link
Member

thorn0 commented Aug 23, 2022

Prettier generally doesn't do things like this. See https://prettier.io/docs/en/rationale.html#what-prettier-is-_not_-concerned-about
I'd recommend using ESLint. See https://eslint.org/docs/latest/rules/object-shorthand

@thorn0 thorn0 closed this as completed Aug 23, 2022
@thorn0 thorn0 added the scope:out-of-scope Posted issue is not in scope of Prettier label Aug 23, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope:out-of-scope Posted issue is not in scope of Prettier
Projects
None yet
Development

No branches or pull requests

2 participants