Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESLint] Decorators Parsing Error #2686

Closed
Lionad-Morotar opened this issue Apr 5, 2019 · 2 comments
Closed

[ESLint] Decorators Parsing Error #2686

Lionad-Morotar opened this issue Apr 5, 2019 · 2 comments

Comments

@Lionad-Morotar
Copy link

问题描述

我的config/index.js中, 插件transform-decorators-legacy并没有关闭:

  plugins: {
    babel: {
      sourceMap: true,
      presets: [
        'env'
      ],
      plugins: [
        'transform-decorators-legacy',
        'transform-class-properties',
        'transform-object-rest-spread'
      ]
    }
  },

但是执行ESLint时, 遇到报错:

D:\@github\twt\src\pages\packages\play\pages\game\index.js
  18:1  error  Parsing error: Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.

  16 | @inject('appStore')
  17 | @observer
> 18 | export default class PreparePage extends Component {
     | ^
  19 | 
  20 |   config = {
  21 |     navigationStyle: 'custom'

✖ 2 problems (2 errors, 0 warnings)

Taro 版本:

👽 Taro v1.2.23


  Taro CLI 1.2.23 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 10.15.3 - C:\nodejs\node.EXE
      Yarn: 1.13.0 - C:\Users\18062\AppData\Roaming\npm\yarn.CMD
      npm: 6.9.1-next.0 - C:\nodejs\npm.CMD
@taro-bot
Copy link

taro-bot bot commented Apr 5, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@Lionad-Morotar
Copy link
Author

升级依赖 babel-eslint9.0.0 , 并在 .eslintrc 文件中配置parserOptions.ecmaFeatures.legacyDecorators 可以解决这个问题

请参考: https://github.com/babel/babel-eslint/releases/tag/v9.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant