-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove match utility and cleanup code (#744)
- Loading branch information
Showing
17 changed files
with
136 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'react-docgen': major | ||
--- | ||
|
||
Remove match utility. | ||
|
||
The utility can be replaced by babel helpers and is not needed anymore. Also | ||
using explicit checks like `path.isMemberExpression()` is better for type safety | ||
and catching potential bugs. |
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
80 changes: 80 additions & 0 deletions
80
packages/react-docgen/src/utils/__tests__/isReactChildrenElementCall-test.ts
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,80 @@ | ||
import { parse } from '../../../tests/utils'; | ||
import isReactChildrenElementCall from '../isReactChildrenElementCall.js'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
describe('isReactChildrenElementCall', () => { | ||
describe('true', () => { | ||
test('React.Children.map', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("React"); | ||
React.Children.map(() => {}); | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(true); | ||
}); | ||
|
||
test('React.Children.only', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("React"); | ||
React.Children.only(() => {}); | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(true); | ||
}); | ||
}); | ||
describe('false', () => { | ||
test('not call expression', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("React"); | ||
React.Children.map; | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(false); | ||
}); | ||
|
||
test('not MemberExpression', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("React"); | ||
map(); | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(false); | ||
}); | ||
|
||
test('not only or map', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("React"); | ||
React.Children.abc(() => {}); | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(false); | ||
}); | ||
|
||
test('not double MemberExpression', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("React"); | ||
Children.map(() => {}); | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(false); | ||
}); | ||
|
||
test('not Children', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("React"); | ||
React.Parent.map(() => {}); | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(false); | ||
}); | ||
|
||
test('not react module', () => { | ||
const def = parse.expressionLast(` | ||
var React = require("test"); | ||
React.Children.map(() => {}); | ||
`); | ||
|
||
expect(isReactChildrenElementCall(def)).toBe(false); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
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
26 changes: 15 additions & 11 deletions
26
packages/react-docgen/src/utils/isReactChildrenElementCall.ts
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.