Column numbers are off by one when codelyzer reports errors in template files
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/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
- Lĩnh vực
- tooling
Hướng nghiên cứu
Tái hiện các chẩn đoán với tslint.json, app.component.ts và app.component.html bằng cách sử dụng các rule template-no-any và template-banana-in-box được liệt kê. So sánh các vị trí được báo cáo với các cột mong đợi 3:19 và 4:16, bao gồm cả trường hợp một phần tử bắt đầu một dòng; hoàn thành nghĩa là các lỗi external-template xác định chính xác phần tử cú pháp gây lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- 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ự
-
agent-ready area: ui-server priority: p3 type: test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
schlessera/brain-kit#4249 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation tool triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
can1357/oh-my-pi#19608 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dependencies tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
bcgov/nr-waste-plus#1549 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
blixvip/solana-token-meta#17 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
blixvip/solana-tx-parse#18 ·