Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(eslint-plugin): switch auto-generated test cases to hand-written in ban-tslint-comment.test.ts#11328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Vinccool96 wants to merge1 commit intotypescript-eslint:main
base:main
Choose a base branch
Loading
fromVinccool96:chore/11047-ban-tslint-comment-handwritten
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 115 additions & 54 deletionspackages/eslint-plugin/tests/rules/ban-tslint-comment.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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, {
Expand All@@ -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);
`,
},
],
});

[8]ページ先頭

©2009-2025 Movatter.jp