reactjs / reactjs/react-docgen

SyntaxError: Invalid regular expression flag

Open
#329 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
316
Avg merge
5h 7m
Merged PRs (30d)
4

Description

I use
create-react-app with "react-scripts": "^2.1.5"
and "react-styleguidist": "^8.0.6"

Warning: Cannot parse src/components/Card/Card.jsx: SyntaxError: Invalid regular expression flag (1:8)

It usually means that react-docgen does not understand your source code, try to file an issue here:
https://github.com/reactjs/react-docgen/issues
import React from "react";
// nodejs library that concatenates classes
import classNames from "classnames";
// nodejs library to set properties for components
import PropTypes from "prop-types";
// @material-ui/core components
import withStyles from "@material-ui/core/styles/withStyles";
// @material-ui/icons

// core components
import cardStyle from "./cardStyle.jsx";

function Card({ ...props }) {
	const { classes, className, children, plain, carousel, ...rest } = props;
	const cardClasses = classNames({
		[classes.card]: true,
		[classes.cardPlain]: plain,
		[classes.cardCarousel]: carousel,
		[className]: className !== undefined
	});
	return (
		<div className={cardClasses} {...rest}>
			{children}
		</div>
	);
}

Card.propTypes = {
	classes: PropTypes.object.isRequired,
	className: PropTypes.string,
	plain: PropTypes.bool,
	carousel: PropTypes.bool,
	children: PropTypes.object.isRequired
};

export default withStyles(cardStyle)(Card);

and "react-styleguidist": "^8.0.6"
styleguide.config.js

module.exports = {
	propsParser: require("react-docgen").parse,
	webpackConfig: require("react-scripts/config/webpack.config"),
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Card/Card.jsx and styleguide.config.js, then run the reported react-docgen parse through the react-styleguidist setup. Reproduce the invalid regular expression flag error and trace which syntax construct causes it; done means the example parses successfully or the unsupported syntax is clearly identified and covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.