Repository navigation
Replies: 3 comments 1 reply
|
I mention to |
1 reply
|
We have released textlint v13! textlint v13 use new APIs by default. |
0 replies
|
I've rewritten html plugin as Pure ESM. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This discussion welcome to feedback for textlint's new APIs.
Feedback is welcome, especially from users who use
textlintas a module, as it will need to be changed in the future.textlint 12.3.0 support a rule that is written as ECMAScript Modules.
requirecan not load ESM, we need to useimport()for loading ESM modules.Current
TextLintCore/TextFixEngine/TextLintEngineuserequireto load modules.As a result,
TextLintCore/TextFixEngine/TextLintEnginecan not support ESM without Breaking Changes.Old APIs and New APIs
We have introduced new API like
createLinterfor supporting Async APIs.v13 continue to support current
TextlintCore,TextLintEngineandTextFixEnginefor backward compatible.However, These API will be retired in the future.
New
createLinterandloadTextlintrcsupports ESM rules/plugins.textlintmodules user should use these instead ofTextlintCore,TextLintEngineandTextFixEngine.ℹ️ Timeline:
createLinterandloadTextlintrcinternally)◉ Linting is Async
◉ Fixing is Async
◉ Linting/Fixing is Async
New APIs
textlint v12.3.0 introduce new APIs.
textlint will drop support old APIs(
textlint,TextLintEngine,TextFixEngine, andTextLintCore) in the future.📝 old APIs can not support ECMAScript modules, new APIs support ECMAScript modules.
createLinter: create linter instancelintFiles(files): Promise<TextlintResult[]>: lint files and return linter messageslintText(text, filePath): Promise<TextlintResult>lint text with virtual filePath and return linter messagesfixFiles(files): Promise<TextlintFixResult[]>lint text and return fixer messagesfixText(text, filePath): Promise<TextlintFixResult>lint text with virtual filePath and return fixer messagesfixFilesandfixTextdoes not modify filesloadTextlintrc: load.textlintrcconfig file and return a descriptor objectloadLinerFormatterandloadFixerFormatter: load formatterExamples
Lint files and output to console.
Fix text and get the fixed text.
Add custom rules and plugins.
If you not want to load
.textlintrc, you can use just@textlint/kernel.Get lintable file extensions.
textlintrcDescriptor.availableExtensionsprovide a list of supported file extensions.For more details, see https://textlint.github.io/docs/use-as-modules.html
Notes
Probably, You can replace
TextlintCore,TextLintEngineandTextFixEnginewith new APIs.If there are missing parts, please report me.
All reactions