Sébastien
Sébastien

Reputation: 12139

How to disallow JSX syntax in JavaScript files (.js extension)

I would like to make sure that JavaScript files (with js extension) in VS Code contain valid JavaScript syntax only.

Is it possible to disallow JSX syntax for .js files in VS Code?

Ideally of course I would like to still allow the JSX syntax for .jsx files.

Upvotes: 0

Views: 108

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318638

You can use the react/jsx-filename-extension rule of eslint-plugin-react.

By default it only allows JSX inside *.jsx files so you will have an error/warning (depending on how you configure it) when it detects JSX in a file where it shouldn't be.

Upvotes: 1

Related Questions