react-docgen
react-docgen copied to clipboard
SyntaxError: Invalid regular expression flag
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"),
};
There is no error when I paste the code here: http://reactcommunity.org/react-docgen/ .