gajus / eslint-config-canonical

The most comprehensive ES code style guide.
Other
589 stars 30 forks source link

`This experimental syntax requires enabling one of the following parser plugin(s): ‘jsx, flow, typescript’` #50

Closed lucasrmendonca closed 1 week ago

lucasrmendonca commented 2 years ago

When linting .jsx files I have the following error: This experimental syntax requires enabling one of the following parser plugin(s): ‘jsx, flow, typescript’

My .eslintrc.json config file is as follows:

{
  "settings": { "import/extensions": [".js", ".jsx"] },
  "ignorePatterns": ["node_modules/"],
  "parserOptions": {
    "ecmaVersion": "latest",
    "ecmaFeatures": { "jsx": true },
  },
  "extends": ["canonical", "canonical/prettier"],
  "overrides": [
    {
      "files": "*.jsx",
      "extends": ["canonical/react"]
    }
  ]
}

If I install "@babel/preset-react" with npm and add the following property to "parserOptions", the error goes away and .jsx files are then linted normally:

"parserOptions": {
   ...
   "babelOptions": {
      "presets": ["@babel/preset-react"]
   },
   ...
},

However, I'm not sure this is the intended way to use the "canonical/react" config since there's no mention of it in the docs...

If @babel/preset-react is required, shouldn't it already come inside the canonical/react config? If it's not required, could someone kindly provide a working example using "canonical/react" with ".jsx" instead of ".tsx"?

github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 44.2.11 :tada:

The release is available on:

Your semantic-release bot :package::rocket: