Babel-eslint: Using the export keyword between a decorator and a class is not allowed. Please use export @dec class instead

Created on 19 Jun 2019  Â·  9Comments  Â·  Source: babel/babel-eslint

I am getting this error using 8.2.2 ,
I've tried the solution given in #662 but it's not working for me.
My .eslintrc.js file :
{
"plugins": [
"react"
],
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"legacyDecorators": true,
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"rules": {
"no-var": "error",
"block-spacing": "error",
"semi": [
"error",
"never"
],
"quotes": [
"error",
"single"
],
"prefer-arrow-callback": "error",
"react/no-find-dom-node": "warn",
"react/no-deprecated": "warn",
"linebreak-style": [
"error",
"unix"
],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"arrow-body-style": [
"error",
"as-needed"
],
"object-curly-spacing": [
"error",
"always"
],
"comma-dangle": [
"error",
"only-multiline"
],
"array-bracket-spacing": [
"error",
"always"
],
"prefer-destructuring": [
"error",
{
"VariableDeclarator": {
"array": false,
"object": true
},
"AssignmentExpression": {
"array": true,
"object": false
}
}
],
"no-confusing-arrow": [
"error",
{
"allowParens": true
}
],
"no-console": [
"error",
{
"allow": [
"warn",
"error",
"info"
]
}
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"no-unused-vars": [
2,
{
"args": "all",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
]
}
}

and .babelrc file :

{
"plugins": [
"transform-decorators-legacy",
"transform-class-properties",
"transform-object-rest-spread",
"transform-es2015-arrow-functions",
"transform-decorators"
],
"presets": [
"env",
"react"
]
}

Most helpful comment

@Emiya0306 You don't seem to be using babel-eslint?

@wizardpisces Can you share your config?

thank you! I just solved it by adding
`parserOptions: {
parser: 'babel-eslint',
"ecmaFeatures": {
"legacyDecorators": true
}
},

` into .eslintrc.js

All 9 comments

I've tried the solution given in #662 but it's not working for me.

Me too. My .eslintrc config is bellow.

{
  "extends": "prettier",
  "plugins": ["prettier"],
  "rules": {
    "prefer-template": 2,
    "new-cap": 2,
    "no-restricted-syntax": 2,
    "guard-for-in": 2,
    "prefer-arrow-callback": 2,
    "func-names": 2,
    "react/jsx-no-bind": 2,
    "no-confusing-arrow": 2,
    "jsx-a11y/no-static-element-interactions": 2,
    "jsx-a11y/anchor-has-content": 2,
    "react/require-default-props": 2,
    "no-plusplus": 2,
    "no-mixed-operators": 0,
    "no-continue": 2,
    "no-bitwise": 2,
    "no-multi-assign": 2,
    "no-restricted-properties": 2,
    "no-prototype-builtins": 2,
    "jsx-a11y/href-no-hash": 2,
    "class-methods-use-this": 2,
    "import/no-named-as-default": 2,
    "import/prefer-default-export": 2,
    "react/no-unescaped-entities": 2,
    "react/no-string-refs": 2,
    "react/jsx-indent": 0,
    "prettier/prettier": "error"
  },
  "parserOptions": {
    "ecmaFeatures": {
      "legacyDecorators": true
    }
  }
}

any progress?

@Emiya0306 You don't seem to be using babel-eslint?

@wizardpisces Can you share your config?

@Emiya0306 You don't seem to be using babel-eslint?

@wizardpisces Can you share your config?

thank you! I just solved it by adding
`parserOptions: {
parser: 'babel-eslint',
"ecmaFeatures": {
"legacyDecorators": true
}
},

` into .eslintrc.js

Add parserOptions: { ecmaVersion: 2015, ecmaFeatures: { legacyDecorators: true } },
into .eslintrc.js

(node:87277) [ESLINT_LEGACY_ECMAFEATURES] DeprecationWarning: The 'ecmaFeatures' config file property is deprecated, and has no effect. (found in ".eslintrc.json")

"@babel/core": "7.9.0",
"babel-eslint": "10.1.0",

Ah, never mind. ecmaFeatures must be INSIDE parserOptions.

Thank you for the issue. Now that @babel/eslint-parser has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.

Was this page helpful?
0 / 5 - 0 ratings