# Ignoring Files or Folders

Sealights' Node.js agent provides the ability to exclude files or folders from the analysis.

* To ignore files from being scanned, create a file called `.slignore` and list in it the file names to match against
* If you are using source maps, you can ignore original files from being included by creating a file called `.slignore.generated`
* Both files use glob pattern aligned to .gitignore format

{% hint style="info" %}
A **common best practice** is to analyze your project files via the output of a command like `tree --du -h -I 'node_modules|sl-dry-run-output|sl_dist' -P "*.[jt]s*"`\
When executed from the root folder of your project, it helps to define accurate *Ignore Rules* described below based on the detailed list of javascript and typescript files the agent will find.
{% endhint %}

## Ignoring test files <a href="#ignoring-test-files" id="ignoring-test-files"></a>

For example, a common best practice is to exclude all the test files from the Build Scan.

If you decide to ignore the test files, the content of your .**slignore** file will be similar to:

```
**/*test.js
```

If you prefer the option to ignore the TS files, your **.slignore.generated** will be similar to

```
**/*.spec.ts
```

## Ignoring Angular bundle files <a href="#ignoring-angular-bundle-files" id="ignoring-angular-bundle-files"></a>

It is recommended for angular applications to add the following to your **.slignore** file:

```
*vendor*.js
*runtime*.js
*inline*.js
*polyfills*.js
```

It is recommended as well to ignore legacy versions of JS files generated for backward compatibility of older browser versions like `es5`, `es2015`…

```
**/es5 
*-es5.js
```

{% hint style="info" %}
More information about the potential consequences is detailed in a dedicated article [Angular 8+: Duplicate Method Reporting](/knowledgebase/setup-and-configuration/troubleshooting-faq/node-javascript/angular-8+-duplicate-method-reporting.md)
{% endhint %}

## Ignoring common mapped files (Images and HTML) <a href="#ignoring-common-mapped-files-images-and-html" id="ignoring-common-mapped-files-images-and-html"></a>

It is recommended to ignore Images and HTML files (as they are listed in the source map files) by adding the following to your **.slignore.generated** file:

{% code overflow="wrap" lineNumbers="true" %}

```
*.html
*.png
*.svg
```

{% endcode %}

## Ignoring all but specific files (whitelisting) <a href="#ignoring-all-but-specific-files-whitelisting" id="ignoring-all-but-specific-files-whitelisting"></a>

In certain projects, it is easier to define only the files that are required. Below, a sample of `.slignore` file definition with that approach:

{% code overflow="wrap" lineNumbers="true" %}

```
#Ignore everything but files matching patterns below (starting with !)
*
!*main*.js
```

{% endcode %}

{% hint style="info" %}
For more details about the format, please refer to [the official git documentation](https://git-scm.com/docs/gitignore) that Sealights strictly aligns with.
{% endhint %}


---

# 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.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/ignoring-files-or-folders.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.
