Skip to content

Commit

Permalink
feat: add "inherit" to comma and singleLine options
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Aug 24, 2024
1 parent ae8a30a commit 5b58e9c
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 340 deletions.
3 changes: 2 additions & 1 deletion docs/src/config/comma.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ Possible option values:
- `"never"`: Do not insert commas inside a list of items. All existed commas will be removed.
- `"noTrailing"`: Insert commas inside a list of items without trailing comma.
- `"onlySingleLine"`: Insert commas inside a list of items only for single line list. For multiple lines list, there won't be commas.
- `"inherit"`: Inherit from the base `comma` option.

Default option value is `"onlySingleLine"`.

This global option can be overridden by different syntax nodes.
Some syntax-node-specific options will override by default:
Some syntax-node-specific options will override by default instead of `"inherit"`:

- `arguments.comma`
- `argumentsDefinition.comma`
Expand Down
3 changes: 2 additions & 1 deletion docs/src/config/single-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ Possible option values:
- `"prefer"`: Place items on single line as possible.
- `"smart"`: Whether items should be placed on single line will be determined by original layout.
- `"never"`: Force items to be on multiple lines.
- `"inherit"`: Inherit from the base `singleLine` option.

Default option value is `"smart"`.

This global option can be overridden by different syntax nodes.
Some syntax-node-specific options will override by default:
Some syntax-node-specific options will override by default instead of `"inherit"`:

- `arguments.singleLine`
- `argumentsDefinition.singleLine`
Expand Down
42 changes: 24 additions & 18 deletions dprint_plugin/deployment/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"definitions": {
"comma": {
"description": "Control whether commas should be inserted inside a list of items.",
"type": ["string", "null"],
"type": "string",
"oneOf": [
{
"const": "always",
Expand All @@ -24,12 +24,16 @@
{
"const": "onlySingleLine",
"description": "Insert commas inside a list of items only for single line list. For multiple lines list, there won't be commas."
},
{
"const": "inherit",
"description": "Inherit from the base `comma` option."
}
]
},
"singleLine": {
"description": "Control whether items should be placed on single line as possible, even they're originally on multiple lines, or force them to be on multiple lines.",
"type": ["string", "null"],
"type": "string",
"oneOf": [
{
"const": "prefer",
Expand All @@ -42,6 +46,10 @@
{
"const": "never",
"description": "Force items to be on multiple lines."
},
{
"const": "inherit",
"description": "Inherit from the base `singleLine` option."
}
]
},
Expand Down Expand Up @@ -82,16 +90,15 @@
},
"comma": {
"$ref": "#/definitions/comma",
"type": "string",
"default": "onlySingleLine"
},
"arguments.comma": {
"$ref": "#/definitions/comma",
"default": null
"default": "inherit"
},
"argumentsDefinition.comma": {
"$ref": "#/definitions/comma",
"default": null
"default": "inherit"
},
"directives.comma": {
"$ref": "#/definitions/comma",
Expand All @@ -111,11 +118,11 @@
},
"listValue.comma": {
"$ref": "#/definitions/comma",
"default": null
"default": "inherit"
},
"objectValue.comma": {
"$ref": "#/definitions/comma",
"default": null
"default": "inherit"
},
"schemaDefinition.comma": {
"$ref": "#/definitions/comma",
Expand All @@ -131,28 +138,27 @@
},
"variableDefinitions.comma": {
"$ref": "#/definitions/comma",
"default": null
"default": "inherit"
},
"singleLine": {
"$ref": "#/definitions/singleLine",
"type": "string",
"default": "smart"
},
"arguments.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"argumentsDefinition.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"directiveLocations.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"directives.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"enumValuesDefinition.singleLine": {
"$ref": "#/definitions/singleLine",
Expand All @@ -164,19 +170,19 @@
},
"implementsInterfaces.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"inputFieldsDefinition.singleLine": {
"$ref": "#/definitions/singleLine",
"default": "never"
},
"listValue.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"objectValue.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"schemaDefinition.singleLine": {
"$ref": "#/definitions/singleLine",
Expand All @@ -192,11 +198,11 @@
},
"unionMemberTypes.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"variableDefinitions.singleLine": {
"$ref": "#/definitions/singleLine",
"default": null
"default": "inherit"
},
"parenSpacing": {
"$ref": "#/definitions/parenSpacing",
Expand Down
Loading

0 comments on commit 5b58e9c

Please sign in to comment.