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: add object-curly-newline rule #83

Merged
merged 6 commits into from Nov 11, 2023
Merged

Conversation

Talent30
Copy link
Contributor

@Talent30 Talent30 commented Nov 4, 2023

index.js Outdated
},
ObjectPattern: {
multiline: true,
minProperties: 4,
Copy link
Member

Choose a reason for hiding this comment

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

What's the reasoning?

Copy link
Contributor Author

@Talent30 Talent30 Nov 6, 2023

Choose a reason for hiding this comment

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

Thank you for asking! Upon reflection, I believe this might not be a good idea.

let {
g, h
} = obj;

The above format isn't very good IMO.

I am leaning towards to set this option as never now until the community enhance the object-property-newline rule or add destructuring-property-newline.

Happy to hear your thoughts :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we add object-property-newline as well we can achieve the following result

Incorrect

let a = {foo: 1
};
let b = {
    foo: 1};
let c = {foo: 1, bar: 2
};

Object.assign(stream, {isTTY: true, columns, rows});

Correct

Object.assign(stream, {
    isTTY: true,
    columns,
    rows
});


let a = {foo: 1};
let b = {foo: 1};
let c = {
    foo: 1,
    bar: 2
};

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@Talent30
Copy link
Contributor Author

Thank you very much for your feedback

@sindresorhus sindresorhus merged commit 3a5448b into xojs:main Nov 11, 2023
3 checks passed
@voxpelli
Copy link

For future reference, this doesn't seem to fully work as desired yet, as it now (as noted above) auto-fixes { foo, bar } into:

{
  foo, bar
}

See eg: sindresorhus/type-fest#838 (review)

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

Successfully merging this pull request may close these issues.

Add object-curly-newline rule
3 participants