Support ESLint + Yarn 2 PnP
Eli Schleifer
I'm curious in trying out trunk in my setup and it works great! Except for the eslint formatter - since trunk uses packages installed under node_modules as per docs, it doesn't work if node_modules is not available (specifically when using yarn 2 PnP). I was wondering if there is a way make trunk and Yarn PnP get along.
I'm so far thinking of 3 possible ways to get it to work ad-hoc:
Installing the missing eslint packages through trunk (if supported)
Configuring the node environment somehow to hook into the PnP runtime
Creating a custom linter mimicking eslint but running it through yarn so that it's decoupled from trunk (IDK if there is a linter type available out of the box for this or if I'd have to use something like @microsoft/eslint-formatter-sarif to convert eslint's output to a compatible custom linter type for trunk)
If anyone has already tried this or if there are any tips on how to approach this I'd be grateful for the help! (edited)
vittorio monaco
Hi, this is an example for trunk 1.1.0
Use
trunk print-config
to check the all configurationthan copy the prettier configuration to customize the new formatter
Here an example in my trunk.yaml
lint:
definitions:
- name: eslintfmt # custom name
type: rewrite
files: # file list to execute the formatter
- typescript
- javascript
command:
- npx
- eslint
- --fix
- ${target}
success_codes:
- 0
batch: true
direct_configs: # Configuration Files
- .eslintrc
- .eslintrc.cjs
- .eslintrc.js
- .eslintrc.json
- .eslintrc.yaml
- .eslintrc.yml
enabled: true
formatter: true # Use this configuration as formatter
in_place: true
known_good_version: 8.10.0
package: eslint
plugin_url: https://slack.trunk.io
runtime: node
version_command:
parse_regex: ${semver}
run: npx eslint --version