# Configuring ESLint

The **ScandiPWA out of the box comes with a very strict linter**. It is here to ensure the quality and consistency of the code between projects. In some cases, the configured defaults might seem too strict, this guide is here to help developers configure to match their needs.

Some rules are our preference, some are "essential" to make sure the code you are writing is compatible with ScandiPWA's plugin architecture. The list of such rules can be found below.

## Essential rules

All `scandipwa` specific rules can be found in `@scandipwa/eslint-plugin-scandipwa-guidelines` NPM package. To use it in your ESLint configuration, add the following fields to your declaration:

```javascript
{
    "plugins": [
        "@scandipwa/scandipwa-guidelines"
    ],
    "rules": {
        // Force @namespace comments in the code
        "@scandipwa/scandipwa-guidelines/use-namespace": "error",
        // Use "__construct" instead of "constructor"
        "@scandipwa/scandipwa-guidelines/use-magic-construct": "error",
    }
}
```

## How to disable ESLint

By default, ESLint is always enabled and check on every compilation. This ensures the quality of code before committing it (otherwise if checked on commit, the changes made are commonly not checked by the developer on a working site).

To disable the ESLint, the following configuration must be added to the ScandiPWA theme's `package.json` file:

```javascript
{
        ...
        "eslintConfig": {
                "extends": "@scandipwa",
                "ignorePatterns": ["src/**"]
        },
        ...
}
```

Learn more about `ignorePatterns` in [official ESLint docs](https://eslint.org/docs/user-guide/configuring/ignoring-code).

## How to change ESlint configurations

You have two main options to change (learn about more options in [the official ESLint guide](https://eslint.org/docs/user-guide/configuring/configuration-files#using-configuration-files)):

* Extend a completely different preset
* Add "overrides" to default configuration values

To change any of these, the ScandiPWA theme's `package.json` file's `eslintConfig` fields. For example:

```javascript
{
    ...
    "eslintConfig": {
        "extends": [
            "react-app"
        ],
        "overrides": [
            "react/jsx-props-no-spreading": "off"
        ]
    }
    ...
}
```


---

# 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.scandipwa.com/developing-with-scandi/developer-tools/configuring-eslint.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.
