Deep dive eslint

Lessons I learned from debugging eslint issues

Lessons I learned from debugging eslint issues

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.

"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.

Last updated