stencil-eslint icon indicating copy to clipboard operation
stencil-eslint copied to clipboard

bug: Console error Cannot read properties of null (reading 'getTypeChecker')

Open James-Wilkinson-git opened this issue 1 year ago • 4 comments

Prerequisites

Stencil ESLint Version

^0.7.1

Current Behavior

After installing eslint and the plugin for stencil lint then running on the files the console errors

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Error while loading rule '@stencil-community/async-methods': Cannot read properties of null (reading 'getTypeChecker')

Expected Behavior

The linter should run

Steps to Reproduce

Install a new eslint and eslint stencil into your project

Code Reproduction URL

n/a

Additional Information

No response

James-Wilkinson-git avatar Feb 08 '24 13:02 James-Wilkinson-git

Same with older versions (tested at 0.6.0). Eslint 8.51.0, node 18.17.1.

certainlyakey avatar Mar 09 '24 22:03 certainlyakey

We are facing the same problem. Are there any updates or workarounds?

Lunarion avatar May 31 '24 08:05 Lunarion

Also running into this one with eslint 8.56.0.

Edit: Adding some more detail. It looks like this error kicks in on eslint 8.45.0

Edit again: Stencil is expecting typed rules to be on https://typescript-eslint.io/developers/custom-rules/#typed-rules

The error comes from services.program.getTypeChecker, but program is null if type checking is turned off.

I had a look around and it seemed that eslint was not picking up my tsconfig so type checking was turned off, breaking stencil.

I had a peek at these release notes https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/

Then added

"parserOptions": {
    "project": "./tsconfig.json"
  }

to my .eslintrc.json, which seems to have fixed the issue. :rocket:

Hope that helps someone!

gavmck avatar Jul 16 '24 08:07 gavmck

Had the same issue, and resolved it in our monorepo by adding

"parser": "@typescript-eslint/parser",
    "parserOptions": {
        "project": "./tsconfig.json"
    },

We're doing the "one tsconfig per package" method in our monorepo. See typescript-eslint monorepo configuration

ogdakke avatar Oct 18 '24 08:10 ogdakke