stencil-eslint
stencil-eslint copied to clipboard
Throws error when a property does not have a type annotation.
When adding the plugin to my eslint extends:
"extends": [
"plugin:@stencil/recommended",
I started getting the following error:
Oops! Something went wrong! :(
ESLint: 7.11.0
TypeError: Cannot read property 'typeAnnotation' of undefined
Occurred while linting C:\MyOrg\MyProj\src\components\org-component\org-component.tsx:14
at getType (C:\MyOrg\MyProj\node_modules\@stencil\eslint-plugin\dist\index.js:65:32)
at ClassProperty > Decorator[expression.callee.name=Element] (C:\MyOrg\MyProj\node_modules\@stencil\eslint-plug
in\dist\index.js:439:37)
at C:\MyOrg\MyProj\node_modules\eslint\lib\linter\safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (C:\MyOrg\MyProj\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (C:\MyOrg\MyProj\node_modules\eslint\lib\linter\node-event-generator.js:254
:26)
at NodeEventGenerator.applySelectors (C:\MyOrg\MyProj\node_modules\eslint\lib\linter\node-event-generator.js:28
3:22)
at NodeEventGenerator.enterNode (C:\MyOrg\MyProj\node_modules\eslint\lib\linter\node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode (C:\MyOrg\MyProj\node_modules\eslint\lib\linter\code-path-analysis\code-path-anal
yzer.js:711:23)
at C:\MyOrg\MyProj\node_modules\eslint\lib\linter\linter.js:952:32
error Command failed with exit code 2.
The stacktrace pointed to my component, where I had a property with no type annotation:
@Component({
tag: 'org-component',
shadow: true,
})
export class OrgComponent implements ComponentWillLoad {
@Element() host;
Enabling TypeScript's noImplicitAny
and then adding a type annotation fixes this issue and lets the linter continue:
@Component({
tag: 'org-component',
shadow: true,
})
export class OrgComponent implements ComponentWillLoad {
@Element() host: HTMLOrgComponentElement;