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

Validation of namespaced import from 'lwc' throws an error #102

Open
ravijayaramappa opened this issue Sep 23, 2022 · 0 comments
Open

Validation of namespaced import from 'lwc' throws an error #102

ravijayaramappa opened this issue Sep 23, 2022 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@ravijayaramappa
Copy link
Contributor

Encountered a javascript exception while trying to save the following LWC component via SFDX.

import * as lwc from 'lwc';

export default class extends lwc.LightningElement {
    condition = true;
}
force-app/main/default/lwc/myComponent/myComponent.js  
bad result: TypeError: Cannot read property 'name' of undefinedOccurred while linting <text>:3Rule: "@lwc/lwc/no-deprecated"    at /home/sfdc/tools/lwc/240.1.2-2.20.5/node_modules/@lwc/eslint-plugin-lwc/lib/util/component.js:30:40    at Array.find (<anonymous>)    at isComponent (/home/sfdc/tools/lwc/240.1.2-2.20.5/node_modules/@lwc/eslint-plugin-lwc/lib/util/component.js:29:62)    at ClassDeclaration (/home/sfdc/tools/lwc/240.1.2-2.20.5/node_modules/@lwc/eslint-plugin-lwc/lib/rules/no-deprecated.js:64:22)    at ruleErrorHandler (/home/sfdc/tools/lwc/240.1.2-2.20.5/node_modules/eslint/lib/linter/linter.js:1114:28)    at /home/sfdc/tools/lwc/240.1.2-2.20.5/node_modules/eslint/lib/linter/safe-emitter.js:45:58    at Array.forEach (<anonymous>)

Although namespaces imports are not allowed from 'lwc' module, I wasn't expecting to get this exception. Instead, I expected the no-disallowed-lwc-imports.js to validate and block the save.

It is due to a bug in the implementation of isComponent util here https://github.com/salesforce/eslint-plugin-lwc/blob/master/lib/util/component.js#L29-L31

@ravijayaramappa ravijayaramappa added the kind/bug Categorizes issue or PR as related to a bug. label Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant