Skip to content

Commit d9e5da1

Browse files
authored
fix(eslint-plugin): [no-deprecated] report when exported class implements/extends deprecated entity (typescript-eslint#10259)
1 parent 1e633c7 commit d9e5da1

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

packages/eslint-plugin/src/rules/no-deprecated.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default createRule({
134134

135135
case AST_NODE_TYPES.ArrowFunctionExpression:
136136
case AST_NODE_TYPES.BlockStatement:
137-
case AST_NODE_TYPES.ClassBody:
137+
case AST_NODE_TYPES.ClassDeclaration:
138138
case AST_NODE_TYPES.TSInterfaceDeclaration:
139139
case AST_NODE_TYPES.FunctionDeclaration:
140140
case AST_NODE_TYPES.FunctionExpression:

packages/eslint-plugin/tests/rules/no-deprecated.test.ts

+93
Original file line numberDiff line numberDiff line change
@@ -2370,5 +2370,98 @@ ruleTester.run('no-deprecated', rule, {
23702370
},
23712371
},
23722372
},
2373+
{
2374+
code: `
2375+
/** @deprecated */
2376+
interface Foo {}
2377+
2378+
class Bar implements Foo {}
2379+
`,
2380+
errors: [
2381+
{
2382+
column: 30,
2383+
data: { name: 'Foo' },
2384+
endColumn: 33,
2385+
endLine: 5,
2386+
line: 5,
2387+
messageId: 'deprecated',
2388+
},
2389+
],
2390+
},
2391+
{
2392+
code: `
2393+
/** @deprecated */
2394+
interface Foo {}
2395+
2396+
export class Bar implements Foo {}
2397+
`,
2398+
errors: [
2399+
{
2400+
column: 37,
2401+
data: { name: 'Foo' },
2402+
endColumn: 40,
2403+
endLine: 5,
2404+
line: 5,
2405+
messageId: 'deprecated',
2406+
},
2407+
],
2408+
},
2409+
{
2410+
code: `
2411+
/** @deprecated */
2412+
interface Foo {}
2413+
2414+
interface Baz {}
2415+
2416+
export class Bar implements Baz, Foo {}
2417+
`,
2418+
errors: [
2419+
{
2420+
column: 42,
2421+
data: { name: 'Foo' },
2422+
endColumn: 45,
2423+
endLine: 7,
2424+
line: 7,
2425+
messageId: 'deprecated',
2426+
},
2427+
],
2428+
},
2429+
{
2430+
code: `
2431+
/** @deprecated */
2432+
class Foo {}
2433+
2434+
export class Bar extends Foo {}
2435+
`,
2436+
errors: [
2437+
{
2438+
column: 34,
2439+
data: { name: 'Foo' },
2440+
endColumn: 37,
2441+
endLine: 5,
2442+
line: 5,
2443+
messageId: 'deprecated',
2444+
},
2445+
],
2446+
},
2447+
{
2448+
code: `
2449+
/** @deprecated */
2450+
declare function decorator(constructor: Function);
2451+
2452+
@decorator
2453+
export class Foo {}
2454+
`,
2455+
errors: [
2456+
{
2457+
column: 10,
2458+
data: { name: 'decorator' },
2459+
endColumn: 19,
2460+
endLine: 5,
2461+
line: 5,
2462+
messageId: 'deprecated',
2463+
},
2464+
],
2465+
},
23732466
],
23742467
});

0 commit comments

Comments
 (0)