Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dlint has off-by-one reports #1201

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/dlint/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn print_compact(diagnostics: &[LintDiagnostic], filename: &str) {
eprintln!(
"{}: line {}, col {}, Error - {} ({})",
filename,
diagnostic.range.start.line_index + 1,
diagnostic.range.start.line_index,
diagnostic.range.start.column_index + 1,
diagnostic.message,
diagnostic.code
Expand Down Expand Up @@ -134,6 +134,8 @@ impl miette::SourceCode for MietteSourceCode<'_> {
end_line_column.line_index + context_lines_after,
self.source.text_str().len(),
);
eprintln!("start line column {:?}", start_line_column);
eprintln!("end line column {:?}", end_line_column);
let src_end = self
.source
.line_end(std::cmp::min(end_line_index, line_count - 1));
Expand Down
1 change: 1 addition & 0 deletions examples/dlint/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ mod tests {
pattern_match(pattern, s, "[WILDCARD]")
}

// TODO(bartlomieju): update to the current version in `deno` repo
fn pattern_match(pattern: &str, s: &str, wildcard: &str) -> bool {
// Normalize line endings
let mut s = s.replace("\r\n", "\n");
Expand Down
8 changes: 4 additions & 4 deletions examples/dlint/testdata/issue1145_no_trailing_newline.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ no-unused-vars

x `base` is never used
,-[issue1145_no_trailing_newline.ts:3:5]
3 | ---*/
4 | var base
2 | ---*/
3 | var base
: ^^|^
: `-- If this is intentional, prefix it with an underscore like `_base`
`----
Expand All @@ -13,8 +13,8 @@ no-var

x `var` keyword is not allowed.
,-[issue1145_no_trailing_newline.ts:3:1]
3 | ---*/
4 | var base
2 | ---*/
3 | var base
: ^^^^^^^^
`----
help: https://lint.deno.land/#no-var
Expand Down
Loading