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

162
Vistas
ESLint shared configuration for all rules within a plugin

I've created a es lint plugin that provides me with a rule which checks that provided import is not in a dynamic list of blacklisted imports.

The list is loaded from a JSON file.

Currently I am loading this file in the create method of a rule, but the rule is being recreated for each file, which in turn makes the linter slow.

I've found the following text in the ESLint documentation, but no other mention of a way to share some global object within an invocation of the linter.

https://eslint.org/docs/latest/user-guide/configuring/configuration-files#adding-shared-settings

ESLint supports adding shared settings into configuration files. Plugins use settings to specify information that should be shared across all of its rules. You can add settings object to ESLint configuration file and it will be supplied to every rule being executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable.

Is this supported? I've tried exporting a settings object in the index.js of the plugin, but it is not being picked up at all.

module.exports.settings = {
    "sharedData": "Hello"
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Looks like I already have a workaround, but wondering if someone will come up with a better solution.

What I did in the end was to load the configuration in the index of the rule itself, which is loaded at the start of ESLint.

Instead of depending on context.getCwd() I've fallen back to _dirname. Which proved to be enough for my use case.

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