-
Notifications
You must be signed in to change notification settings - Fork 885
max-line-length with template literals #3905
Comments
@ashwinr @ajafff @adidahiya @jkillian How would you design the options schema for this while remaining backward compatible? |
@ashwinr @ajafff @adidahiya @jkillian Sorry to bump this again, but I'd like to get a PR in. Unless I'm missing something, I've been unable to find a case where the options can be either a number or an object. |
@joelday The "max-line-length": [true, 120]
"max-line-length": [true, {"limit": 120, "ignore-pattern": "^import |^export {(.*?)}"}] So you should be able to add a new property to the object and it will remain backward compatible. Something like this: {
"type": "array",
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"limit": {
"type": "number"
},
"ignore-pattern": {
"type": "string"
},
"ignore-multiline-template-literals": {
"type": "boolean"
}
},
"additionalProperties": false
}
]
},
"minLength": 1,
"maxLength": 2
} |
@joelday @reduckted This rule has some problems, I found mainly 2: template literals and Regex. In both cases it is hard or not recommendable to cut these long strings. Then a property like Could also be possible add support for regex? |
The option should probably ignore all strings, whether they're single-line, multi-line or template strings. |
For now, for a single line template literals, it is possible to use |
If you intend to implement #3585, I would strongly recommend the sage advice of @reduckted is heeded, and that such an option should be enabled by default for all strings. Strings could contain absolutely anything. A linter has no business expressing opinions on them, and a fixer certainly hasn't got any business whatsoever touching them because it can't possibly understand the rules that govern "the set of all possible strings". |
Hi, I had the same issue in some projects I was participating in and here is the solution I came up with. |
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
Expected behavior
This rule should skip verification for "some" strings, including multiline template literal.
The text was updated successfully, but these errors were encountered: