Replies: 3 comments 1 reply
-
I mention to |
Beta Was this translation helpful? Give feedback.
1 reply
-
We have released textlint v13! textlint v13 use new APIs by default. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I've rewritten html plugin as Pure ESM. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This discussion welcome to feedback for textlint's new APIs.
Feedback is welcome, especially from users who use
textlint
as 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.
require
can not load ESM, we need to useimport()
for loading ESM modules.Current
TextLintCore
/TextFixEngine
/TextLintEngine
userequire
to load modules.As a result,
TextLintCore
/TextFixEngine
/TextLintEngine
can not support ESM without Breaking Changes.Old APIs and New APIs
We have introduced new API like
createLinter
for supporting Async APIs.v13 continue to support current
TextlintCore
,TextLintEngine
andTextFixEngine
for backward compatible.However, These API will be retired in the future.
New
createLinter
andloadTextlintrc
supports ESM rules/plugins.textlint
modules user should use these instead ofTextlintCore
,TextLintEngine
andTextFixEngine
.ℹ️ Timeline:
createLinter
andloadTextlintrc
internally)◉ 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 messagesfixFiles
andfixText
does not modify filesloadTextlintrc
: load.textlintrc
config file and return a descriptor objectloadLinerFormatter
andloadFixerFormatter
: 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.availableExtensions
provide 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
,TextLintEngine
andTextFixEngine
with new APIs.If there are missing parts, please report me.
Beta Was this translation helpful? Give feedback.
All reactions