Skip to content

Commit 758d919

Browse files
authored
Merge pull request #11 from azu/support-tilde
feat(prh): support ~/ path
2 parents 844308f + ae6b812 commit 758d919

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
"prh"
3333
],
3434
"dependencies": {
35-
"prh": "^0.9.0",
35+
"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",
41-
"babel-plugin-add-module-exports": "^0.1.2",
42+
"babel-plugin-add-module-exports": "^0.2.1",
4243
"babel-preset-es2015": "^6.6.0",
43-
"babel-preset-jsdoc-to-assert": "^1.0.1",
44+
"babel-preset-jsdoc-to-assert": "^2.0.1",
4445
"babel-preset-power-assert": "^1.0.0",
4546
"babel-register": "^6.7.2",
4647
"mocha": "^2.3.2",

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)