-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(textlint): add deprecation warning to old APIs (#1312)
* fix(textlint): add deprecation warning to old APIs `TextLintCore`, `TextFixEngine`, `TextLintEngine`, and `textlint` API is deprecated * refactor(examples): Use new APIs * refactor(examples): Use new APIs * refactor(examples): Use new APIs * chore: update lock * update message * test: add deprecated label to tests * test: add deprecated label to tests * test: use TextilntCoreCompat instead of TextlintCore * refactor: remove unneeded test * test: move to kernel * remove unused * comment * import * feat: add @textlint/legacy-textlint-core * Update packages/@textlint/legacy-textlint-core/tsconfig.json+2 * remove unused test * fix: test * docs: update readme * Update package-lock.json * test: should not use DEPRECATED module * test: fix tests
- Loading branch information
Showing
45 changed files
with
567 additions
and
1,131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"no-todo": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// LICENSE : MIT | ||
import { createLinter, loadTextlintrc, loadLinterFormatter } from "textlint"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
async function lintFile(filePath) { | ||
// descriptor is a structure object for linter | ||
// It includes rules, plugins, and options | ||
const descriptor = await loadTextlintrc({ | ||
configFilePath: path.join(__dirname, ".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(__dirname + "/README.md").catch(function(error) { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"no-todo": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
{ | ||
"name": "textlint-example-use-as-ts-module", | ||
"version": "13.4.1", | ||
"private": true, | ||
"license": "MIT", | ||
"author": "0x6b", | ||
"main": "lib/src/index.js", | ||
"scripts": { | ||
"prebuild": "npm-run-all clean", | ||
"build": "tsc -b", | ||
"clean": "rimraf lib/ module/", | ||
"pretest": "npm-run-all build", | ||
"test": "node lib/src/index.js fixtures/success.md", | ||
"test:ci": "npm test" | ||
}, | ||
"dependencies": { | ||
"textlint": "^13.4.1", | ||
"textlint-rule-no-exclamation-question-mark": "^1.0.2", | ||
"textlint-rule-no-todo": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.7.16", | ||
"npm-run-all": "^4.1.5", | ||
"rimraf": "^3.0.2", | ||
"typescript": "~4.9.4" | ||
}, | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"module/", | ||
"src/", | ||
"!*.tsbuildinfo" | ||
] | ||
"name": "textlint-example-use-as-ts-module", | ||
"version": "13.4.1", | ||
"private": true, | ||
"license": "MIT", | ||
"type": "module", | ||
"author": "0x6b", | ||
"main": "lib/src/index.js", | ||
"scripts": { | ||
"build": "tsc --build", | ||
"clean": "tsc --build --clean", | ||
"test": "npm run build && node lib/src/index.js fixtures/success.md", | ||
"fail:test": "npm run build && node lib/src/index.js fixtures/failure.md", | ||
"test:ci": "npm test" | ||
}, | ||
"dependencies": { | ||
"textlint": "^13.4.1", | ||
"textlint-rule-no-todo": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.7.16", | ||
"typescript": "~4.9.4" | ||
}, | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"module/", | ||
"src/", | ||
"!*.tsbuildinfo" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
// LICENSE : MIT | ||
"use strict"; | ||
import { argv, cwd, exit } from "process"; | ||
import { resolve } from "path"; | ||
import { TextLintEngine } from "textlint"; | ||
import { TextlintResult } from "@textlint/kernel"; | ||
import { createLinter, loadTextlintrc, loadLinterFormatter } from "textlint"; | ||
import path from "node:path"; | ||
import { parseArgs } from "node:util"; | ||
|
||
const [, , filename] = argv; | ||
|
||
function lintFile(filePath: string) { | ||
const filePathList = [resolve(cwd(), filePath)]; | ||
|
||
const engine = new TextLintEngine({ | ||
rules: ["no-todo", "no-exclamation-question-mark"], | ||
formatterName: "pretty-error", | ||
color: false | ||
async function lintFile(filePaths: string[]) { | ||
// descriptor is a structure object for linter | ||
// It includes rules, plugins, and options | ||
const descriptor = await loadTextlintrc({ | ||
configFilePath: path.join(process.cwd(), ".textlintrc.json") | ||
}); | ||
|
||
return engine.executeOnFiles(filePathList).then(function (results: TextlintResult[]) { | ||
if (engine.isErrorResults(results)) { | ||
console.log(engine.formatResults(results)); | ||
} else { | ||
console.log("All Passed!"); | ||
} | ||
const linter = createLinter({ | ||
descriptor | ||
}); | ||
const results = await linter.lintFiles(filePaths); | ||
// 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(filename).catch(function (error: TextlintResult) { | ||
const { positionals } = parseArgs({ | ||
allowPositionals: true | ||
}); | ||
lintFile(positionals).catch(function (error) { | ||
console.error(error); | ||
exit(1); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.