salesforce / eslint-plugin-lwc

Official ESLint rules for LWC
MIT License
98 stars 32 forks source link

fix: fix named variable/function exports #92

Closed nolanlawson closed 2 years ago

nolanlawson commented 2 years ago

When trying to release into eslint-config-lwc, I noticed a bug in the no-disallowed-lwc-imports rule. It fails on code like this:

export function foo() {}
export const foo = 'foo'

This throws TypeError: Cannot read properties of null (reading 'type') at this line:

https://github.com/salesforce/eslint-plugin-lwc/blob/6128fbe36a262b12a8e66d9d3d2a2a902ea4afde/lib/rules/no-disallowed-lwc-imports.js#L37

The problem is that we weren't distinguishing these usages from exports like export { foo } from 'lwc'.

This PR fixes that.