"object-property-newline" rule: add option to allow shorthand properties on the same line
See original GitHub issueWhat rule do you want to change?
Does this change cause the rule to produce more or fewer warnings?
Fewer
How will the change be implemented? (New option, new default behavior, etc.)?
A new allowAllShorthandPropertiesOnSameLine
option:
allowAllShorthandPropertiesOnSameLine: true
allows all the shorthand properties to be on the same line.allowAllShorthandPropertiesOnSameLine: false
(default) disallows shorthand properties to be on the same line.
[Currently the only possible option is allowAllPropertiesOnSameLine
]
Please provide some example code that this change will affect:
const object = {
shortHandProperty1, shortHandProperty2, property3: "value3", property4: "value4"
};
What does the rule currently do for this code?
With ["error"]
, expects:
const object = {
shortHandProperty1,
shortHandProperty2,
property3: "value3",
property4: "value4"
};
What will the rule do after it’s changed?
With ["error", {allowAllShorthandPropertiesOnSameLine: true}]
, also validates:
const object = {
shortHandProperty1, shortHandProperty2,
property3: "value3",
property4: "value4"
};
Are you willing to submit a pull request to implement this change?
Yes
Comment
I haven’t found any style guide that explicitly recommends this, but it seems to be quite a common pattern to me.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
object-property-newline - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Shorthand properties - CSS: Cascading Style Sheets | MDN
Shorthand properties are CSS properties that let you set the values of multiple other CSS properties simultaneously.
Read more >Linter rules for single or multiline object literals - Stack Overflow
I try to set up ESLint rules for both linting and autoformatting of object literal. This snippet should cause linter error: let obj...
Read more >object-property-newline (Rules) - 开发者手册 - Tencent cloud
This rule permits you to restrict the locations of property specifications in object literals. You may prohibit any part of any property ......
Read more >vue/object-property-newline - eslint-plugin-vue
The --fix option on the command line can automatically fix some of the problems reported by this rule. This rule is the same...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What happens if there are a lot of shorthand properties? It seems like you would be forced to do something like this (which I imagine could be viewed as undesirable, particular since it could conflict with
max-len
):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.