-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…k#21833) This prevents edge cases where AST nodes are incorrectly matched.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import {createContext, useContext} from 'react'; | ||
|
||
const A = createContext(1); | ||
const B = createContext(2); | ||
|
||
export function Component() { | ||
const a = useContext(A); | ||
const b = useContext(B); | ||
|
||
// prettier-ignore | ||
const c = useContext(A), d = useContext(B); // eslint-disable-line one-var | ||
|
||
return a + b + c + d; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
const {useDebugValue, useState} = require('react'); | ||
|
||
function Component(props) { | ||
const foo = useCustomHookOne(); | ||
// This cae is ignored; | ||
// the meaning of a tuple assignment for a custom hook is unclear. | ||
const [bar] = useCustomHookTwo(); | ||
return `${foo}-${bar}`; | ||
} | ||
|
||
function useCustomHookOne() { | ||
// DebugValue hook should not appear in log. | ||
useDebugValue('example'); | ||
return true; | ||
} | ||
|
||
function useCustomHookTwo() { | ||
const [baz, setBaz] = useState(true); | ||
return [baz, setBaz]; | ||
} | ||
|
||
module.exports = {Component}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
const {useDebugValue} = require('react'); | ||
|
||
function Component(props) { | ||
useCustomHookOne(); | ||
const [bar] = useCustomHookTwo(); | ||
return bar; | ||
} | ||
|
||
function useCustomHookOne() { | ||
// DebugValue hook should not appear in log. | ||
useDebugValue('example'); | ||
} | ||
|
||
function useCustomHookTwo() { | ||
// DebugValue hook should not appear in log. | ||
useDebugValue('example'); | ||
return [true]; | ||
} | ||
|
||
module.exports = {Component}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
const React = require('react'); | ||
const {useEffect} = React; | ||
|
||
function Component(props) { | ||
useEffect(() => {}); | ||
React.useLayoutEffect(() => () => {}); | ||
return null; | ||
} | ||
|
||
module.exports = {Component}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
const React = require('react'); | ||
const {useReducer} = React; | ||
|
||
function Component(props) { | ||
const [foo] = useReducer(true); | ||
const [bar] = useReducer(true); | ||
const [baz] = React.useReducer(true); | ||
return `${foo}-${bar}-${baz}`; | ||
} | ||
|
||
module.exports = {Component}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
const React = require('react'); | ||
const {useState} = React; | ||
|
||
function Component(props) { | ||
const [foo] = useState(true); | ||
const bar = useState(true); | ||
const [baz] = React.useState(true); | ||
return `${foo}-${bar}-${baz}`; | ||
} | ||
|
||
module.exports = {Component}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The JavaScript source files in this directory are not linted or pre-processed in any way. This is intentional, since they are used by the `parseHookNames-test` to test the behavior of "uncompiled" JavaScript (without source maps). |