Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Reading Wrong Eslint Config File For Mono Repo. #1519

Closed
4 tasks done
Huzaifa-Asif opened this issue Dec 7, 2023 · 1 comment
Closed
4 tasks done

[BUG] Reading Wrong Eslint Config File For Mono Repo. #1519

Huzaifa-Asif opened this issue Dec 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Huzaifa-Asif
Copy link

Huzaifa-Asif commented Dec 7, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

I get the following error message when my action is executed because action is reading service/lambda/bsp/.eslintrc.json file. It should read the eslint file present in the base directory. As i have 200 plus micro services so we can't create seperate eslint config for all of them. but some of the services have eslint config file and when change is made in those services that eslint file is read by action.

Action Config:

name: ESLint Changed Files

on:
  pull_request:
    types: [opened, synchronize, ready_for_review]
    branches:
      - 'sprint/**'

jobs:
  eslint-check:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x] # Define the Node.js version(s) you want the check to run on.
    
    steps:
    - name: Check out code
      uses: actions/checkout@v4
      with:
        ref: ${{ github.event.pull_request.head.sha }}
        fetch-depth: 0
      
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}

    - name: Install dependencies
      run: npm install eslint jest eslint-plugin-jest eslint-plugin-node

    - name: Action Configuration
      uses: tj-actions/eslint-changed-files@v21
      with:
        extra_args: "--fix"
        config_path: ".eslintrc.json"
        skip_annotations: true
        token: ${{ secrets.GITHUB_TOKEN }} # GitHub automatically creates a `GITHUB_TOKEN` secret to use in your workflow.
        file_extensions: |
          **/*.js
          **/*.jsx
          **/*.ts
          **/*.tsx

    - name: Verify Changed files
      if: ${{ ! cancelled() }}
      uses: tj-actions/verify-changed-files@v16
      id: verify-changed-files
      with:
        files: |
          **/*.{js,jsx,ts,tsx}

    - name: Commit outstanding changes
      if: ${{ ! cancelled() && steps.verify-changed-files.outputs.files_changed == 'true' }}
      run: |
        git config --local user.email "github-actions[bot]@users.noreply.github.com"
        git config --local user.name "github-actions[bot]"
        git add ${{ steps.verify-changed-files.outputs.changed_files }}
        git commit -m "refactor: lint fixes"

    - name: Push changes
      if: ${{ ! cancelled() && steps.verify-changed-files.outputs.files_changed == 'true' }}
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        branch: ${{ github.head_ref }}

Action Error

Resolving repository path: /home/runner/work/respond-io/respond-io/.
  Running ESlint on changed files...
  
  Oops! Something went wrong! :(
  
  ESLint: 8.55.0
  
  Error: service/lambda/bsp/.eslintrc.json:
  	Environment key "jest/globals" is unknown
  
      at /home/runner/work/respond-io/respond-io/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2079:23

To Reproduce

Create a microservice and add eslint config file in that as well, but point the eslint file present in base directory. then you will see that eslint is reading service config file.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-22.04

Expected behavior?

It should read base directory eslint not the service level eslint config and should not crash.

Relevant log output

Resolving repository path: /home/runner/work/respond-io/respond-io/.
  Running ESlint on changed files...
  
  Oops! Something went wrong! :(
  
  ESLint: 8.55.0
  
  Error: service/lambda/bsp/.eslintrc.json:
  	Environment key "jest/globals" is unknown
  
      at /home/runner/work/respond-io/respond-io/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2079:23

Has all relevant logs been included?

  • I've included all relevant logs

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Huzaifa-Asif Huzaifa-Asif added the bug Something isn't working label Dec 7, 2023
@jackton1
Copy link
Member

jackton1 commented Dec 9, 2023

Hi @Huzaifa-Asif, this appears to be a bug with eslint configuration system. I’ll suggest creating a bug ticket here.

Helpful Resources

If you are using one configuration file and want ESLint to ignore any .eslintrc.* files, make sure to use --no-eslintrc along with the --config flag.

@jackton1 jackton1 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants