---
schema_version: "1"
id: ca7d13608981a1828cb33984e71203fb9cde1151c22b39f43e1346509de2b441
title: ESLint Customization (Retired)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/code-analyzer/salesforce-code-analyzer/guides/v3x/custom-configuration/eslint-config.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/eslint-config.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1603ac4bcabe71b68c2281d8150ae2184b1877679e7424f9cb5d9c231eebf4cf
products:
  - Salesforce Code Analyzer
---
# ESLint Customization (Retired)

To bring in the power of any ESLint capabilities that aren’t supported by default in Salesforce Code Analyzer, use your own customized `.eslintrc.json`. You have the flexibility to use different parsers or plug-ins, and you can define your own custom ESLint ruleset.

To invoke a customized ESLint file, pass in your config file filepath as a value to `--eslintconfig` flag in `scanner run` command. For example:

```
	`$ sf scanner run --target /path/to/your/target --eslintconfig /path/to/.eslintrc.json`
```

## Your ESLint Custom Configuration Responsibilities

Before setting up your custom configuration with ESLint through Code Analyzer, make sure that you understand your responsibilities.

- All npm dependencies, including ESLint, must be installed in the directory where you run the `scanner run` command.
- Your custom configuration cascades into your other project configurations as though you ran ESLint directly with the `-c | –config` flag. Your custom configuration must perform all necessary overrides.
- Your `.eslintrc.json` file must be in `.eslintrc` format. However, there are no restrictions on the filename.
- The `.eslintignore` flag isn’t evaluated. Instead, use the `--target` flag to define the targets that you want Code Analyzer to scan. `--target` accepts a comma-separated list of any combination of files, directories, positive patterns, and negations.
- Any `package.json` files with embedded ESLint configuration aren’t supported.
- If your configuration executes Typescript, make sure that your `tsconfig` file is added to the configuration under `parserOptions.project`. The `--tsconfig` flag can’t be used with `--eslintconfig` flag. For example:

  ```
  //.eslintrc.json
   "parseOptions": {
       "project": "/path/to/tsconfig.json"
   },
  ```

## ESlint Restrictions

ESLint usage in Code Analyzer has these restrictions.

- When `--eslintconfig` is provided, no other default ESLint engines run in Code Analyzer
- Rule filters such as `--category` and `--ruleset` aren’t evaluated on rules selected from an ESLint custom configuration
- Engine filters can be used with `--eslintconfig` flag. However, only the rules included in the config execute. PMD runs with the default set of rules, but `eslint-lwc` isn’t invoked. Instead, ESLint is invoked based on the configuration in `/path/to/.eslintrc.json`. For example:

  ```
  $ sf scanner run --engine pmd,eslint-lwc --eslintconfig /path/to/.eslintrc.json --target /target/path
  ```

## Authoring Custom ESLint Rules

Writing custom ESLint rules requires creating a custom ESLint plug-in and defining rules within it.ESLint rule definitions must contain documentation. Format your documentation like this:

```
// Rule definition in index.js or where you choose to store it
    meta: {
        docs: {
            description: "Information about the rule"
        },
		...
	}
```

After your rule is ready and tested, add it as a dependency to the `npm` setup in the same directory where Code Analyzer runs. Use the `npm` or `yarn` version of this command.

```
yarn add file:/path/to/ESLint-plugin-my-custom
npm install file:/path/to/ESLint-plugin-my-custom
```

After your rule is added, ensure that the `node_modules` directory:

- Has a child directory with your plug-in’s name
- Contains the `package.json`, `index.js`, and other files that you created

## Managing Custom ESLint Rules

Custom rules on ESLint are handled through Code Analyzer’s [ESLint Custom Configuration](https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/custom-configuration/eslint-config.md).

### Add Rules

To add your custom rules to a custom `.eslintrc.json` file, follow these steps.

1. Add your plug-in:

```
//.eslintrc.json
...
		"plugins": [
                "my-custom",
				... // Other required plugins
        ],
...
```

2. Add your rule:

```
//.eslintrc.json
...
		"rules": {
                "my-custom/my-new-rule": 1,
				... //Other rules
        },
...
```

3. Make sure that your directory has all the required npm dependencies, including ESLint, your custom rule plug-in, and any other applicable dependencies, such as parsers or processors.

### Run Rules

Execute the `scanner run` command in the directory with all the necessary npm dependencies. For example:

```
$ sf scanner run --eslintconfig /path/to/my/.eslintrc.json --target /path/to/target
```

## See Also

- [_ESLint_: Cascading and Hierarchy](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#cascading-and-hierarchy)
- [_ESLint_: Configure ESLint](https://eslint.org/docs/latest/user-guide/configuring/)
- [_ESLint_: Custom Rules](https://eslint.org/docs/latest/developer-guide/working-with-rules)
- [_ESLint_: Create Plugins](https://eslint.org/docs/latest/extend/plugins)
