betterer icon indicating copy to clipboard operation
betterer copied to clipboard

First code line in Editors is "1", but in betterer "0". Code navigation is not precise

Open Evilweed opened this issue 3 years ago • 1 comments

Describe the bug All code editors i've checked (Webstorm, Sublime, VS Code) count the code lines starting from number 1. Betterer reports display first line of code as 0. So there is one line difference between what we see in editor and what reporter reports.

To Reproduce

import { typescript } from '@betterer/typescript'

export default {
    'stricter typescript compilation': () =>
        typescript('tsconfig.json', {
            strict: true,
            noImplicitAny: true,
            strictNullChecks: true,
            strictFunctionTypes: true,
            strictPropertyInitialization: false,
            useDefineForClassFields: false,
        }).include('./test-file.ts'),
}

test-file.ts

function a1(b1) {
    console.error(b1)
}

function a2(b2) {
    console.error(b2)
}

function a3(b3) {
    console.error(b3)
}

Expected behavior Betterer should point to exact place of the issue, so that developers can use file.ts:<line_number> to go to editor straight to issue to fix it.

Screenshots CleanShot 2021-12-14 at 11 12 09@2x CleanShot 2021-12-14 at 11 13 35@2x

Versions (please complete the following information):

System:

  • OS: macOS 11.6
  • Memory: 20.64 MB / 16.00 GB

Binaries:

  • Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
  • Yarn: 1.22.17 - /usr/local/bin/yarn
  • npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm

Languages:

  • Bash: 3.2.57 - /bin/bash

Betterer:

  • 5.1.5

Evilweed avatar Dec 14 '21 10:12 Evilweed

As I deep dive into the code, the line and column is initially designed as zero-based index. If we change to 1-based index, it would cause breaking change I think.

image

phhien203 avatar Jan 30 '23 14:01 phhien203