Skip to content

Commit ae6b812

Browse files
committed
feat(prh): support ~/ path
`~/` should be expected as `$HOME$/`.
1 parent 334a6e3 commit ae6b812

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"dependencies": {
3535
"prh": "^1.0.1",
3636
"structured-source": "^3.0.2",
37-
"textlint-rule-helper": "^1.1.3"
37+
"textlint-rule-helper": "^1.1.3",
38+
"untildify": "^3.0.2"
3839
},
3940
"devDependencies": {
4041
"babel-cli": "^6.7.5",

src/prh-rule.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import {RuleHelper} from "textlint-rule-helper";
44
import StructuredSource from "structured-source";
55
import prh from "prh";
66
import path from "path";
7+
const untildify = require('untildify');
78
function createPrhEngine(rulePaths, baseDir) {
89
if (rulePaths.length === 0) {
910
return null;
1011
}
11-
const prhEngine = prh.fromYAMLFilePath(path.resolve(baseDir, rulePaths[0]));
12-
rulePaths.slice(1).forEach(ruleFilePath => {
12+
const expandedRulePaths = rulePaths.map(rulePath => untildify(rulePath));
13+
const prhEngine = prh.fromYAMLFilePath(path.resolve(baseDir, expandedRulePaths[0]));
14+
expandedRulePaths.slice(1).forEach(ruleFilePath => {
1315
const config = prh.fromYAMLFilePath(path.resolve(baseDir, ruleFilePath));
1416
prhEngine.merge(config);
1517
});
@@ -82,10 +84,10 @@ function reporter(context, options = {}) {
8284
return;
8385
}
8486
/*
85-
line start with 1
86-
column start with 0
87+
line start with 1
88+
column start with 0
8789
88-
adjust position => line -1, column +0
90+
adjust position => line -1, column +0
8991
*/
9092
var position = src.indexToPosition(changeSet.index);
9193

test/textlintrc-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe(".textlinrc test", function () {
1313
"prh": rule
1414
}, {
1515
"prh": {
16-
"rulePaths": [path.join(__dirname, "fixtures", "rule.yaml")]
16+
"rulePaths": [path.join(__dirname, "fixtures", "rule.yaml"), path.join(__dirname, "fixtures", "imports.yml")]
1717
}
1818
});
1919
return textlint.lintMarkdown("jquery").then(result => {

0 commit comments

Comments
 (0)