Skip to content

Commit

Permalink
fix(eslint-plugin): [no-use-before-define] false positive for functio…
Browse files Browse the repository at this point in the history
…n type arguments (#2554)

Fixes #2527
  • Loading branch information
bradzacher committed Sep 13, 2020
1 parent 02d72d4 commit 189162d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/eslint-plugin/src/rules/no-use-before-define.ts
Expand Up @@ -260,7 +260,8 @@ export default util.createRule<Options, MessageIds>({
variable.identifiers.length === 0 ||
(variable.identifiers[0].range[1] <= reference.identifier.range[1] &&
!isInInitializer(variable, reference)) ||
!isForbidden(variable, reference)
!isForbidden(variable, reference) ||
reference.from.type === TSESLint.Scope.ScopeType.functionType
) {
return;
}
Expand Down
Expand Up @@ -343,6 +343,10 @@ const React = require('react');
},
},
},
// https://github.com/typescript-eslint/typescript-eslint/issues/2527
`
type T = (value: unknown) => value is Id;
`,
],
invalid: [
{
Expand Down
2 changes: 2 additions & 0 deletions packages/experimental-utils/src/ts-eslint/Scope.ts
Expand Up @@ -46,9 +46,11 @@ namespace Scope {
export type Reference = scopeManager.Reference;
export type Variable = scopeManager.Variable | ESLintScopeVariable;
export type Scope = scopeManager.Scope;
export const ScopeType = scopeManager.ScopeType;
// TODO - in the next major, clean this up with a breaking change
export type DefinitionType = scopeManager.Definition;
export type Definition = scopeManager.Definition;
export const DefinitionType = scopeManager.DefinitionType;
}

export { Scope };

0 comments on commit 189162d

Please sign in to comment.