# JavaScript/TypeScript/CSS

## Requirements and recommendations <a href="#requirements" id="requirements"></a>

This section describes requirements or recommendations regarding the machine running the scanner that are specific to the analysis of JavaScript/TypeScript/CSS. For general requirements, see [General requirements](/sonarqube-server/10.4/analyzing-source-code/scanner-environment/general-requirements.md).

### Memory <a href="#memory" id="memory"></a>

A minimum of 4GB memory is recommended.

To allow the analysis to use more memory, see **Slow or unresponsive analysis** in the **Troubleshooting** section below.

### Node.js <a href="#nodejs" id="nodejs"></a>

The Node.js runtime environment is used by the scanner to perform the analysis. If your architecture is Linux x64, Windows x64, or Apple ARM64, no Node.js installation is required. Otherwise, two options are possible as explained below.

The scanner will retrieve the Node.js runtime according to the following options and in the following order:

1. The Node.js defined through the parameter `sonar.nodejs.executable` (absolute path to Node.js) if the runtime version is compatible.
2. The Node.js downloaded by the scanner from the SonarQube server during analysis if the detected architecture is one of the supported ones: Linux x64, Windows x64, and Apple ARM64.
3. The Node.js defined with `node` in the `PATH` if the runtime version is compatible.

If your architecture is neither Linux x64, Windows x64, nor Apple ARM64 then you must set up option 1 or 3 (to know how to set up option 1, see [Analysis parameters](/sonarqube-server/10.4/analyzing-source-code/analysis-parameters.md)). In that case, we recommend using the [active LTS](https://nodejs.org/en/about/previous-releases#release-schedule) of Node.js, currently v20. Otherwise, Node.js v16 is the minimum supported version but it will soon be unsupported.

### Other <a href="#other" id="other"></a>

If you have a community plugin for CSS analysis installed on your SonarQube instance it will conflict with analysis of CSS, so it should be removed.

## Language-specific properties <a href="#language-specific-properties" id="language-specific-properties"></a>

Discover and update the JavaScript/TypeScript [Analysis parameters](/sonarqube-server/10.4/analyzing-source-code/analysis-parameters.md) in **Administration > General Settings > Languages > JavaScript/TypeScript**.

Discover and update the CSS [Analysis parameters](/sonarqube-server/10.4/analyzing-source-code/analysis-parameters.md) in **Administration > General Settings > CSS**.

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

### Slow or unresponsive analysis <a href="#slow-or-unresponsive-analysis" id="slow-or-unresponsive-analysis"></a>

On a big project, more memory may need to be allocated to analyze the project. This would be manifested by analysis getting stuck and the following stack trace might appear in the logs

```css-79elbk
ERROR: Failed to get response while analyzing [file].ts
java.io.InterruptedIOException: timeout
```

You can use `sonar.javascript.node.maxspace` property to allow the analysis to use more memory. Set this property to `4096` or `8192` for big projects. This property should be set in `sonar-project.properties` file or on command line for scanner (with `-Dsonar.javascript.node.maxspace=4096`).

### File encoding errors <a href="#file-encoding-errors" id="file-encoding-errors"></a>

If you encounter file encoding errors, use `sonar.sourceEncoding=UTF-8` configuration. To know how to perform this configuration, see [Analysis parameters](/sonarqube-server/10.4/analyzing-source-code/analysis-parameters.md).

### Default exclusions for JS/TS <a href="#default-exclusions-for-jsts" id="default-exclusions-for-jsts"></a>

By default, analysis will exclude files from dependencies in usual directories, such as `node_modules`, `bower_components`, `dist`, `vendor`, and `external`. It will also ignore `.d.ts` files. If for some reason analysis of files in these directories is desired, it can be configured by setting `sonar.javascript.exclusions` property to empty value, i.e. `sonar.javascript.exclusions=""`, or to comma separated list of paths to be excluded. This property will exclude only JavaScript/TypeScript files, while `sonar.exclusions` property will exclude all files. `sonar.exclusions` property should be preferred to configure general exclusions for the project.

By default, analysis will exclude all files whose size is greater than 1000 KB. To change this limit, set the `sonar.javascript.maxFileSize` property on scanner side, or change the limit in the UI (**Maximum size of analyzed files** field under **Project Settings > General Settings > Languages>JavaScript / TypeScript** (at project level) or **Administration> General Settings > Languages>JavaScript / TypeScript** (at global level)).

### Detection of code bundles <a href="#detection-of-code-bundles" id="detection-of-code-bundles"></a>

The analyzer will attempt to detect bundled code or generated code. This means code that was automatically transformed and optimized with tools such as Webpack and similar. We consider generated code out of scope of the analysis since developers are not able to act upon the findings in such code. Whenever generated code is detected, the analysis will print a log message: once per the whole project on `INFO` level, and for each file on the `DEBUG` level. If you want to opt-in for analyzing the generated code or in case the detection is incorrect, you can disable it by setting `sonar.javascript.detectBundles=false`.

### Custom rules for JS/TS <a href="#custom-rules-for-jsts" id="custom-rules-for-jsts"></a>

Custom rules are not supported by the analyzer. As an alternative we suggest you to have a look at [ESLint](https://eslint.org/docs/developer-guide/). It provides custom rules that you can then import thanks to the [External analyzer reports](/sonarqube-server/10.4/analyzing-source-code/importing-external-issues/external-analyzer-reports.md) feature.

## Related Pages <a href="#related-pages" id="related-pages"></a>

* [External analyzer reports](/sonarqube-server/10.4/analyzing-source-code/importing-external-issues/external-analyzer-reports.md) (ESLint, TSLint, StyleLint)
* [Overview](/sonarqube-server/10.4/analyzing-source-code/test-coverage/overview.md) (LCOV format)
* [SonarJS plugin for ESLint](https://github.com/SonarSource/eslint-plugin-sonarjs)
* [Adding coding rules](/sonarqube-server/10.4/extension-guide/adding-coding-rules.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/10.4/analyzing-source-code/languages/javascript-typescript-css.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
