Closed
Description
表題の事象があったため、エラーの Stack trace を報告します。
Stack trace
TypeError: Reduce of empty array with no initial value
at ***.md
at Array.reduce (<anonymous>)
at ***/node_modules/@textlint-ja/textlint-rule-no-dropping-i/lib/no-dropping-i.js:32:16
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 2)
at async Promise.all (index 58)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
空の配列に対して reduce を行う際は初期値を与える必要があるようです。
以下のようにしたところエラーは出なくなり、そのままローカルで使用させていただいております。
no-dropping-i.js
...
return (0, _kuromojin.tokenize)(text).then(tokens => {
tokens.reduce((prev, current) => {
if (isTargetWord(prev) && isMasuWord(current)) {
report(node, new RuleError("い抜き言葉を使用しています。", {
index: current.word_position - 1
}));
}
return current;
}, 0);
...
恐れ入りますが入力に使ったファイルは公開できる文章ではなく、提示できません。
空の検出があること自体が想定外かどうか、根本的なところを作者の方でご判断いただければ幸いです。