-
Notifications
You must be signed in to change notification settings - Fork 23
Description
As I have been making contributions, I try to match the surrounding code style, but sometimes add semicolons, or get the single-quote/double-quote different.
Prettier would make it easy to enforce a single code style for everyone.
There are currently 423 single-quotes and 870 double-quotes in the source files.
Likewise, there are 428 semicolons, but mostly in multi-statement lines like these:
closeOk.setUint8(j, 1); j += 1 // type: method
closeOk.setUint16(j, channelId); j += 2 // channel
closeOk.setUint32(j, 4); j += 4 // frameSize
The biggest change is that Prettier will force the statements above onto separate lines.
Considering the above, these are the options that could be used:
{
"semi": false,
"singleQuote": false // default is `false`
}
With "semi": false
, that runs into a potential linting issue because Prettier is trying to prevent a potential ASI failure with changes like this:
case "S":
;[v, len] = this.getLongString(i, littleEndian)
i += len
break
ESLint will complain about unnecessary semicolons (but can be disabled with eslint-config-prettier
)... Maybe semicolons are fine after all?
Alternatively ESLint could be used to enforce a coding style, starting with the semi and quotes rules. The full list of rules that would need to be configured is extensive.
Using linters for formatting is not really recommended, including by ESLint.