overridden BasicTemplateAstVisitor.visitEvent() doesn't visit all events
まだ誰も着手していません。
評価
- 難易度
- 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 ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 ·
メンテナーはふだん 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 日以内に返信