Search code examples
javascriptreactjsjscs

Tool for checking codestyle in JSX files


There are exists many beautiful code formatting tools for vanilla Javascript. For example, JSCS. Is there any tool that can validate and format reactjs templates?

I have got error like that one at this moment

Unexpected token < at static/view/Auth.jsx :
    34 |
    35 |  return (
    36 |      <div className="auth-page"></div>

Solution

  • JSCS can be used with React. You have to add flag --esprima=esprima-fb to make it compatible with jsx syntax.

    If you're starting your JSCS from cmd: jscs path[ path[...]] --esprima=esprima-fb

    If you have a .jscrsc config file add "esprima" : "esprima-fb"