1 | # @textlint/kernel
|
2 |
|
3 | textlint kernel is core logic by pure JavaScript.
|
4 |
|
5 | This module is a low layer of textlint.
|
6 |
|
7 | No plugin, No rule, No filter rule by default.
|
8 |
|
9 | ## Install
|
10 |
|
11 | Install with [npm](https://www.npmjs.com/):
|
12 |
|
13 | npm install @textlint/kernel
|
14 |
|
15 | ## Usage
|
16 |
|
17 | ```js
|
18 | import { TextlintKernel } from "@textlint/kernel";
|
19 | const kernel = new TextlintKernel();
|
20 | const 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 | };
|
36 | kernel.lintText("TODO: text", options).then(result => {
|
37 | assert.ok(typeof result.filePath === "string");
|
38 | assert.ok(result.messages.length === 1);
|
39 | });
|
40 | ```
|
41 |
|
42 | Notes: Preset is a collection of Rules.
|
43 | Currently, `presets` option does not exist.
|
44 |
|
45 | ## Type Interface
|
46 |
|
47 | `@textlint/kernel` export core types of textlint.
|
48 |
|
49 | If you use TypeScript, this types help you.
|
50 |
|
51 | ```ts
|
52 | // Types
|
53 | import {
|
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 |
|
78 | See [Releases page](https://github.com/textlint/textlint/releases).
|
79 |
|
80 | ## Running tests
|
81 |
|
82 | Install devDependencies and Run `npm test`:
|
83 |
|
84 | npm i -d && npm test
|
85 |
|
86 | ## Contributing
|
87 |
|
88 | Pull requests and stars are always welcome.
|
89 |
|
90 | For bugs and feature requests, [please create an issue](https://github.com/textlint/textlint/issues).
|
91 |
|
92 | 1. Fork it!
|
93 | 2. Create your feature branch: `git checkout -b my-new-feature`
|
94 | 3. Commit your changes: `git commit -am 'Add some feature'`
|
95 | 4. Push to the branch: `git push origin my-new-feature`
|
96 | 5. 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 |
|
105 | MIT © azu
|