Accepted answer

Here is how I resolved the issue.

    • Add the following content to your .babelrc file and make sure .babelrc is in the root folder
{ "presets": ["env","react"] }
    • Make sure you exclude static assets like CSS, images, SCSS, PDF, fonts, etc. Add the following to package.json as highlighted in the screenshot
"moduleNameMapper": {
  "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"




If anybody comes here to figure out what is happening, I think the accepted answer is not related to the issue here.

When the file extension is .js and if you try to write JSX in that file, linter will complain if you have a correct ESlint configuration.

Instead, try to change the file extension to .jsx or .tsx (if Typescript involved).

Related Query

More Query from same tag