facebook / hermes

A JavaScript engine optimized for running React Native.

Home Page:https://hermesengine.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hermes eslint: No sourceCode in context

ayroblu opened this issue · comments

In ft-flow, there is this line:

node_modules/eslint-plugin-ft-flow/dist/rules/defineFlowType.js:75:44

      var newGetScope = context.sourceCode.getScope;

Which errors with:

TypeError: Cannot read properties of undefined (reading 'getScope')

Based on the error, it says while trying to lint this line:

import typeof Yargs from 'yargs';

If I switch to @babel/eslint-parser then it passes just fine, that's why I'm opening an issue in this repo, but it could also be a ft-flow issue

Looks like this issue was introduced in a recent change to ft-flow, i left a comment there flow-typed/eslint-plugin-ft-flow#50 but might be also worth opening a issue on that repo. No totally sure why @babel/eslint-parser doesn't have this issue, as far as i can tell hermes-eslint doesn't implement these API's, instead eslint does wrapped around the ScopeManager API which we return from parseForESLint. I'm not super familiar with the details though so happy to make changes if someone knows what the difference is cc @brianc118, but ill close for now since i believe there are no changes needed on the hermes eslint side.

@pieterv I'm guessing you meant to tag @Brianzchen?

yeah, sorry about that, i should have looked more closely at the autocomplete result.

@ayroblu I'll make the fixes as recommended but just curious what version of eslint are you on?

We are on eslint 7.32.0.

New error, gonna make a new issue