Skip to content Skip to sidebar Skip to footer

Eslint Parsing Error On Export Statement

I'm following a course and the author exports out a Component in the following manner: export MainContainer from './Main/MainContainer' The default correct way is export { default

Solution 1:

The default correct way is export { default as MainContainer } from './Main/MainContainer'

Where did you get that information? According to the MDN Documentation, you could either:

export { MainContainerasdefault } from'./Main/MainContainer'

or

exportdefaultMainContainerfrom'./Main/MainContainer'

Solution 2:

In my app when I did eslint --init I choose json as one of the options.

This created a .eslint.json file, so I had 2 eslint files, my original .eslintrc and the json version.

I believe the .json version was overriding the non-JSON version.

Here is the file with the additions from the original:

enter image description here

{"env":{"browser":true,"es6":true},"extends":["eslint:recommended","plugin:react/recommended"],"parser":"babel-eslint","parserOptions":{"ecmaFeatures":{"experimentalObjectRestSpread":true,"jsx":true},"sourceType":"module"},"plugins":["react"],"rules":{"no-console":[2,{"allow":["warn","error"]}],"indent":["error",2],"linebreak-style":["error","unix"],"quotes":["error","single"],"semi":[2,"never"],"no-extra-semi":2,"jsx-quotes":[2,"prefer-single"],"react/jsx-boolean-value":[2,"always"],"react/jsx-closing-bracket-location":[2,{"selfClosing":"after-props","nonEmpty":"after-props"}],"react/jsx-max-props-per-line":[2,{"maximum":3}],"react/self-closing-comp":2,"react/sort-comp":2}}

Now I do not get the error or warning when using:

export MainContainer from './Main/MainContainer'

Post a Comment for "Eslint Parsing Error On Export Statement"