eslint-plugin-sonarjs
eslint-plugin-sonarjs copied to clipboard
sonarjs/cognitive-complexity strange typings
That type (number | 'metric' | 'sonar-runtime')[]
does not seem to be correct if you look at the schema, which is:
[
{ type: 'integer', minimum: 0 },
{ enum: ['sonar-runtime', 'metric'] }
]
If you compile this schema, you will get [number, 'sonar-runtime' | 'metric']
, and you may want to have them optional so you could omit them.
Now, if your typings are used, this is valid from the typescript (types) perspective:
{
// 'error' from combining your typings with eslint Linter.RuleEntry
'sonarjs/cognitive-complexity': ['error', 5, 'metric', 'metric', 5, 'metric', 'metric', 'sonar-runtime', 'sonar-runtime', 5, 9]
}
Of course, that does not break create
method in any way because of this way of extracting the options. Anyways, it is odd. I was compiling schemas of rules for different ESLint plugins and found this inconsistency between types.
Thank you for the information, we will try to fix this in our next sprint.
This issue has been migrated to Jira. ESLINTJS-33