Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): [no-use-before-define] false positive for function type arguments #2554

Merged
merged 1 commit into from Sep 13, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 };