diff --git a/packages/eslint-plugin/tests/rules/ban-tslint-comment.test.ts b/packages/eslint-plugin/tests/rules/ban-tslint-comment.test.ts index 70ebf3d6f107..227d4f3ab3d8 100644 --- a/packages/eslint-plugin/tests/rules/ban-tslint-comment.test.ts +++ b/packages/eslint-plugin/tests/rules/ban-tslint-comment.test.ts @@ -2,50 +2,6 @@ import { RuleTester } from '@typescript-eslint/rule-tester'; import rule from '../../src/rules/ban-tslint-comment'; -interface Testable { - code: string; - column?: number; - line?: number; - output?: string; - text?: string; -} - -const PALANTIR_EXAMPLES: Testable[] = [ - { code: '/* tslint:disable */' }, // Disable all rules for the rest of the file - { code: '/* tslint:enable */' }, // Enable all rules for the rest of the file - { - code: '/* tslint:disable:rule1 rule2 rule3... */', - }, // Disable the listed rules for the rest of the file - { - code: '/* tslint:enable:rule1 rule2 rule3... */', - }, // Enable the listed rules for the rest of the file - { code: '// tslint:disable-next-line' }, // Disables all rules for the following line - { - code: 'someCode(); // tslint:disable-line', - column: 13, - output: 'someCode();', - text: '// tslint:disable-line', - }, // Disables all rules for the current line - { - code: '// tslint:disable-next-line:rule1 rule2 rule3...', - }, // Disables the listed rules for the next line -]; - -// prettier-ignore -const MORE_EXAMPLES: Testable[] = [ - { - code: `const woah = doSomeStuff(); -// tslint:disable-line -console.log(woah); -`, - line: 2, - output: `const woah = doSomeStuff(); -console.log(woah); -`, - text: '// tslint:disable-line', - }, -] - const ruleTester = new RuleTester(); ruleTester.run('ban-tslint-comment', rule, { @@ -66,18 +22,123 @@ ruleTester.run('ban-tslint-comment', rule, { code: '/* another comment that mentions tslint */', }, ], - invalid: [...PALANTIR_EXAMPLES, ...MORE_EXAMPLES].map( - ({ code, column, line, output, text }) => ({ - code, + invalid: [ + { + code: '/* tslint:disable */', + errors: [ + { + column: 1, + data: { + text: '/* tslint:disable */', + }, + line: 1, + messageId: 'commentDetected', + }, + ], + output: '', + }, + { + code: '/* tslint:enable */', + errors: [ + { + column: 1, + data: { + text: '/* tslint:enable */', + }, + line: 1, + messageId: 'commentDetected', + }, + ], + output: '', + }, + { + code: '/* tslint:disable:rule1 rule2 rule3... */', + errors: [ + { + column: 1, + data: { + text: '/* tslint:disable:rule1 rule2 rule3... */', + }, + line: 1, + messageId: 'commentDetected', + }, + ], + output: '', + }, + { + code: '/* tslint:enable:rule1 rule2 rule3... */', + errors: [ + { + column: 1, + data: { + text: '/* tslint:enable:rule1 rule2 rule3... */', + }, + line: 1, + messageId: 'commentDetected', + }, + ], + output: '', + }, + { + code: '// tslint:disable-next-line', + errors: [ + { + column: 1, + data: { + text: '// tslint:disable-next-line', + }, + line: 1, + messageId: 'commentDetected', + }, + ], + output: '', + }, + { + code: 'someCode(); // tslint:disable-line', errors: [ { - column: column ?? 1, - data: { text: text ?? code }, - line: line ?? 1, - messageId: 'commentDetected' as const, + column: 13, + data: { + text: '// tslint:disable-line', + }, + line: 1, + messageId: 'commentDetected', }, ], - output: output ?? '', - }), - ), + output: 'someCode();', + }, + { + code: '// tslint:disable-next-line:rule1 rule2 rule3...', + errors: [ + { + column: 1, + data: { text: '// tslint:disable-next-line:rule1 rule2 rule3...' }, + line: 1, + messageId: 'commentDetected', + }, + ], + output: '', + }, + { + code: ` +const woah = doSomeStuff(); +// tslint:disable-line +console.log(woah); + `, + errors: [ + { + column: 1, + data: { + text: '// tslint:disable-line', + }, + line: 3, + messageId: 'commentDetected', + }, + ], + output: ` +const woah = doSomeStuff(); +console.log(woah); + `, + }, + ], }); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy