> For the complete documentation index, see [llms.txt](https://notes.lirenxn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.lirenxn.com/featured/deep-dive-eslint.md).

# Deep dive eslint

Lessons I learned from debugging eslint issues

### Lessons I learned from debugging eslint issues

1. [**eslint** with class property -- How **babel-eslint** work with **eslint**](/featured/deep-dive-eslint/eslint-with-class-property.md)&#x20;
2. [**eslint** with **fix** -- pitfall with `CLIEngine()`](/featured/deep-dive-eslint/eslint-with-fix.md)
3. [**eslint** with **jsx**](/featured/deep-dive-eslint/eslint-with-jsx.md)

### Tips:

#### eslint and babel-loader

**babel-eslint <= v10.x** parses the code with a set of default opts, **without** being able to access the project's `.babalrc` config file.

Tricky part is, its github default page for `babel-eslint` is actually for **UNRELEASED v11.x**, in which a new config field `parserOption.babelOptions` is added. With `babel` changed to a peerDep and external parse config.

> This ensures that the same Babel configuration is used during both linting and compilation.

```javascript
"parserOptions":{
  "babelOptions":{
    "configFile": "PATH_TO_CONFIG"
  }
}
```

#### Programmatically linting (in custom cli)

`eslint` have a `CliEngine` which loads the cli options. `--print-config` will trigger `engine.getConfigForFile(PATH_TO_SINGLE_FILE)` to load the config for single file. Cos the config can vary for different type of files, you need to specify single file here.

**vscode eslint extension**

> **The extension uses the ESLint library installed in the opened workspace folder. If the folder doesn't provide one the extension looks for a global install version.**
