Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
Forking core eslint rules

I want to do some minor edits to core eslint rules, e.g. array-bracket-newline, or indent. These rules often depend on utilities inside eslint, most commonly ast-utils. So far, i've used a plugin, added the modified rules there, and did a require('eslint/lib/rules/utils/ast-utils'), as eslint is a peer-dependency anyways.

Since https://github.com/eslint/eslint/commit/24c9f2ac57efcd699ca69695c82e51ce5742df7b this is no longer possible, as an exports directive was added to the package.json. What is the usual method for changing behavior of core eslint rules nowadays?

  • copying out all dependencies would be possible, but both tedious, and duplicating code for no reason (i'd have to trace all the dependencies, and rip out chunks of eslint's code).
  • forking eslint as a whole seems unclean, as there are a lot of other parts, which depend on it (starting from eslint-plugins, over to vscode extensions, yarn sdks, ...). Each one would need to be changed, or some very dirty rename used, in which the fork pretends to be the original (accident waiting to happen).
  • yarn package patching the exports away seems really dirty.

Is there some clean way?


Edit: my current best idea is forking eslint, removing the exports, and then using require('eslint-fork/lib/rules/utils/ast-utils') on the fork. This means i need an extra eslint copy for no real reason, but it's for linting, and a bit of disk space isn't important.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It is possible to require unexported files by their full path, i.e.:

const { dirname, join } = require('path');
const astUtilsPath = join(dirname(require.resolve('eslint')), 'rules/utils/ast-utils.js');
const astUtils = require(astUtilsPath);

Note that this method relies on the main export being located in a particular package folder ('lib' in the case of eslint).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!