score:4

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": {
  "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
    "<rootdir>/__mocks__/filemock.js",
  "\\.(css|less)$": "<rootdir>/__mocks__/stylemock.js"
}

screenshot:

exclude-static-assets

score:0

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