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

314
Vistas
Is it possible to ignore ESLint configuration files in certain, but not all, parent directories?

According to the ESLint documentation, when ESLint is run, it searches for configuration files in the current directory and all parent directories up to and including the root directory (/), the home directory, or a directory where the root: true option is specified in an ESLint configuration file.

Is it possible to configure ESLint to check for ESLint configuration files in certain parent directories, but not others?

To make things more concrete, take the example of the Drupal 9 based project that I am working on currently. The project tree has this general shape:

.
├── .eslintrc.js
├── node_modules
├── package-lock.json
├── package.json
└── web
    ├── .eslintrc.json
    └── modules
        └── custom
            └── some_module
                ├── .eslintrc.js
                ├── node_modules
                ├── package-lock.json
                └── package.json

As you can see, the project has an ESLint configuration file at the root of the repository, as many projects do, but there is also an ESLint configuration file in the some_module directory for settings which are specific to that module.

So far so good. However, Drupal 9 also distributes its own, internal ESLint configuration file in the web directory. That configuration file would be helpful if I were working on Drupal core, but I'm not. Nonetheless, its presence between the two ESLint configuration files that I actually care about interferes with my desired ESLint configuration and actually causes ESLint invocations from the root of the repository to fail.

Is it possible to configure ESLint to read the some_module/.eslintrc.js configuration file and the .eslintrc.js configuration file at the root of the repository, but ignore the web/.eslintrc.json in the middle?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After some research and thought, I realized that the extends keyword can help solve this problem. I ended up adding the following to the some_module/.eslintrc.js configuration file:

module.exports = {
  // Do not search for ESLint configuration files in parent directories because
  // Drupal 9 puts one in the *web* directory which we do not want applied.
  //
  // However, do manually extend from the ESLint configuration at the root of
  // this repository.
  root: true,
  extends: ["../../../../.eslintrc.js"],

  // [other ESlint configuration]
};

These two lines tell ESLint that it should not search for ESLint configuration files in parent directories of some_module, but that it should manually read and apply the ESLint configuration at the root of the repository, in effect skipping the web/.eslintrc.json configuration file altogether.

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