Skip to content

stylus/hash-object-property-comma

require or disallow commas in hash object properties.

  • ⚙️ This rule is included in "stylelint-stylus/standard". (options: ["always",{"trailing":"never"}])
  • 🔧 The fix option can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule require or disallow commas in hash object properties.

🔧 Options

json
{
  "stylus/hash-object-property-comma": ["always" | "never",
    {
      "trailing": "always" | "never"
    }
  ]
}
  • Primary Option

    • "always" ... Requires comma.
    • "never" ... Disallows comma.
  • Secondary Option (optional)

    • "trailing" ... Defines the style apply to the trailing comma.

"always"

styl
/* stylelint rules config: {"stylus/hash-object-property-comma": "always"} */
// ✓ GOOD
foo = {
  bar: baz,
  baz: raz,
}
foo = { bar: baz, baz: raz, }

// ✗ BAD
foo = {
  bar: baz
baz: raz
} foo = { bar: baz, baz: raz
}

"never"

styl
/* stylelint rules config: {"stylus/hash-object-property-comma": "never"} */
// ✓ GOOD
foo = {
  bar: baz
  baz: raz
}
foo = { bar: baz, baz: raz }

// ✗ BAD
foo = {
  bar: baz
,
baz: raz } foo = { bar: baz, baz: raz
,
}

[ "always", { "trailing": "never" } ]

styl
/* stylelint rules config: {"stylus/hash-object-property-comma": ["always", { "trailing": "never" }]} */
// ✓ GOOD
foo = {
  bar: baz,
  baz: raz
}
foo = { bar: baz, baz: raz }

// ✗ BAD
foo = {
  bar: baz
baz: raz } foo = { bar: baz, baz: raz
,
} foo = { bar: baz, baz: raz
,
}

📚 Further reading

🔍 Implementation