Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 2 additions & 5 deletions packages/eslint-plugin/src/util/collectUnusedVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,7 @@ function isMergableExported(variable: TSESLint.Scope.Variable): boolean {
* @returns True if the variable is exported, false if not.
*/
function isExported(variable: TSESLint.Scope.Variable): boolean {
const definition = variable.defs[0];

if (definition) {
return variable.defs.some(definition => {
let node = definition.node;

if (node.type === AST_NODE_TYPES.VariableDeclarator) {
Expand All @@ -438,8 +436,7 @@ function isExported(variable: TSESLint.Scope.Variable): boolean {
}

return node.parent!.type.indexOf('Export') === 0;
}
return false;
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,18 @@ export class Foo {
typescript: '4.4',
},
},
`
interface Foo {
bar: string;
}
export const Foo = 'bar';
`,
`
export const Foo = 'bar';
interface Foo {
bar: string;
}
`,
],

invalid: [
Expand Down Expand Up @@ -1805,5 +1817,25 @@ x = foo(x);
},
],
},
{
code: `
interface Foo {
bar: string;
}
const Foo = 'bar';
`,
errors: [
{
messageId: 'unusedVar',
line: 5,
column: 7,
data: {
varName: 'Foo',
action: 'assigned a value',
additional: '',
},
},
],
},
],
});