UNPKG

2.34 kBMarkdownView Raw
1# @textlint/kernel
2
3textlint kernel is core logic by pure JavaScript.
4
5This module is a low layer of textlint.
6
7No plugin, No rule, No filter rule by default.
8
9## Install
10
11Install with [npm](https://www.npmjs.com/):
12
13 npm install @textlint/kernel
14
15## Usage
16
17```js
18import { TextlintKernel } from "@textlint/kernel";
19const kernel = new TextlintKernel();
20const options = {
21 filePath: "/path/to/file.md",
22 ext: ".md",
23 plugins: [
24 {
25 pluginId: "markdown",
26 plugin: require("@textlint/textlint-plugin-markdown")
27 }
28 ],
29 rules: [
30 {
31 ruleId: "no-todo",
32 rule: require("textlint-rule-no-todo").default
33 }
34 ]
35};
36kernel.lintText("TODO: text", options).then(result => {
37 assert.ok(typeof result.filePath === "string");
38 assert.ok(result.messages.length === 1);
39});
40```
41
42Notes: Preset is a collection of Rules.
43Currently, `presets` option does not exist.
44
45## Type Interface
46
47`@textlint/kernel` export core types of textlint.
48
49If you use TypeScript, this types help you.
50
51```ts
52// Types
53import {
54 TextlintResult,
55 TextlintFixResult,
56 TextlintFixCommand,
57 TextlintMessage,
58 // Kernel rule/filter/plugin format
59 TextlintKernelRule,
60 TextlintKernelFilterRule,
61 TextlintKernelPlugin,
62 // textlint rule interface
63 TextlintRuleCreator,
64 TextlintRuleOptions,
65 // textlint filter rule interface
66 TextlintFilterRuleCreator,
67 TextlintFilterRuleOptions,
68 // textlint plugin interface
69 TextlintPluginCreator,
70 TextlintPluginOptions,
71 TextlintPluginProcessor,
72 TextlintPluginProcessorConstructor
73} from "@textlint/kernel";
74```
75
76## Changelog
77
78See [Releases page](https://github.com/textlint/textlint/releases).
79
80## Running tests
81
82Install devDependencies and Run `npm test`:
83
84 npm i -d && npm test
85
86## Contributing
87
88Pull requests and stars are always welcome.
89
90For bugs and feature requests, [please create an issue](https://github.com/textlint/textlint/issues).
91
921. Fork it!
932. Create your feature branch: `git checkout -b my-new-feature`
943. Commit your changes: `git commit -am 'Add some feature'`
954. Push to the branch: `git push origin my-new-feature`
965. Submit a pull request :D
97
98## Author
99
100- [github/azu](https://github.com/azu)
101- [twitter/azu_re](https://twitter.com/azu_re)
102
103## License
104
105MIT © azu