Closed Lonli-Lokli closed 1 year ago
I want to report a bug.
Reproducer
// minimal reproducer if relevant type Executor = { process: (onMessage: (message: 'old' | 'new') => void) => boolean; }; export const onHandler = (command: 'add' | 'remove', item: any, executor: Executor) => { switch (command) { case 'add': return executor.process((message) => { switch (message) {// False-positive here for no-nested-switch case 'new': return item !== null; break; case 'old': return true; } }) case 'remove': break; } }
Expected behavior
no error as those switches are in different contexts
eslint-plugin-sonarjs version: 0.19.0 eslint version: 8.15.0 Node.js version: v16.19.1
Rule key: no-nested-switch
Hello @Lonli-Lokli,
Technically, you are right that there is indeed a function declaration in between those switches. However, the rule is about readability and therefore we assess this case as a true positive.
I want to report a bug.
Reproducer
Expected behavior
no error as those switches are in different contexts
eslint-plugin-sonarjs version: 0.19.0
eslint version: 8.15.0
Node.js version: v16.19.1
Rule key: no-nested-switch