Skip to content

Commit 27d60e9

Browse files
committed
fix(ast): TxtAST alwasys has type value
1 parent 5655c89 commit 27d60e9

File tree

6 files changed

+947
-1
lines changed

6 files changed

+947
-1
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"presets": [
88
"jsdoc-to-assert",
99
"power-assert"
10+
],
11+
"only":[
12+
"src/*.js",
13+
"test/*.js",
14+
"node_modules/textlint-ast-test/lib/*.js"
1015
]
1116
}
1217
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"mocha": "^2.3.3",
4343
"power-assert": "^1.4.0",
4444
"textlint": "^6.7.0",
45+
"textlint-ast-test": "^1.1.3",
4546
"textlint-rule-no-todo": "^2.0.0"
4647
},
4748
"dependencies": {

src/html-to-ast.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ export function parse(html) {
6060
end: {line: position.end.line, column: position.end.column + 1}
6161
};
6262
}
63+
// Unknown type
64+
if (typeof node.type === "undefined") {
65+
node.type = "UNKNOWN";
66+
}
6367
// map `range`, `loc` and `raw` to node
64-
if (node.position) {
68+
if (typeof node.position === "object") {
6569
let position = node.position;
6670
// TxtNode's line start with 1
6771
// TxtNode's column start with 0

0 commit comments

Comments
 (0)