ESLint is a linter for JavaScript, JSON and TypeScript.

You can enable the ESLint linter with:

trunk check enable eslint

Auto Enabling

ESLint will be auto-enabled if any of its config files are present: .eslintrc, .eslintrc.cjs, .eslintrc.js.


ESLint supports the following config files:

  • .eslintrc

  • .eslintrc.cjs

  • .eslintrc.js

  • .eslintrc.json

  • .eslintrc.mjs

  • .eslintrc.yaml

  • .eslintrc.yml

You can move these files to .trunk/configs and trunk check will still find them. See Moving Linter Configs for more info.

Usage Notes

Most ESLint users use a number of plugins, custom parsers, etc. Trunk has the ability to turn sandboxing and caching on or off for each linter, and we've turned it off for ESLint so it can use your repo's installed packages for ESLint plugins and other required ESLint packages. Trunk does control the ESLint version itself, but otherwise ESLint looks for all plugins, configs, etc. based on the path of source file it is linting. This all means you do need to have npm/yarn install'd in your repo as a prerequisite before running ESLint via trunk.

We recommend you disable all Prettier rules in your ESLint config and let Trunk run Prettier automatically on your files. It's much nicer to just autoformat a file than to see a lint error for every missing space.

You can easily do this by adding the eslint-config-prettier package and in your ESLint config's extends section adding prettier as the last element. For example, your extends list might look like:

  # Order matters, later configs purposefully override settings from earlier configs
  - eslint:recommended
  - airbnb
  - plugin:@typescript-eslint/recommended
  - plugin:import/recommended
  - plugin:import/typescript
  - plugin:node/recommended
  - plugin:mocha/recommended
  - plugin:react/recommended
  - prettier # this actually turns OFF all Prettier rules running via ESLint

Last updated