File tree Expand file tree Collapse file tree 11 files changed +67
-27
lines changed Expand file tree Collapse file tree 11 files changed +67
-27
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ import type {Plugin} from 'unified'
44// See `parse-latin`.
55type Extension < Node extends Nodes > = ( node : Node ) => undefined | void
66
7+ // Note: we have to use manual types here,
8+ // instead of getting them from `lib/index.js`,
9+ // because TS generates wrong types for functions that use `this`.
10+ // TS makes them into classes which is incorrect.
711/**
812 * Add support for parsing Dutch natural language.
913 *
Original file line number Diff line number Diff line change 11/**
22 * @import {Root} from 'nlcst'
3- * @import {Parser, Processor} from 'unified'
3+ * @import {Processor} from 'unified'
44 */
55
66import { ParseDutch } from 'parse-dutch'
77
88/**
99 * Add support for parsing Dutch natural language.
1010 *
11+ * @this {Processor<Root>}
12+ * Processor.
1113 * @returns {undefined }
1214 * Nothing.
1315 */
1416export default function retextDutch ( ) {
15- // @ts -expect-error -- TS in JSDoc doesn’t understand `this`.
16- // eslint-disable-next-line unicorn/no-this-assignment
17- const self = /** @type {Processor<Root> } */ ( this )
17+ const self = this
1818
1919 self . parser = parser
2020
21- /** @type {Parser<Root> } */
21+ /**
22+ * @param {string } value
23+ * Document.
24+ * @returns {Root }
25+ * Tree.
26+ */
2227 function parser ( value ) {
2328 const parser = new ParseDutch ( )
2429 add ( parser . tokenizeParagraphPlugins , self . data ( 'nlcstParagraphExtensions' ) )
Original file line number Diff line number Diff line change 6161 }
6262 }
6363 ],
64- "prettier" : true
64+ "prettier" : true ,
65+ "rules" : {
66+ "unicorn/no-this-assignment" : " off"
67+ }
6568 }
6669}
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ import type {Plugin} from 'unified'
44// See `parse-latin`.
55type Extension < Node extends Nodes > = ( node : Node ) => undefined | void
66
7+ // Note: we have to use manual types here,
8+ // instead of getting them from `lib/index.js`,
9+ // because TS generates wrong types for functions that use `this`.
10+ // TS makes them into classes which is incorrect.
711/**
812 * Add support for parsing English natural language.
913 *
Original file line number Diff line number Diff line change 11/**
22 * @import {Root} from 'nlcst'
3- * @import {Parser, Processor} from 'unified'
3+ * @import {Processor} from 'unified'
44 */
55
66import { ParseEnglish } from 'parse-english'
77
88/**
99 * Add support for parsing English natural language.
1010 *
11+ * @this {Processor<Root>}
12+ * Processor.
1113 * @returns {undefined }
1214 * Nothing.
1315 */
1416export default function retextEnglish ( ) {
15- // @ts -expect-error -- TS in JSDoc doesn’t understand `this`.
16- // eslint-disable-next-line unicorn/no-this-assignment
17- const self = /** @type {Processor<Root> } */ ( this )
17+ const self = this
1818
1919 self . parser = parser
2020
21- /** @type {Parser<Root> } */
21+ /**
22+ * @param {string } value
23+ * Document.
24+ * @returns {Root }
25+ * Tree.
26+ */
2227 function parser ( value ) {
2328 const parser = new ParseEnglish ( )
2429 add ( parser . tokenizeParagraphPlugins , self . data ( 'nlcstParagraphExtensions' ) )
Original file line number Diff line number Diff line change 6161 }
6262 }
6363 ],
64- "prettier" : true
64+ "prettier" : true ,
65+ "rules" : {
66+ "unicorn/no-this-assignment" : " off"
67+ }
6568 }
6669}
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ import type {Plugin} from 'unified'
44// See `parse-latin`.
55type Extension < Node extends Nodes > = ( node : Node ) => undefined | void
66
7+ // Note: we have to use manual types here,
8+ // instead of getting them from `lib/index.js`,
9+ // because TS generates wrong types for functions that use `this`.
10+ // TS makes them into classes which is incorrect.
711/**
812 * Add support for parsing Latin-script natural language.
913 *
Original file line number Diff line number Diff line change @@ -8,17 +8,22 @@ import {ParseLatin} from 'parse-latin'
88/**
99 * Add support for parsing Latin-script natural language.
1010 *
11+ * @this {Processor<Root>}
12+ * Processor.
1113 * @returns {undefined }
1214 * Nothing.
1315 */
1416export default function retextLatin ( ) {
15- // @ts -expect-error -- TS in JSDoc doesn’t understand `this`.
16- // eslint-disable-next-line unicorn/no-this-assignment
17- const self = /** @type {Processor<Root> } */ ( this )
17+ const self = this
1818
1919 self . parser = parser
2020
21- /** @type {Parser<Root> } */
21+ /**
22+ * @param {string } value
23+ * Document.
24+ * @returns {Root }
25+ * Tree.
26+ */
2227 function parser ( value ) {
2328 const parser = new ParseLatin ( )
2429 add ( parser . tokenizeParagraphPlugins , self . data ( 'nlcstParagraphExtensions' ) )
Original file line number Diff line number Diff line change 6161 }
6262 }
6363 ],
64- "prettier" : true
64+ "prettier" : true ,
65+ "rules" : {
66+ "unicorn/no-this-assignment" : " off"
67+ }
6568 }
6669}
Original file line number Diff line number Diff line change 11import type { Root } from 'nlcst'
22import type { Plugin } from 'unified'
33
4+ // Note: we have to use manual types here,
5+ // instead of getting them from `lib/index.js`,
6+ // because TS generates wrong types for functions that use `this`.
7+ // TS makes them into classes which is incorrect.
48/**
59 * Add support for serializing natural language.
610 *
You can’t perform that action at this time.
0 commit comments