From 9c79e5e3060502b41f02d94942af60f3df5e78d0 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 27 Aug 2021 15:20:51 +0200 Subject: [PATCH] Use `@types/nlcst` --- index.js | 7 +++++-- package.json | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 79d114e..c3ae169 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,7 @@ /** + * @typedef {import('nlcst').Root} Root + * @typedef {import('nlcst').Word} Word + * * @typedef Options * Configuration. * @property {string[]} [ignore] @@ -18,7 +21,7 @@ const verbs = new Set(['am', 'are', 'were', 'being', 'is', 'been', 'was', 'be']) /** * Plugin to check for passive voice. * - * @type {import('unified').Plugin<[Options?]>} + * @type {import('unified').Plugin<[Options?], Root>} */ export default function retextPassive(options = {}) { const ignore = options.ignore || [] @@ -27,7 +30,7 @@ export default function retextPassive(options = {}) { return (tree, file) => { search(tree, phrases, (match, index, parent, phrase) => { - const before = findBefore(parent, index, 'WordNode') + const before = /** @type {Word} */ (findBefore(parent, index, 'WordNode')) if (!before || !verbs.has(toString(before).toLowerCase())) { return diff --git a/package.json b/package.json index e29845c..105606b 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "list.js" ], "dependencies": { + "@types/nlcst": "^1.0.0", "nlcst-search": "^3.0.0", "nlcst-to-string": "^3.0.0", "unified": "^10.0.0",