Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda