Column numbers are off by one when codelyzer reports errors in template files
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- angular, typescript
- 領域
- tooling
調査の方向性
指定された template-no-any ルールと template-banana-in-box ルールを使用して、tslint.json、app.component.ts、app.component.html で診断結果を再現します。報告された位置を期待される列 3:19 および 4:16 と比較し、要素が行の先頭から始まる場合も含めます。外部テンプレートのエラーが問題のある構文要素を正確に特定できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
Column numbers are off by one when codelyzer reports errors in template files (works fine in inline templates).
With an inline template, errors are reported at the syntax element causing the error:

$ node_modules/.bin/tslint src/app/app.component.ts
ERROR: src/app/app.component.ts:8:29 - Avoid using '$any' in templates
ERROR: src/app/app.component.ts:9:26 - Invalid binding syntax. Use [(expr)] instead
If we replace inline (template) with file (templateUrl), errors are reported one character to the left of the element causing the error:

$ node_modules/.bin/tslint src/app/app.component.ts
ERROR: src/app/app.component.html:3:18 - Avoid using '$any' in templates
ERROR: src/app/app.component.html:4:15 - Invalid binding syntax. Use [(expr)] instead
If we move the element causing the error to the start of the line:
<div>
<h1>
Welcome to {{
$any(title) }}!
</h1>
</div>
The error is actually reported on the previous line:
$ node_modules/.bin/tslint src/app/app.component.ts
ERROR: src/app/app.component.html:3:18 - Avoid using '$any' in templates
I haven't checked all rules that report errors in templates, but it seems to affect most of them (see example with template-no-any and template-banana-in-box below, also reproducible with template-acessibility- rules).
This is probably a non-issue when using codelyzer via the CLI, but would be relevant for editor integrations where it is important to highlight the correct element (I'm trying to extend Intellij IDEA's tslint support to include codelyzer errors, but I'm not sure if it will ultimately work).
So feel free to take this into account when deciding the issue's priority...
To Reproduce
To reproduce, create a new Angular project (either via Angular CLI or manually) with the tslint.json, app.component.ts and app.component.html files below, then invoke node_modules/.bin/tslint app.component.ts
Code
tslint.json
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"template-no-any": true,
"template-banana-in-box": true
}
}
app.component.ts
import {Component} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'codelyzer-offsets-bug';
fontSizePx: any;
}
app.component.html
<div>
<h1>
Welcome to {{ $any(title) }}!
<app-sizer ([size])="fontSizePx"></app-sizer>
</h1>
</div>
Expected behavior
For the example code above, the expected behavior would be to have template-no-any report an error at 3:19 (actually reported at 3:18), template-banana-in-box error at 4:16 (actually reported at 4:15).
Environment
- Version [e.g. 22]: 5.1.0
- OS: [e.g. iOS]: macOS
- Node.js version: 10.5.0
- Package manager (yarn/npm) version: npm v.6.4.1
- Angular version: 8.1.2
- tslint version: 5.18
- 主要言語
- 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
-
agent-ready area: ui-server priority: p3 type: test
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
schlessera/brain-kit#4249 ·
メンテナーはふだん 1 日以内に返信
-
documentation tool triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
can1357/oh-my-pi#19608 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
dependencies tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
bcgov/nr-waste-plus#1549 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
blixvip/solana-token-meta#17 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
blixvip/solana-tx-parse#18 ·