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: Cannot read properties of undefined (reading 'ignores') #18094

Closed
1 task
FirelightFlagboy opened this issue Feb 8, 2024 · 6 comments
Closed
1 task

Bug: Cannot read properties of undefined (reading 'ignores') #18094

FirelightFlagboy opened this issue Feb 8, 2024 · 6 comments
Labels
bug ESLint is working incorrectly needs info Not enough information has been provided to triage this issue repro:needed

Comments

@FirelightFlagboy
Copy link

FirelightFlagboy commented Feb 8, 2024

Environment

Node version: v16.20.2
npm version: v8.19.4
Local ESLint version: v8.56.0 (Currently used)
Global ESLint version: Not found
Operating System: linux 6.7.3-arch1-2

What parser are you using?

@typescript-eslint/parser

What did you do?

Configuration

eslint.config.js:

const typescript_plugin = require('@typescript-eslint/eslint-plugin')
const typescript_parser = require('@typescript-eslint/parser')

module.exports = [
  {
    plugins: {
      typescript_plugin
    },
    languageOptions: {
      parser: typescript_parser
    },
    ignores: [],
    rules: {}
  },
  // extends ...
  typescript_plugin.configs.eslint_recommended
]

package.json:

{
  "name": "[redacted]",
  "version": "0.0.1",
  "engines": {
    "node": "16.17"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^12.0.2",
    "@angular/cdk": "^12.0.2",
    "@angular/common": "^12.0.2",
    "@angular/compiler": "^12.0.2",
    "@angular/core": "^12.0.2",
    "@angular/forms": "^12.0.2",
    "@angular/material": "^12.0.2",
    "@angular/platform-browser": "^12.0.2",
    "@angular/platform-browser-dynamic": "^12.0.2",
    "@angular/router": "^12.0.2",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "@stripe/stripe-js": "^1.15.0",
    "bootstrap": "^4.6.0",
    "core-js": "^3.13.1",
    "express": "^4.17.1",
    "force-ssl-heroku": "^1.0.2",
    "google-libphonenumber": "^3.2.21",
    "latest-version": "^5.1.0",
    "ng-recaptcha": "^8.0.0",
    "ng2-pdf-viewer": "6.4.1",
    "ngx-stripe": "^12.0.1",
    "path": "^0.12.7",
    "rxjs": "^6.6.7",
    "tslib": "^2.2.0",
    "zone.js": "^0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^12.0.2",
    "@angular/cli": "^12.0.2",
    "@angular/compiler-cli": "^12.0.2",
    "@angular/language-service": "^12.0.2",
    "@eslint/eslintrc": "^3.0.0",
    "@types/jasmine": "^3.7.6",
    "@types/jasminewd2": "^2.0.9",
    "@types/node": "^12.20.13",
    "@typescript-eslint/eslint-plugin": "^6.21.0",
    "@typescript-eslint/parser": "^6.21.0",
    "codelyzer": "^6.0.2",
    "eslint": "^8.56.0",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "^6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.7.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.7.0",
    "typescript": "^4.2.4"
  }
}

No code involved, eslint crash at the startup.

eslint is executed with npx eslint .

What did you expect to happen?

That eslint lint the repository without crashing 😅

What actually happened?


Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Cannot read properties of undefined (reading 'ignores')
    at FlatConfigArray.get ignores [as ignores] ([redacted]/node_modules/@humanwhocodes/config-array/api.js:648:15)
    at FlatConfigArray.isDirectoryIgnored ([redacted]/node_modules/@humanwhocodes/config-array/api.js:1012:10)
    at FlatConfigArray.getConfig ([redacted]/node_modules/@humanwhocodes/config-array/api.js:806:12)
    at FlatConfigArray.isFileIgnored ([redacted]/node_modules/@humanwhocodes/config-array/api.js:962:15)
    at [redacted]/node_modules/eslint/lib/eslint/eslint-helpers.js:312:49
    at Array.reduce (<anonymous>)
    at entryFilter ([redacted]/node_modules/eslint/lib/eslint/eslint-helpers.js:299:28)
    at Object.isAppliedFilter ([redacted]/node_modules/@nodelib/fs.walk/out/readers/common.js:12:31)
    at AsyncReader._handleEntry ([redacted]/node_modules/@nodelib/fs.walk/out/readers/async.js:86:20)
    at [redacted]/node_modules/@nodelib/fs.walk/out/readers/async.js:65:22

Link to Minimal Reproducible Example

https://github.com/FirelightFlagboy/eslint-cannot-read-property-of-undefined-reading-ignores

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@FirelightFlagboy FirelightFlagboy added bug ESLint is working incorrectly repro:needed labels Feb 8, 2024
@mdjermanovic
Copy link
Member

typescript_plugin.configs.eslint_recommended

Can you check what the value of typescript_plugin.configs.eslint_recommended is? It could be that @typescript-eslint/eslint-plugin doesn't export a config named eslint_recommended, in which case this would be undefined.

@mdjermanovic mdjermanovic added the needs info Not enough information has been provided to triage this issue label Feb 8, 2024
@FirelightFlagboy
Copy link
Author

The value of typescript_plugin.configs.eslint_recommended should be:

"use strict";
module.exports = {
    overrides: [
        {
            files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
            rules: {
                'constructor-super': 'off', // ts(2335) & ts(2377)
                'getter-return': 'off', // ts(2378)
                'no-const-assign': 'off', // ts(2588)
                'no-dupe-args': 'off', // ts(2300)
                'no-dupe-class-members': 'off', // ts(2393) & ts(2300)
                'no-dupe-keys': 'off', // ts(1117)
                'no-func-assign': 'off', // ts(2630)
                'no-import-assign': 'off', // ts(2632) & ts(2540)
                'no-new-symbol': 'off', // ts(7009)
                'no-obj-calls': 'off', // ts(2349)
                'no-redeclare': 'off', // ts(2451)
                'no-setter-return': 'off', // ts(2408)
                'no-this-before-super': 'off', // ts(2376) & ts(17009)
                'no-undef': 'off', // ts(2304) & ts(2552)
                'no-unreachable': 'off', // ts(7027)
                'no-unsafe-negation': 'off', // ts(2365) & ts(2322) & ts(2358)
                'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
                'prefer-const': 'error', // ts provides better types with const
                'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
                'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
            },
        },
    ],
};
//# sourceMappingURL=eslint-recommended.js.map

I've extract the value from node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js

@snitin315
Copy link
Contributor

@FirelightFlagboy As per typescript-eslint/typescript-eslint#7935 (comment), you can't use '@typescript-eslint/eslint-plugin' for flat config, there is a different package typescript-eslint. The new usage is mentioned in this doc

If that still doesn't work for you, can you open an issue in typescript-eslint repo instead?

@snitin315 snitin315 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2024
@eslint-github-bot
Copy link

It looks like there wasn't enough information for us to know how to help you, so we're closing the issue.

Thanks for your understanding.

@G-Rath
Copy link
Contributor

G-Rath commented Mar 29, 2024

It could be that @typescript-eslint/eslint-plugin doesn't export a config named eslint_recommended, in which case this would be undefined.

I came across this while testing some eslint-plugin-jest stuff for our next major, because we removed our flat/snapshot config - it took me a few minutes to track down what was happening and seems a bit surprising; I know in flat config ESLint can't say for sure this is the case, but I think it would be nice if there could be an explicit undefined check so we get a more helpful "hey you've provided undefined which is never valid; are you maybe trying to use a config that doesn't exist?" type message rather than a generic property access (which is also implementation dependent - right now it happens to be ignores but in future ESLint might do something before that section of code, changing the error message).

I'm happy to open an issue and even attempt a PR if people think that would be a good idea.

@mdjermanovic
Copy link
Member

@G-Rath that sounds like a good idea to me. Can you open an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ESLint is working incorrectly needs info Not enough information has been provided to triage this issue repro:needed
Projects
Archived in project
Development

No branches or pull requests

4 participants