0

我在设置 JSCS 以使用 JSX/React 和 ES6(stage-0)时遇到了困难。它抛出这样的错误:

Expected end of node list but "Punctuator" found at ./src/base/react/architecture/components/Dummy.component.jsx :
     1 |import React, { PropTypes, Component } from 'react';
--------^

Expected end of node list but "Punctuator" found at ./src/base/react/architecture/utils/redux-ext.js :
     1 |import React from 'react';
--------^
     2 |import Immutable from 'immutable';
     3 |import * as reactRedux from 'react-redux';

我无法修复它或找到此问题的原因。

我的配置是:

{
  "preset": "airbnb",
  "validateIndentation": 4,
  "fileExtensions": [
    ".js",
    ".jsx"
  ],
  "maxErrors": -1,
  "excludeFiles": [
    "**/ammap.js",
    "**/worldHigh.js",
    "**/worldLow.js",
    "node_modules/*",
    "**/assets/*"
  ]
}
4

1 回答 1

2

我有同样的问题。经过一番挖掘,我把它钉在了我的静态 propTypes 中的分号上。我也在 JSCS 3.0.7 上。当前的解决方法(仍在寻找更好的解决方法):

import React from 'react';
import {connect} from 'react-redux';

//jscs:disable requireSemicolons
//unfortunately had to disable semicolons
const SomeComponent = WrappedComponent => class SomeComponent extends React.Component {

    static propTypes = {
        somePropType: React.PropTypes.func,
    } //semicolon here caused the 'Punctuator' error 

    constructor (props) {
        super(props); ....
于 2016-12-19T20:00:27.807 回答