ant-design / ant-design-pro

👨🏻‍💻👩🏻‍💻 Use Ant Design like a Pro!
https://pro.ant.design
MIT License
36.35k stars 8.14k forks source link

Precommit Error: Using the export keyword between a decorator and a class is not allowed #2076

Closed Madridspark closed 6 years ago

Madridspark commented 6 years ago

\src\routes\List\TableList.js

error Parsing error: Using the export keyword between a decorator and a class is not allowed. Please use export @dec class instead.

  64 | }))
  65 | @Form.create()
> 66 | export default class TableList extends PureComponent {
     | ^
  67 |   state = {
  68 |     modalVisible: false,
  69 |     expandForm: false,
Madridspark commented 6 years ago

同样的错误还在其他使用了装饰器的文件中出现,而无法在 ESLint 文档中查到忽略此种错误的方法。

The same error occurs in other files that use decorators, and methods that ignore such errors cannot be found in the ESLint documentation.

chenshuai2144 commented 6 years ago

看起来像是 tslint 的报错。。。

Madridspark commented 6 years ago

问题是,这是官方的代码,我并没有改。。。

chenshuai2144 commented 6 years ago

编辑器干的吗?

Madridspark commented 6 years ago

应该不是,是在提交的时候,Git 的 precommit 钩子触发了 lint-stage 代码检查

yoyo837 commented 6 years ago

babel-eslint v9 使用了新的装饰者提案 https://github.com/babel/babel-eslint/releases/tag/v9.0.0, @chenshuai2144 是不是得umi 搞一下,否则降级v8.2.6

yoyo837 commented 6 years ago

应该来个紧急修复兼容下老的提案写法,而且vscode编辑器目前格式化也是按老的方式;不过umi和pro官方的小伙伴没有出现这个问题吗?

afc163 commented 6 years ago

https://github.com/ant-design/ant-design-pro/commit/cbf117ec66c3bc23c1e29a7b7fdf728f0fcd0ea3

特意为了这个改了一圈。

afc163 commented 6 years ago

https://github.com/tc39/proposal-decorators/issues/69#issuecomment-370234060

yoyo837 commented 6 years ago

原来是都改过去了,那我也这么干。

Madridspark commented 6 years ago

😂那我也改了吧,谢谢

hazeFlame commented 6 years ago

刚出现,我刚安装了8.2.6还是不行

hazeFlame commented 6 years ago

image image 我这个怎么搞

Madridspark commented 6 years ago

凉了,官方最新的版本把这种都改过来了,以前的写法是不符合规范的,要是自己的代码的话你就手动改过来吧,要是 antd pro 的话就从 github 拉最新的代码下来

yoyo837 commented 6 years ago

@hazeFlame See #2122

hazeFlame commented 6 years ago

没用过pro,只能一个一个改了。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

afc163 commented 6 years ago

我改的时候也感到很蛋疼。。

ekuwang commented 6 years ago

我clone了最新的代码,提交时依然在precommit会报错。最终发现,是因为lint-staged中会执行prettier --write命令,这个命令把decorator的用法又改回了旧的格式,导致随后的lint不通过,从而无法commit

jwmann commented 6 years ago

I have the same issue as @ekuwang

zjafei commented 5 years ago

我clone了最新的代码,提交时依然在precommit会报错。最终发现,是因为lint-staged中会执行prettier --write命令,这个命令把decorator的用法又改回了旧的格式,导致随后的lint不通过,从而无法commit

是我 我也是的

chenshuai2144 commented 5 years ago

顺应时代潮流吧

pingbeer commented 5 years ago

mark

gclsoft commented 5 years ago

,
//  "husky": {
//    "hooks": {
//      "pre-commit": "npm run lint-staged"
//    }
//  }
```去掉就行