sonar-scanner - ERROR: Failed to parse file with espree parser in module mode

sonar-scanner - ERROR: Failed to parse file with espree parser in module mode

在节点项目上 运行 sonar-scanner 时,我收到无法解析文件错误,如下所示

ERROR: Failed to parse file [file:///home/node-app/somedir/index.js] at line 1: Unexpected token './AddCat' (with espree parser in module mode)

我的 index.js 文件如下所示:

export default from './AddCat';

我的 AddCat.js 文件如下所示:

import React from 'react';
import { Image } from '@cat-ui/core';

import { translate } from 'client/helpers/language';
import Page from 'client/components/Page';

import { StyledText, StyledButton, StyledImagePlaceholder } from './AddCat.styled';
import AdditionalApplicant from './images/additional_applicant.png';

const AddCat = () => (
  <Page>
    <StyledImagePlaceholder>
      <Image width="67px" height="60px" src={AdditionalApplicant} />
    </StyledImagePlaceholder>
    <StyledText color="grey">{translate('AddCatText')}</StyledText>
    <StyledButton
      tag="a"
      color="secondary"
      href="/morecats/morecats.html?route=V1&sharedCat=true"
      label={translate('AddCatButton')}
    />
  </Page>
);

export default AddCat;

问题仅出在 index.js 而不是 AddCat.js 而 运行 声纳扫描仪。我认为这是某种格式问题,非常感谢您提供解决问题的帮助。

此致, 阿舒托什

语法 export default fromstage 1 proposal。 SonarQube 仅支持开箱即用的 ES 2018 语法。实际上,这意味着在此文件中不会检测到任何问题。