Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim-Mazurok committed Apr 9, 2023
1 parent f0f83ce commit 36195e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
23 changes: 12 additions & 11 deletions packages/eslint-plugin/src/util/collectUnusedVariables.ts
Expand Up @@ -423,20 +423,21 @@ 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];
const exportedDefinition = variable.defs.find(definition => {
if (definition) {
let node = definition.node;

if (definition) {
let node = definition.node;
if (node.type === AST_NODE_TYPES.VariableDeclarator) {
node = node.parent!;
} else if (definition.type === TSESLint.Scope.DefinitionType.Parameter) {
return false;
}

if (node.type === AST_NODE_TYPES.VariableDeclarator) {
node = node.parent!;
} else if (definition.type === TSESLint.Scope.DefinitionType.Parameter) {
return false;
return node.parent!.type.indexOf('Export') === 0;
}

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

/**
Expand Down
Expand Up @@ -1072,6 +1072,12 @@ export class Foo {
typescript: '4.4',
},
},
`
interface Foo {
bar: string;
}
export const Foo = 'bar';
`,
],

invalid: [
Expand Down

0 comments on commit 36195e6

Please sign in to comment.