-
-
Notifications
You must be signed in to change notification settings - Fork 154
Closed
Labels
Type: BugBug or Bug fixesBug or Bug fixes
Description
There are replaced by createLinter
and loadTextlintrc
, and loadLinerFormatter
.
Depretead old APIs
Depreacate four APIs in textlint
package.
API | Alternative |
---|---|
textlint |
use @textlint/legacy-textlint-core or @textlint/kernel |
TextLintCore |
use @textlint/legacy-textlint-core or @textlint/kernel |
TextLintEngine |
use createLinter and loadTextlintrc |
TextFixEngine |
use createLinter and loadTextlintrc |
How to control the deprecation message?
- If the
NODE_OPTIONS=--throw-deprecation
is used, the deprecation warning is thrown as an exception rather than being emitted as an event. - If the
NODE_OPTIONS=--no-deprecation
is used, the deprecation warning is suppressed. - If the
NODE_OPTIONS=--trace-deprecation
is used, the deprecation warning is printed to stderr along with the full stack trace.
If you want to find the usage of deprecation APIs, you can run with NODE_OPTIONS=--throw-deprecation
env.
NODE_OPTIONS=--throw-deprecation node your-script.js
For more details, see process.emitWarning(warning[, options]).
Documentaion for New APIs
Migration Guide
TextLintEngine
/TextFixEngine
Use createLinter
and loadTextlintrc
instead of TextLintEngine
/TextFixEngine
import { TextLintEngine } from "textlint";
import path from "path";
function lintFile(filePath) {
const engine = new TextLintEngine({
formatterName: "stylish",
});
const filePathList = [filePath];
return engine.executeOnFiles(filePathList).then(function (results) {
const output = engine.formatResults(results);
console.log(output);
});
}
lintFile(path.resolve(process.cwd(), "README.md"));
→
import { createLinter, loadTextlintrc, loadLinterFormatter } from "textlint";
import path from "node:path";
import { fileURLToPath } from "node:url";
async function lintFile(filePath) {
// descriptor is a structure object for linter
// It includes rules, plugins, and options
const descriptor = await loadTextlintrc({
configFilePath: path.join(process.cwd(), ".textlintrc.json")
});
const linter = createLinter({
descriptor
});
const results = await linter.lintFiles([filePath]);
// textlint has two types formatter sets for linter and fixer
const formatter = await loadLinterFormatter({ formatterName: "stylish" });
const output = formatter.format(results);
console.log(output);
}
lintFile(path.join(process.cwd(), "README.md")
TextLintCore
Use @textlint/legacy-textlint-core
instead of it.
This package is deprecated, but you can migrate it smooth.
- import { TextLintCore } from "textlint";
+ import { TextLintCore } from "@textlint/legacy-textlint-core";
TODO
- deprecate old APIs using process.emitWarning(warning[, options])
Metadata
Metadata
Assignees
Labels
Type: BugBug or Bug fixesBug or Bug fixes