original parserOptions not getting passed to traversed files. Intentional?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript, react
- Domain
- documentation, tooling
Research direction
Start at src/importer/makeFsImporter.js around line 70 and trace how parserOptions are handled for traversed files versus the original parse call. Confirm the behavior with imported Flow types; done means the intended parser options are consistently applied or the issue documents why they must be reset.
Written by the indexing model from the issue text.
Description
I'm using react-docgen@next on a project that uses Flow, and I'm utilizing the new makeFsImporter importer to be able to parse imported types. Here's my setup:
value = docgen.parse(source, null, null, {
importer: docgen.importers.makeFsImporter(),
filename: path,
parserOptions: {
plugins: [
'jsx',
'flow',
'nullishCoalescingOperator',
'objectRestSpread',
'optionalCatchBinding',
'optionalChaining',
'classProperties',
'classPrivateProperties',
'classPrivateMethods',
],
},
});
I am passing parserOptions because the .babelrc that react-docgen finds is not the one I want it to use (it doesn't contain the flow plugin). I noticed that the parserOptions get applied correctly to the original file, but for other files that are traversed, parserOptions are ignored:
https://github.com/reactjs/react-docgen/blob/master/src/importer/makeFsImporter.js#L70
This causes a SyntaxError when traversed files with imported types are parsed because it reverts to the .babelrc that I was avoiding by specifying parserOptions.plugins.
Is the line in makeFsImporter that sets parserOptions: {} intentional? Or can it be removed so that parserOptions specified in the original parse call are applied to other files? I'm happy to open a PR if so.
EDIT: I found a similar question asked when this code was introduced: https://github.com/reactjs/react-docgen/pull/352/files/8c0a15fcae4053b1d2115bd7dbd24252cf70b228#r287538448.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 3h 28m
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reactjs/react-docgen
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
reactjs/react-docgen#1102 ·
-
Typescript Status Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
reactjs/react-docgen#1005 · 4 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
reactjs/react-docgen#997 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
reactjs/react-docgen#994 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
reactjs/react-docgen#982 · 2 comments ·
All issues in reactjs/react-docgen
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·