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

Fix: Clarify line breaks in object-curly-newline (fixes #14024) #14063

Merged
merged 3 commits into from Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/rules/object-curly-newline.md
@@ -1,17 +1,17 @@
# enforce consistent line breaks inside braces (object-curly-newline)
# enforce consistent line breaks after opening and before closing braces (object-curly-newline)
Copy link
Member

Choose a reason for hiding this comment

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

Looks good!

Can we make the same change ("inside braces" -> "after opening and before closing braces") here, in descriptions of string options "never" and "always":

  • "always" requires line breaks after opening and before closing braces
  • "never" disallows line breaks after opening and before closing braces

Also, can we update meta description to be the same as the new title: "enforce consistent line breaks after opening and before closing braces".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now this is similar to https://eslint.org/docs/rules/array-bracket-newline.
I think both of them should be written the same way.
I can change this one and make another PR for array-bracket-newline. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the delay. Yes, sounds like a good plan!


A number of style guides require or disallow line breaks inside of object braces and other tokens.

## Rule Details

This rule enforces consistent line breaks inside braces of object literals or destructuring assignments.
This rule requires or disallows a line break between `{` and its following token, and between `}` and its preceding token of object literals or destructuring assignments.

## Options

This rule has either a string option:

* `"always"` requires line breaks inside braces
* `"never"` disallows line breaks inside braces
* `"always"` requires line breaks after opening and before closing braces
* `"never"` disallows line breaks after opening and before closing braces

Or an object option:

Expand Down Expand Up @@ -538,7 +538,7 @@ export { foo as f, bar } from 'foo-bar';

## When Not To Use It

If you don't want to enforce consistent line breaks inside braces, then it's safe to disable this rule.
If you don't want to enforce consistent line breaks after opening and before closing braces, then it's safe to disable this rule.

## Related Rules

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/object-curly-newline.js
Expand Up @@ -134,7 +134,7 @@ module.exports = {
type: "layout",

docs: {
description: "enforce consistent line breaks inside braces",
description: "enforce consistent line breaks after opening and before closing braces",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/object-curly-newline"
Expand Down