overridden BasicTemplateAstVisitor.visitEvent() doesn't visit all events
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- angular, typescript
调研方向
从 codelyzer/angular/templates/basicTemplateAstVisitor 开始,并将其 visitEvent 行为与 bananaInBoxRule.ts 进行比较。使用提供的 EventLoggerTemplateVisitor 和 ng lint,在包含 EventEmitter 处理程序的 Angular 6 模板中重现该问题。当所有相关模板事件都能一致地被访问,且不存在报告中的遗漏或无法解释的重复访问时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
What I'm trying to do: Write a custom rule that enforces event handler naming consistency, by copying and modifying the code from banana-in-box.
Problem: The custom rule is not visiting most Angular template events, by which I mean bindings like (event)="handler()".
Minimal example: I've stripped away all the functionality in this rule except for logging the visited event's name (this is the entire TypeScript source file):
import * as ast from '@angular/compiler';
import { NgWalker } from 'codelyzer/angular/ngWalker';
import { BasicTemplateAstVisitor } from 'codelyzer/angular/templates/basicTemplateAstVisitor';
import * as Lint from 'tslint';
import * as ts from 'typescript';
class EventLoggerTemplateVisitor extends BasicTemplateAstVisitor {
public visitEvent(eventProperty: ast.BoundEventAst, context: BasicTemplateAstVisitor): any {
console.log(eventProperty.name);
super.visitEvent(eventProperty, context);
}
}
export class Rule extends Lint.Rules.AbstractRule {
public static metadata: Lint.IRuleMetadata = {
ruleName: 'event-visitor-logger',
type: 'functionality',
description: 'Dummy "rule" that just logs all the events it visits.',
rationale: 'Debugging',
options: null,
optionsDescription: 'Not configurable.',
typescriptOnly: true,
hasFix: false
};
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(
new NgWalker(sourceFile, this.getOptions(), {
templateVisitorCtrl: EventLoggerTemplateVisitor
})
);
}
}
Output:
$ ng lint
click
click
click
click
click
mouseenter
click
submit
click
click
click
click
click
click
click
click
click
click
click
click
click
mouseenter
click
submit
click
click
click
click
click
click
click
click
(Actually, it looks like the events being visited are being visited twice each for whatever reason. Don't know if that's relevant, so I left the duplicate output in there just in case.)
Expected Output: We have many EventEmitter handlers defined in our templates, and none of them show up in this output. Furthermore, our project has 227 (click) handlers defined, and the output above doesn't list anywhere close to that many.
Further troubleshooting: I created another temporary custom rule by copying banana-in-box itself, renaming it to just banana, and adding the same console.log(). I get the same exact output from both of these test rules. In addition, I purposely "put a box inside a banana" and it's not being reported (both banana-in-box and this temporary banana are configured as true).
** Versions:**
Angular 6 and Codelyzer 4.4.2.
"devDependencies": {
"@angular-devkit/build-angular": "~0.7.0",
"@angular/cli": "6.1.5",
"@angular/compiler-cli": "6.1.7",
"@angular/language-service": "6.1.7",
"@angular/platform-server": "6.1.7",
"@types/jest": "22.2.3",
"@types/marked": "0.3.0",
"@types/node": "~6.0.60",
"@types/pdfjs-dist": "^0.1.2",
"@types/video.js": "6.2.9",
"codelyzer": "4.4.2",
"http-server": "^0.11.1",
"jasmine-spec-reporter": "~4.2.1",
"jest": "23.1.0",
"jest-preset-angular": "5.2.1",
"ngrx-store-freeze": "^0.2.3",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"tslint-consistent-codestyle": "~1.13.1",
"typescript": "2.9.2",
"webpack-bundle-analyzer": "^2.11.3"
}
Any ideas? Thanks!
- Ed
- 主要语言
- TypeScript
- 星标
- 2.5k
- 派生
- 232
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mgechev/codelyzer 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 32/100
-
Angular 14未关闭
难度 2/5 1-3 小时 新手友好度 35/100
-
Support for Angular 10可能已有人在做 @ccarmesin 于 1842 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 25/100
查看 mgechev/codelyzer 的全部 Issue
相似的 Issue
-
clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster maturity:stable P3
难度 2/5 1-3 小时 新手友好度 72/100
openclaw/openclaw#200937 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
accepted bug needs-info triaged
难度 2/5 1-3 小时 新手友好度 76/100
zts212653/clowder-ai#2025 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
letehaha/moneymatter#906 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
blinkospace/blinko#1287 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
Feyisara2108/stellargive#1379 ·
维护者通常 1 天内回复