JSCS标点

时间:2016-09-15 11:32:20

标签: reactjs import ecmascript-6 jscs

我在设置JSCS以使用JSX / React和ES6(阶段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/*"
  ]
}

1 个答案:

答案 0 :(得分: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); ....