Skip to content

Commit b5c24b1

Browse files
committed
[WIP] add textlint's transform
Don't work
1 parent ff2b326 commit b5c24b1

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"shift-parser": "^4.1.0",
8080
"source-map": "^0.5.3",
8181
"tern": "^0.17.0",
82+
"textlint": "^6.0.3",
8283
"traceur": "0.0.102",
8384
"txt-to-ast": "^1.1.0",
8485
"typescript": "^1.7.5",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default function (context) {
2+
console.log(context);
3+
return {}
4+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import compileModule from '../../../utils/compileModule';
2+
import pkg from 'textlint/package.json';
3+
4+
const ID = 'textlint';
5+
6+
export default {
7+
id: ID,
8+
displayName: ID,
9+
version: pkg.version,
10+
homepage: pkg.homepage,
11+
12+
defaultParserID: 'textlint:markdown-to-ast',
13+
14+
loadTransformer(callback) {
15+
require(['textlint/lib/textlint-core', 'babel-core'], (TextLintCore, babel) => {
16+
callback({ TextLintCore, babel });
17+
})
18+
},
19+
20+
transform({TextLintCore, babel}, transformCode, code) {
21+
console.log(TextLintCore);
22+
const textlintCore = new TextLintCore();
23+
let rule = compileModule( // eslint-disable-line no-shadow
24+
babel.transform(transformCode).code
25+
);
26+
textlintCore.setupRules({
27+
'astExplorerRule': rule
28+
});
29+
return textlintCore.lintText(code, ".md").then(result => {
30+
return JSON.stringify(result);
31+
});
32+
}
33+
};

0 commit comments

Comments
 (0)