Tôi có một tệp index.js có tên xuất sau được đặt tên trong đó.eslint ném lỗi phân tích cú pháp không mong muốn khi xuất tên là
export Main from './Main/Main'
Tuy nhiên, eslint không thích điều này và ném lỗi
Parsing error: Unexpected token Main
Tôi không chắc chắn lý do tại sao khi ứng dụng được hoạt động bình thường và tôi tin rằng đó là cú pháp hợp lệ.
tập tin .eslintrc của tôi trông như thế này
{
env: {
es6: true,
browser: true
},
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true
}
},
plugins: [
"react",
],
extends: ["eslint:recommended", "plugin:react/recommended", "standard"],
"rules": {
"comma-dangle" : [2, "always-multiline"],
"semi": [2, "never"],
"no-extra-semi": 2,
"jsx-quotes": [2, "prefer-single"],
"react/jsx-boolean-value": [2, "always"],
"react/jsx-closing-bracket-location": [2, {selfClosing: "after-props", nonEmpty: "after-props"}],
"react/jsx-curly-spacing": [2, "never", {"allowMultiline": false}],
"react/jsx-max-props-per-line": [2, {maximum: 3}],
"react/jsx-no-literals": 2,
"react/sort-prop-types": 2,
"react/self-closing-comp": 2,
"react/sort-comp": 2
},
}
Đó không phải là cú pháp hợp lệ, như bạn có thể xác minh bằng cách nhìn vào spec: http: //www.ecma-international. org/ecma-262/6.0/index.html # table-42. Giải pháp chính xác là gì phụ thuộc vào những gì ''./Main/Main'' xuất khẩu và làm thế nào nó. –
Đó là một đề xuất cú pháp, nhưng bạn sẽ phải kích hoạt nó. – loganfsmyth
@ FelixKling Bạn nói đúng. Có ý tưởng từ đây https://github.com/erikras/react-redux-universal-hot-example/blob/master/src/components/index.js Cảm ơn những người đứng đầu! –