Motivation
Our code style is:
For single-line object notation:
/**
* @typedef {{ a: boolean, b: string, c: number }} Example
*/
For multi-line object notation:
/**
* @typedef {{
* a: boolean,
* b: string,
* c: number,
* }} Example
*/
We use:
{
// ...
rules: {
"jsdoc/type-formatting": [
"error",
{
objectTypeBracketSpacing: " ",
objectFieldSeparator: "comma-and-linebreak",
},
],
},
}
We don't want a trailing comma for single-line object notation, but want it for multi-line.
Set the objectFieldSeparatorTrailingPunctuation to true will always add , (comma) to single-line and multi-line object notations, separatorForSingleObjectField is not fit for our purpose, because some object notations can be written in single-line with multiple properties.
We align our jsdocs like prettier formats objects.
Why some objects are using single-line and other are using multi-line? It all depends on how many properties are in the object and how much line length they occupy. If the object is longer than 80 characters, we write it in several lines.
Idea - objectFieldSeparatorTrailingPunctuation: boolean | "multi-line-only"
Current behavior
No ability to configure
Desired behavior
Ability to configure
Alternatives considered
No alternatives
Motivation
Our code style is:
For single-line object notation:
For multi-line object notation:
We use:
We don't want a trailing comma for single-line object notation, but want it for multi-line.
Set the
objectFieldSeparatorTrailingPunctuationtotruewill always add,(comma) to single-line and multi-line object notations,separatorForSingleObjectFieldis not fit for our purpose, because some object notations can be written in single-line with multiple properties.We align our jsdocs like prettier formats objects.
Why some objects are using single-line and other are using multi-line? It all depends on how many properties are in the object and how much line length they occupy. If the object is longer than 80 characters, we write it in several lines.
Idea -
objectFieldSeparatorTrailingPunctuation: boolean | "multi-line-only"Current behavior
No ability to configure
Desired behavior
Ability to configure
Alternatives considered
No alternatives