-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(scope-manager): don't create references for intrinsic JSX elements (
- Loading branch information
1 parent
5afeeab
commit cdb9807
Showing
9 changed files
with
208 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/scope-manager/tests/fixtures/jsx/component-intrinsic-name.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
function div() {} // should not be referenced | ||
<div />; |
58 changes: 58 additions & 0 deletions
58
packages/scope-manager/tests/fixtures/jsx/component-intrinsic-name.tsx.shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`jsx component-intrinsic-name 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2 { | ||
defs: Array [ | ||
FunctionNameDefinition$1 { | ||
name: Identifier<"div">, | ||
node: FunctionDeclaration$1, | ||
}, | ||
], | ||
name: "div", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
Variable$3 { | ||
defs: Array [], | ||
name: "arguments", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$2, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"const" => ImplicitGlobalConstTypeVariable, | ||
"div" => Variable$2, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2, | ||
], | ||
}, | ||
FunctionScope$2 { | ||
block: FunctionDeclaration$1, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"arguments" => Variable$3, | ||
}, | ||
type: "function", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$3, | ||
], | ||
}, | ||
], | ||
} | ||
`; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ixtures/jsx/component-namespaced.tsx.shot → ...xtures/jsx/component-namespaced1.tsx.shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/scope-manager/tests/fixtures/jsx/component-namespaced2.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const x = { | ||
Foo() {}, | ||
}; | ||
const Foo = 1; // should be unreferenced | ||
|
||
<x.Foo />; // lower cased namespaces should still create a reference |
106 changes: 106 additions & 0 deletions
106
packages/scope-manager/tests/fixtures/jsx/component-namespaced2.tsx.shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`jsx component-namespaced2 1`] = ` | ||
ScopeManager { | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2 { | ||
defs: Array [ | ||
VariableDefinition$1 { | ||
name: Identifier<"x">, | ||
node: VariableDeclarator$1, | ||
}, | ||
], | ||
name: "x", | ||
references: Array [ | ||
Reference$1 { | ||
identifier: Identifier<"x">, | ||
init: true, | ||
isRead: false, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: true, | ||
resolved: Variable$2, | ||
writeExpr: ObjectExpression$2, | ||
}, | ||
Reference$3 { | ||
identifier: JSXIdentifier$3, | ||
isRead: true, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: false, | ||
resolved: Variable$2, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
Variable$3 { | ||
defs: Array [], | ||
name: "arguments", | ||
references: Array [], | ||
isValueVariable: true, | ||
isTypeVariable: true, | ||
}, | ||
Variable$4 { | ||
defs: Array [ | ||
VariableDefinition$2 { | ||
name: Identifier<"Foo">, | ||
node: VariableDeclarator$4, | ||
}, | ||
], | ||
name: "Foo", | ||
references: Array [ | ||
Reference$2 { | ||
identifier: Identifier<"Foo">, | ||
init: true, | ||
isRead: false, | ||
isTypeReference: false, | ||
isValueReference: true, | ||
isWrite: true, | ||
resolved: Variable$4, | ||
writeExpr: Literal$5, | ||
}, | ||
], | ||
isValueVariable: true, | ||
isTypeVariable: false, | ||
}, | ||
], | ||
scopes: Array [ | ||
GlobalScope$1 { | ||
block: Program$6, | ||
isStrict: false, | ||
references: Array [ | ||
Reference$1, | ||
Reference$2, | ||
Reference$3, | ||
], | ||
set: Map { | ||
"const" => ImplicitGlobalConstTypeVariable, | ||
"x" => Variable$2, | ||
"Foo" => Variable$4, | ||
}, | ||
type: "global", | ||
upper: null, | ||
variables: Array [ | ||
ImplicitGlobalConstTypeVariable, | ||
Variable$2, | ||
Variable$4, | ||
], | ||
}, | ||
FunctionScope$2 { | ||
block: FunctionExpression$7, | ||
isStrict: false, | ||
references: Array [], | ||
set: Map { | ||
"arguments" => Variable$3, | ||
}, | ||
type: "function", | ||
upper: GlobalScope$1, | ||
variables: Array [ | ||
Variable$3, | ||
], | ||
}, | ||
], | ||
} | ||
`; |