Skip to content

Eslint don't respect root: true if the directory name contains curly braces #14742

@phoenix741

Description

@phoenix741

The problem is that if

  • the directory contains curly brace (it is the case on our jenkins environment, because it is used to group job {PROJECT1}Job1, {PROJECT1}Job2, ...). So the directory will be /var/lib/jenkins/{PROJECT1}Job1/client ...
  • the glob using to select file file to include include curl brace like in nest.js : eslint "{src,apps,libs,test}/**/*.ts" --fix

Eslint will read all directory inside /var/lib/jenkins and execute eslint on other project/job inside this directory. If this project don't have node_modules, or if there is error, ... : our job crash.

Tell us about your environment

Node version: v14.15.1
npm version: v6.14.8
Local ESLint version: v7.29.0 (Currently used)
Global ESLint version: Not found
Operating System: linux 5.4.0-74-generic

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?

@typescript-eslint/parser

Please show your full configuration:

The problem appear when i use angular cli, nest.js cli or custom eslint configuration.

Configuration
module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint/eslint-plugin'],
  extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
  root: true,
  env: {
    node: true,
    jest: true,
  },
  ignorePatterns: ['.eslintrc.js'],
  rules: {
    '@typescript-eslint/interface-name-prefix': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
  },
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Exemple in the following code :
https://github.com/phoenix741/bug-eslint-curly-brace

cd topdirectory/\{test\}eslinterr/server
npm install
npx eslint '{src}/**/*.js'

Oops! Something went wrong! :(

ESLint: 7.29.0

Error: Failed to load parser '@typescript-eslint/parser' declared in '../client/.eslintrc.js': Cannot find module 'typescript'
Require stack:
- /tmp/topdirectory/{test}eslinterr/client/node_modules/@typescript-eslint/typescript-estree/dist/parser.js
- /tmp/topdirectory/{test}eslinterr/client/node_modules/@typescript-eslint/typescript-estree/dist/index.js
- /tmp/topdirectory/{test}eslinterr/client/node_modules/@typescript-eslint/parser/dist/parser.js
- /tmp/topdirectory/{test}eslinterr/client/node_modules/@typescript-eslint/parser/dist/index.js
- /tmp/topdirectory/{test}eslinterr/server/node_modules/@eslint/eslintrc/lib/config-array-factory.js
- /tmp/topdirectory/{test}eslinterr/server/node_modules/@eslint/eslintrc/lib/index.js
- /tmp/topdirectory/{test}eslinterr/server/node_modules/eslint/lib/cli-engine/cli-engine.js
- /tmp/topdirectory/{test}eslinterr/server/node_modules/eslint/lib/eslint/eslint.js
- /tmp/topdirectory/{test}eslinterr/server/node_modules/eslint/lib/eslint/index.js
- /tmp/topdirectory/{test}eslinterr/server/node_modules/eslint/lib/cli.js
- /tmp/topdirectory/{test}eslinterr/server/node_modules/eslint/bin/eslint.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (/tmp/topdirectory/{test}eslinterr/server/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/tmp/topdirectory/{test}eslinterr/client/node_modules/@typescript-eslint/typescript-estree/dist/parser.js:31:25)
    at Module._compile (/tmp/topdirectory/{test}eslinterr/server/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)

The error is on the client directory but i launch it in the server directory.

What did you expect to happen?

Eslint should be respect : root: true and shouldn't go in top directory

What actually happened? Please copy-paste the actual, raw output from ESLint.

❯ DEBUG=eslint:* npx eslint '{src}/**/*.js'
  eslint:cli CLI args: [ '{src}/**/*.js' ] +0ms
  eslint:cli Running on files +4ms
  eslint:file-enumerator Start to iterate files: [ '{src}/**/*.js' ] +0ms
  eslint:file-enumerator Glob: /tmp/topdirectory/{test}eslinterr/server/{src}/**/*.js +1ms
  eslint:file-enumerator recursive? true +5ms
  eslint:file-enumerator Enter the directory: /tmp/topdirectory +0ms
  eslint:file-enumerator Didn't match: .gitignore +5ms
  eslint:file-enumerator Enter the directory: /tmp/topdirectory/{test}eslinterr +0ms
  eslint:file-enumerator Enter the directory: /tmp/topdirectory/{test}eslinterr/client +1m
....
....

Steps to reproduce this issue:

  1. cd /tmp
  2. git clone https://github.com/phoenix741/bug-eslint-curly-brace
  3. cd topdirectory/{test}eslinterr/server
  4. npm i
  5. DEBUG=eslint:* npx eslint '{src}/**/*.js'

Like i don't install the client part i have the error :

  eslint:cli CLI args: [ '{src}/**/*.js' ] +0ms
  eslint:cli Running on files +5ms
  eslint:file-enumerator Start to iterate files: [ '{src}/**/*.js' ] +0ms
  eslint:file-enumerator Glob: /tmp/topdirectory/{test}eslinterr/server/{src}/**/*.js +1ms
  eslint:file-enumerator recursive? true +4ms
  eslint:file-enumerator Enter the directory: /tmp/topdirectory +0ms
  eslint:file-enumerator Didn't match: .gitignore +7ms
  eslint:file-enumerator Enter the directory: /tmp/topdirectory/{test}eslinterr +0ms
  eslint:file-enumerator Enter the directory: /tmp/topdirectory/{test}eslinterr/client +1ms

Oops! Something went wrong! :(

ESLint: 7.29.0

ESLint couldn't find the config "airbnb-base" to extend from. Please check that the name of the config is correct.

The config "airbnb-base" was referenced from the config file in "/tmp/topdirectory/{test}eslinterr/client/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Are you willing to submit a pull request to fix this bug?

No, Sorry

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyrepro:yesIssues with a reproducible example

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions