eslint-plugin-sonarjs icon indicating copy to clipboard operation
eslint-plugin-sonarjs copied to clipboard

sonarjs/cognitive-complexity strange typings

Open datismoa opened this issue 1 year ago • 1 comments

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.

datismoa avatar Jan 22 '24 01:01 datismoa

Thank you for the information, we will try to fix this in our next sprint.

ilia-kebets-sonarsource avatar Jan 24 '24 16:01 ilia-kebets-sonarsource

This issue has been migrated to Jira. ESLINTJS-33

Wohops avatar Apr 29 '24 08:04 Wohops