Skip to content

Commit 8e01f44

Browse files
committed
fix(rule): add fallback
Fix following error: > Error while loading rule 'prh': Path must be a string. Received undefined
1 parent 12b04fe commit 8e01f44

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/textlint-rule-prh.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const forEachChange = (changeSet, str, onChangeOfMatch) => {
9393
};
9494
const getConfigBaseDir = (context) => {
9595
if (typeof context.getConfigBaseDir === "function") {
96-
return context.getConfigBaseDir();
96+
return context.getConfigBaseDir() || process.cwd();
9797
}
9898
// Old fallback that use deprecated `config` value
9999
// https://github.com/textlint/textlint/issues/294
@@ -127,7 +127,9 @@ function reporter(context, options = {}) {
127127
if (actual === expected) {
128128
return;
129129
}
130-
report(node, new RuleError(actual + " => " + expected, {
130+
131+
const messages = actual + " => " + expected;
132+
report(node, new RuleError(messages, {
131133
index: matchStartIndex,
132134
fix: fixer.replaceTextRange([matchStartIndex, matchEndIndex], expected)
133135
}));

0 commit comments

Comments
 (0)