在 Node 项目上运行 Sonar 扫描仪时,我收到“无法解析文件”错误,如下所示
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;
运行 Sonar 扫描仪时,问题仅存在于 index.js 而不是 AddCat.js。我认为这是某种格式问题,非常感谢任何帮助解决该问题的帮助。
问候, 阿舒托什
最佳答案
语法导出默认值
是stage 1 proposal 。 SonarQube 仅支持开箱即用的 ES 2018 语法。实际上,这意味着在此文件中不会检测到任何问题。
关于javascript - Sonar 扫描仪 - 错误 : Failed to parse file with espree parser in module mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52876717/