I am using SonarQube Scanner 3.3.0.1492, with the SonarJS 5.2.1.7778 (javascript) plugin. I did a yarn install to install typescript v3.5.3. When I run sonar scanner, I receive a couple of different parse errors for things that normally parse properly during our builds. Here are a couple of examples
const genericGatewayRequest = <T extends {} | void>(request: AxiosRequestConfig): AxiosPromise<T> => {
^
const mockedAxios = Axios as jest.Mocked<typeof Axios>;
^
declare module 'react-number-format' {
export interface NumberFormatProps extends Partial<FormOutlinedTextFieldProps> {
^
Most of these appear to be newer features of typescript. So I’m wondering which part of my setup is out of date? I don’t understand how sonar-scanner gets its configuration for typescript.
For extra context here is my sonar-project.properties:
sonar.exclusions=node_modules/**
sonar.projectKey=membexxxxxxxxxx
sonar.sources=.
sonar.host.url=https://stl-wxxxxxxx
And my tsconfig.json:
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"baseUrl": "src",
"paths": {
"@test-utils": [
"../test/utils"
]
},
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"sourceMap": true
},
"include": [
"./src/**/*"
]
}
And my .eslintrc.js (if this is even used):
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended',
'plugin:jsx-a11y/strict',
'plugin:sonarjs/recommended'
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
},
rules: {},
plugins: ['react', 'jsx-a11y', 'sonarjs'],
parserOptions: {
ecmaFeatures: {
jsx: true
}
},
settings: {
react: {
version: 'detect'
}
}
};