overridden BasicTemplateAstVisitor.visitEvent() doesn't visit all events
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- angular, typescript
Hướng nghiên cứu
Bắt đầu với codelyzer/angular/templates/basicTemplateAstVisitor và so sánh hành vi visitEvent của nó với bananaInBoxRule.ts. Tái hiện vấn đề bằng EventLoggerTemplateVisitor được cung cấp và ng lint trên các template Angular 6 có chứa các trình xử lý EventEmitter. Hoàn tất khi tất cả các sự kiện template liên quan đều được truy cập nhất quán, không còn các trường hợp bị bỏ sót được báo cáo hoặc các lần truy cập trùng lặp không thể giải thích.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 2.5k
- Fork
- 232
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của mgechev/codelyzer
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 32/100
-
Angular 14Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
Support for Angular 10Có thể đã có người làm @ccarmesin đã nhận 1842 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Tất cả issue của mgechev/codelyzer
Issue tương tự
-
clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster maturity:stable P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openclaw/openclaw#200937 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accepted bug needs-info triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
zts212653/clowder-ai#2025 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
letehaha/moneymatter#906 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
blinkospace/blinko#1287 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Feyisara2108/stellargive#1379 ·
Maintainer thường phản hồi trong vòng 1 ngày