Skip to content

Commit 601eaf7

Browse files
committed
shiritori: lint
1 parent bf90ac2 commit 601eaf7

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

functions/shiritori/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class Bad extends Error {}
3030
exports.Bad = Bad
3131

3232
// https://github.com/hexenq/kuroshiro/issues/64
33-
async function toHiragana(word) {
33+
async function toHiragana (word) {
3434
const hira = await kuroshiro.convert(word, { to: 'hiragana' })
3535
return wanakana.toHiragana(hira)
3636
}
3737

3838
// しりとりのルールのチェック。
3939
exports.check = (word, chain) => loaded.then(async () => {
40-
//「ん」で終わるかどうか?
40+
// 「ん」で終わるかどうか?
4141
const wordHira = await toHiragana(word)
4242
if (wordHira[wordHira.length - 1] === 'ん') {
4343
throw new Bad('ends with ん')

functions/shiritori/main.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ console.log(chain[0])
3232
rl.prompt()
3333
rl.on('line', input => {
3434
shiritori.interact(
35-
kana => Promise.resolve(corpus[kana]),
36-
input,
37-
chain
35+
kana => Promise.resolve(corpus[kana]),
36+
input,
37+
chain
3838
).then(result => {
3939
console.log(`${result.word} [${result.kana}]`)
4040
chain.unshift(input)
@@ -45,11 +45,9 @@ rl.on('line', input => {
4545
case shiritori.Win:
4646
console.log('すごい!')
4747
process.exit(0)
48-
break
4948
case shiritori.Bad:
5049
console.log('ざんねん。')
5150
process.exit(-1)
52-
break
5351
default:
5452
throw reason
5553
}

functions/shiritori/test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ test('check: shiritori', async t => {
2121

2222
test('check: ends with ん', async t => {
2323
await t.throwsAsync(shiritori.check('とん', ['べんと']),
24-
//)
24+
//)
2525
await t.throwsAsync(shiritori.check('トン', ['べんと']),
26-
//)
26+
//)
2727
})
2828

2929
test('check: already used', async t => {
3030
await t.throwsAsync(shiritori.check('とんかつ', ['べんと', 'トンカツ']),
31-
/already used/)
31+
/already used/)
3232
})
3333

3434
test('check: not shiritori', async t => {
3535
await t.throwsAsync(shiritori.check('とんかつ', ['エビフライ']),
36-
/does not match/)
36+
/does not match/)
3737
})
3838

3939
test('check: ー rules', async t => {
@@ -44,7 +44,7 @@ test('check: ー rules', async t => {
4444
t.true(await shiritori.check('あり', ['りかー']))
4545
t.true(await shiritori.check('田んぼ', ['スプリンター']))
4646
await t.throwsAsync(shiritori.check('とんかつ', ['りかー']),
47-
/does not match/)
47+
/does not match/)
4848
})
4949

5050
test('check: ぁぃぅぇぉゃゅょ rules', async t => {
@@ -92,28 +92,28 @@ test('interact: next', async t => {
9292

9393
test('interact: lose', async t => {
9494
await t.throwsAsync(shiritori.interact(dict, 'つと', ['とつ', 'つと']),
95-
{instanceOf: shiritori.Bad,
96-
message: /already used/})
95+
{ instanceOf: shiritori.Bad,
96+
message: /already used/ })
9797
})
9898

9999
test('interact: win without result', async t => {
100100
await t.throwsAsync(shiritori.interact(dict, 'つと', ['とんかつ', 'べんと']),
101-
{instanceOf: shiritori.Win})
101+
{ instanceOf: shiritori.Win })
102102
})
103103

104104
test('interact: win with result', async t => {
105105
await t.throwsAsync(shiritori.interact(dict, 'とんかつ', ['べんと']),
106-
{instanceOf: shiritori.Win})
106+
{ instanceOf: shiritori.Win })
107107
})
108108

109109
test('interact: win with ん', async t => {
110110
await t.throwsAsync(shiritori.interact(dict, '銀座', ['鰻']),
111-
{instanceOf: shiritori.Win})
111+
{ instanceOf: shiritori.Win })
112112
})
113113

114114
test('interact: error ', async t => {
115115
await t.throwsAsync(shiritori.interact(k => Promise.resolve({ 'つけまん': '' }),
116-
'とんかつ', ['べんと']),
117-
{instanceOf: Error,
118-
message:/no dictionary entry/})
116+
'とんかつ', ['べんと']),
117+
{ instanceOf: Error,
118+
message: /no dictionary entry/ })
119119
})

0 commit comments

Comments
 (0)