Skip to content

Commit 5733f52

Browse files
authored
Merge pull request #11 from ai/nodots
remove dot after line number
2 parents b8bdbd8 + e6a273e commit 5733f52

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

lib/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ module.exports = (input, line, col) => {
2424

2525
// A little ugly, but we can handle line zero this way
2626
let frame = []
27-
if (line - 1 === 0) frame.push(' 0. |')
28-
else frame.push(` ${line - 1}.${pad} | ${start}`)
29-
frame.push(` > ${line}.${errorPad} | ${error}`)
30-
if (col !== -1) frame.push(` ${pad} | ${padLeft('^', col, ' ')}`)
31-
frame.push(` ${line + 1}. |`)
27+
if (line - 1 === 0) frame.push(' 0 |')
28+
else frame.push(` ${line - 1}${pad} | ${start}`)
29+
frame.push(` > ${line}${errorPad} | ${error}`)
30+
if (col !== -1) frame.push(` ${pad}| ${padLeft('^', col, ' ')}`)
31+
frame.push(` ${line + 1} |`)
3232

3333
return frame.join('\n')
3434
}

readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ const framer = require('code-frame')
1616
// col - int (optional)
1717

1818
framer('\nfunction (foo) {\n\tconsole.log(foo\n}', 3, 24)
19-
// 2. | function (foo) {
20-
// > 3. | console.log(foo
21-
// | ^
22-
// 4. |
19+
// 2 | function (foo) {
20+
// > 3 | console.log(foo
21+
// | ^
22+
// 4 |
2323

2424
// Without col
2525
framer('\n\n\tconsole.logfoo, bar)', 3)
26-
// 2. |
27-
// > 3. | console.logfoo, bar)
28-
// 4. |
26+
// 2 |
27+
// > 3 | console.logfoo, bar)
28+
// 4 |
2929
```
3030

3131
## License

test/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ const framer = require('..')
44
test('basic output', (t) => {
55
let error = framer('\nfunction (foo) {\n\tconsole.log(foo\n}', 3, 24)
66
let expected =
7-
' 2. | function (foo) {\n > 3. | \tconsole.log(foo\n | ^\n 4. |'
7+
' 2 | function (foo) {\n > 3 | \tconsole.log(foo\n | ^\n 4 |'
88
t.is(error, expected)
99
})
1010

1111
test('error at line 1', (t) => {
1212
let error = framer('function (foo, bar\n{\n\tconsole.log(foo, bar)\n}', 1, 19)
1313
let expected =
14-
' 0. |\n > 1. | function (foo, bar\n | ^\n 2. |'
14+
' 0 |\n > 1 | function (foo, bar\n | ^\n 2 |'
1515
t.is(error, expected)
1616
})
1717

1818
test('no col passed', (t) => {
1919
let error = framer('\n\n\tconsole.logfoo, bar)', 3)
2020
let expected =
21-
' 2. | \n > 3. | \tconsole.logfoo, bar)\n 4. |'
21+
' 2 | \n > 3 | \tconsole.logfoo, bar)\n 4 |'
2222
t.is(error, expected)
2323
})
2424

2525
test('non-matching numPad lengths (startPad)', (t) => {
2626
let error =
2727
framer('\n\n\n\n\n\n\n\nfunction(foo) {\n\tconsole.log(foo\n}', 10, 23)
2828
let expected =
29-
' 9. | function(foo) {\n > 10. | \tconsole.log(foo\n | ^\n 11. |'
29+
' 9 | function(foo) {\n > 10 | \tconsole.log(foo\n | ^\n 11 |'
3030
t.is(error, expected)
3131
})
3232

3333
test('non-matching numPad lengths (errorPad)', (t) => {
3434
let error =
3535
framer('\n\n\n\n\n\n\nfunction(foo) {\n\tconsole.log(foo\n}', 9, 23)
3636
let expected =
37-
' 8. | function(foo) {\n > 9. | \tconsole.log(foo\n | ^\n 10. |'
37+
' 8 | function(foo) {\n > 9 | \tconsole.log(foo\n | ^\n 10 |'
3838
t.is(error, expected)
3939
})

0 commit comments

Comments
 (0)