Skip to content

stringQuoteType

SPGoding edited this page Apr 26, 2020 · 1 revision

Rule Details

⚠️ Diagnostic: this is a diagnostic rule used by the diagnostic feature.

🔧 Fixable: violations of this rule can be fixed by Code Actions.

Enforce the type of string argument quotation marks.

  • ("always single"): always uses single quotation marks (').
  • ("always double"): always uses double quotation marks (").
  • ("prefer single"): always uses single quotation marks (') unless there are single quotation marks in the string.
  • ("prefer double"): always uses double quotation marks (") unless there are double quotation marks in the string.

Examples

Default

{
    "stringQuoteType": ["warning", "prefer double"]
}

👍 Good

datapack enable "file/xxx.zip"
datapack enable "file/xxx'ooo.zip"
datapack enable 'file/xxx"ooo.zip'

👎 Bad

datapack enable 'file/xxx.zip'
datapack enable 'file/xxx\'ooo.zip'
datapack enable "file/xxx\"ooo.zip"

Always Double

{
    "stringQuoteType": ["warning", "always double"]
}

👍 Good

datapack enable "file/xxx.zip"
datapack enable "file/xxx'ooo.zip"
datapack enable "file/xxx\"ooo.zip"

👎 Bad

datapack enable 'file/xxx.zip'
datapack enable 'file/xxx\'ooo.zip'
datapack enable 'file/xxx"ooo.zip'

Disabled

{
    "stringQuoteType": null
}

👍 Good

datapack enable "file/xxx.zip"
datapack enable 'file/xxx.zip'
datapack enable "file/xxx'ooo.zip"
datapack enable 'file/xxx\'ooo.zip'
datapack enable "file/xxx\"ooo.zip"
datapack enable 'file/xxx"ooo.zip'

History

This rule was introduced in DHP 2.0.0.

Clone this wiki locally