Rule: max-line-length
Requires lines to be under a certain max length.
Rationale
Limiting the length of a line of code improves code readability. It also makes comparing code side-by-side easier and improves compatibility with various editors, IDEs, and diff viewers.
Config
It can take one argument, which can be any of the following:
- integer indicating maximum length of lines.
- object with keys:
limit- number greater than 0 defining the max line lengthignore-pattern- string defining ignore pattern for this rule, being parsed bynew RegExp(). For example://pattern will ignore all in-line comments.^importpattern will ignore all import statements.^export {(.*?)}pattern will ignore all multiple export statements.class [a-zA-Z]+ implementspattern will ignore all class declarations implementing interfaces.^import |^export {(.*?)}|class [a-zA-Z]+ implements |//pattern will ignore all the cases listed above.
check-strings- determines if strings should be checked,falseby default.check-regex- determines if regular expressions should be checked,falseby default.
Config examples
"max-line-length": [true, 120]
"max-line-length": [
true,
{
"limit": 120,
"ignore-pattern": "^import |^export {(.*?)}",
"check-strings": true,
"check-regex": true
}
]
Schema
{
"type": "array",
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"limit": {
"type": "number"
},
"ignore-pattern": {
"type": "string"
},
"check-strings": {
"type": "boolean"
},
"check-regex": {
"type": "boolean"
}
},
"additionalProperties": false
}
]
},
"minLength": 1,
"maxLength": 2
}