Our code has bee a bit of a maintenance nightmare due to previous developers being liberal with single letter variables and little documentation. The latter we could deal with if the variables names were meaningful and self-descriptive. For this reason we are trying to set up eslint to avoid this going forward.
Our requirements:
- minimum of two characters, since
id
would be an acceptable variable - allow
i
andj
, since they are monly used in 'for' loops as indexes - allow single letter properties on json, to allow
point = { x: 2, y: 2 }
So far the best we have e up with is:
"id-length": [2, { "exceptions": ["i", "j"] }]
This covers points 1 and 2, but fails for point 3. Quoting single letter json attributes does not work for us to the quote-props
rule being present and that we would rather keep.
Can anyone suggest an eslint configuration that would allow to support all three requirements?
Our code has bee a bit of a maintenance nightmare due to previous developers being liberal with single letter variables and little documentation. The latter we could deal with if the variables names were meaningful and self-descriptive. For this reason we are trying to set up eslint to avoid this going forward.
Our requirements:
- minimum of two characters, since
id
would be an acceptable variable - allow
i
andj
, since they are monly used in 'for' loops as indexes - allow single letter properties on json, to allow
point = { x: 2, y: 2 }
So far the best we have e up with is:
"id-length": [2, { "exceptions": ["i", "j"] }]
This covers points 1 and 2, but fails for point 3. Quoting single letter json attributes does not work for us to the quote-props
rule being present and that we would rather keep.
Can anyone suggest an eslint configuration that would allow to support all three requirements?
Share Improve this question asked Aug 25, 2020 at 20:02 Andre MAndre M 7,5989 gold badges64 silver badges107 bronze badges1 Answer
Reset to default 8ESLint allows the rule to not be applied on object properties with "properties": never
. It's not enabled by default, so you have to specify it deliberately.
"rules": {
"id-length": [ 2, { "exceptions": ["i", "j"], "properties": "never" }]
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745186816a4615675.html
评论列表(0条)