我正在尝试升级到Babel到6.4。在解决了require
的一系列问题之后,现在我对丢失分号有很多错误:
ERROR in ./src/components/views/HomePage/main.js
Module build failed: SyntaxError: /Users/chris/ss/components/views/HomePage/main.js: A semicolon is required after a class property (16:23)
14 | @connectToStores
15 | class HomePage extends Component{
> 16 | static propTypes = {}
| ^
17 |
18 | static contextTypes = {
19 | onSetBodyClass: PropTypes.func.isRequired,
at Parser.pp.raise (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:1425:13)
at Parser.pp.parseClassProperty (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:2577:10)
at Parser.parseClassProperty (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:3785:20)
at Parser.pp.parseClassBody (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:2482:34)
at Parser.pp.parseClass (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:2425:8)
at Parser.pp.parseStatement (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:1889:19)
at Parser.parseStatement (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:3574:22)
at Parser.pp.parseBlockBody (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:2294:21)
at Parser.pp.parseTopLevel (/Users/chris/ss/node_modules/babel-core/node_modules/babylon/index.js:1823:8)
是否有一个linter或一些实用程序可以自动修复所有这些?
答案 0 :(得分:0)
看完这篇文章后,巴贝尔会改变这一点。
此外,this response to the same issue建议还原Babel版本,直到问题解决为止:
<强>的package.json 强>
"babel": "<6.3.0",
"babel-cli": "<6.3.0",
"babel-core": "<6.3.0",
"babylon": "<6.3.0",
据我所知,尽管如此,仍然可以告诉我们已经提到的TC39规范。
答案 1 :(得分:0)
您可以使用JSCS&#39; requireSemicolons规则自动修复此内容。
https://github.com/jscs-dev/node-jscs/pull/2057 - 在2.9.0版本中添加了此内容。