# ESLint Rules

Project Zero uses a set of ESLint rules which extends upon the "eslint:recommended" rule set. These rules are marked by a checkmark at <https://eslint.org/docs/rules/> . Keep in mind that ESLint might change these at any time. You can see the extended rules in `/templates/.eslintrc.js`.

Most of these added rules are from [Best Practices](https://eslint.org/docs/rules/#best-practices), [Stylistic Issues](https://eslint.org/docs/rules/#stylistic-issues) and [ECMAScript 6](https://eslint.org/docs/rules/#ecmascript-6) sections. The main goal here is to have a base set of rules that prevents some common issues and improve code readability without restricting the developer too much.

Since we use '@babel/eslint-parser' as parser, you should make sure that you're using Node.js version 14+.

To make sure ESLint is properly configured in the project and its rules are applied correctly, there is a "pre-commit" git hook. With it, no code that doesn't pass linting will be pushed to production. Of course, it is possible for developers to use "eslint-disable" statements and these should be caught and questioned during code review.

To help find and fix possible linting errors on project basis, there are 2 npm scripts: `npm run lint` and `npm run lint:fix`.

```
"lint": "eslint .", // Lint project
"lint:fix": "eslint . --fix" // Lint project and fix auto-fixable issues
```

If you're using Visual Studio Code, following setup is recommended:

1 - Plugin: [VS Code ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)

2 - Settings:

```
{
 // Auto-fix problems on file save
 "editor.codeActionsOnSave": {
     "source.fixAll.eslint": true
 },
 // Make sure it's looking at the correct directory
 "eslint.workingDirectories": ["./templates"],
}
```


---

# 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.akinon.com/technical-guides/project-zero/django/project-structure/eslint-rules.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.
