Fix ESLint on CI - cannot extend airbnb-base

Created on 4 April 2024, 3 months ago
Updated 12 April 2024, 2 months ago

Problem/Motivation

When running tests on CI, the ESLint check fails, as in https://git.drupalcode.org/project/g2/-/pipelines/137660

However, locally, the ESLint check passes.

Steps to reproduce

Run any MR on Gitlab. The log has

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 "/builds/project/g2/web/modules/custom/g2/js/.eslintrc.json".

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

None expected.

API changes

None expected.

Data model changes

None expected.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France fgm Paris, France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @fgm
  • First commit to issue fork.
  • Merge request !14Draft: Issue #3438413: Fix ESLINT → (Open) created by jonathan1055
  • Pipeline finished with Success
    3 months ago
    Total: 131s
    #137683
  • Pipeline finished with Success
    3 months ago
    Total: 165s
    #137697
  • Pipeline finished with Success
    3 months ago
    Total: 165s
    #137713
  • Pipeline finished with Success
    3 months ago
    Total: 170s
    #137728
  • Pipeline finished with Success
    3 months ago
    Total: 132s
    #138444
  • 🇬🇧United Kingdom jonathan1055

    The gitlab issue to fix this is #3438843: Problem with eslint extends

    Just a querstion. You have

      "extends": [
        "../../../../core/.eslintrc.json",
        "airbnb-base",
        "airbnb-typescript/base",
        "prettier"
      ]
    

    But the core config file core/.eslintrc.json already extends "airbnb-base" so do you really need to include it too?
    That wouldn't fix the overall problem, but I'm just curious, that's all.

  • 🇫🇷France fgm Paris, France

    I just checked without it and got this:

    
    Oops! Something went wrong! :(
    
    ESLint: 8.45.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 "/web/core/.eslintrc.json".
    
    If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
    
  • 🇬🇧United Kingdom jonathan1055

    Yes it's exactly the same error. This will not be fixed in #3438843: Problem with eslint extends as it's a bigger problem. I have already created a new issue #3438843: Problem with eslint extends to investiagte it. Do you know the mechanism by which the core eslint loads airbnb-base? I presume it is from a /vendor and I know how 'extends' works when you give a path to a file. But I don't know how a pre-built pre-defined config is "found". I'm sure it is simple, I've just not had cause to research it until now.

  • Pipeline finished with Success
    3 months ago
    Total: 137s
    #140062
  • Pipeline finished with Success
    3 months ago
    Total: 132s
    #140069
  • 🇪🇸Spain fjgarlin

    Do you know the mechanism by which the core eslint loads airbnb-base?

    The core/.eslintrc.json file uses it via "extends". The library is brought via yarn, see the entry for eslint-config-airbnb-base in core/package.json here: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/package.json#L66

    We are doing yarn install in the .composer-base job, so it should be available and found.

  • Pipeline finished with Success
    3 months ago
    Total: 132s
    #143012
  • 🇬🇧United Kingdom jonathan1055

    In #5 fgm said

    I just checked without it ...

    Do you mean without the projects .eslintrc.json file? I tried that in an earlier commit in the MR and the job ran (but gave warnings of course). But the message you give above is "The config airbnb-base was referenced from the config file in /web/core/.eslintrc.json" I did not get this error when I removed .eslintrc.json file. So I just want to check what we are looking at here.

  • 🇫🇷France fgm Paris, France

    To clarify, I meant "without the airbnb-base" line in the project .eslintrc.json, not "without the project .eslintrc.json".

  • 🇬🇧United Kingdom jonathan1055

    Thanks that's helpful. It would imply that the airbnb config is not being installed in your pipelines, regardless of whether you have it in your custom config file. That does not help you, but it does mean that hopefully ew do not have something fundamentally wrong with our eslint job. I can test that hypothesis on another project.

  • 🇬🇧United Kingdom jonathan1055

    But we also have a discrepancy, as I thought I had tested it without the extends. This commit in the MR
    https://git.drupalcode.org/project/g2/-/merge_requests/14/diffs?commit_i...
    produced this job
    https://git.drupalcode.org/issue/g2-3438413/-/jobs/1241595
    It did not fail on the airbnb-base problem.

  • 🇫🇷France fgm Paris, France

    Right, that one failed on '@typescript-eslint/parser instead. Not necessarily better, but at least different.

  • 🇫🇷France fgm Paris, France

    I did a few changes, so here's patch3438413-13.patch : I don't know how to handle multiple contributors with the MR flow.

  • 🇪🇸Spain fjgarlin

    I think that as long as you don't work on the same file as Jonathan (.gitlab-ci.yml file), you should be fine committing/pushing changes to the branch of the MR. You'll just need to click on "Get push access" and then follow the instructions in "Show commands" to get the branch locally.

  • 🇬🇧United Kingdom jonathan1055

    I am not currently working on this so there should not be any clashes. I can do investigation on other projects to help with #3432261: Eslint on contrib is making incorrect recommendations If/when I want to make a further change to .gitlab-ci.yml I will check back here with you first.

  • 🇫🇷France fgm Paris, France

    Strangely enough this morning the pipeline on an unrelated MR passed the ESLint step. Were there changes in CI ? https://git.drupalcode.org/project/g2/-/jobs/1309927

Production build 0.69.0 2024