@@ -3,49 +3,52 @@ import { spellCheckDocument } from 'cspell-lib';
33async function check ( text ) {
44 const result = await spellCheckDocument (
55 {
6- languageId : 'plaintext' ,
7- locale : 'en' ,
86 text,
97 uri : '' ,
8+ languageId : 'plaintext' ,
9+ locale : 'en' ,
1010 } ,
1111 { } ,
1212 { } ,
1313 ) ;
1414
15- return result . issues . length === 0 ;
15+ return {
16+ result : result . issues . length === 0 ,
17+ words : result . issues . map ( issue => issue . text ) ,
18+ } ;
1619}
1720
1821export default {
1922 rules : {
20- 'spellcheck/body ' : async ( { body } ) => {
21- const result = await check ( body ) ;
23+ 'spellcheck/header ' : async ( { header } ) => {
24+ const { result, words } = await check ( header ) ;
2225
23- return [ result , 'body may not be misspelled' ] ;
26+ return [ result , `header may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
2427 } ,
25- 'spellcheck/footer ' : async ( { footer } ) => {
26- const result = await check ( footer ) ;
28+ 'spellcheck/body ' : async ( { body } ) => {
29+ const { result, words } = await check ( body ) ;
2730
28- return [ result , 'footer may not be misspelled' ] ;
31+ return [ result , `body may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
2932 } ,
30- 'spellcheck/header ' : async ( { header } ) => {
31- const result = await check ( header ) ;
33+ 'spellcheck/footer ' : async ( { footer } ) => {
34+ const { result, words } = await check ( footer ) ;
3235
33- return [ result , 'header may not be misspelled' ] ;
36+ return [ result , `footer may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
3437 } ,
3538 'spellcheck/scope' : async ( { scope } ) => {
36- const result = await check ( scope ) ;
39+ const { result, words } = await check ( scope ) ;
3740
38- return [ result , ' scope may not be misspelled' ] ;
41+ return [ result , ` scope may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
3942 } ,
4043 'spellcheck/subject' : async ( { subject } ) => {
41- const result = await check ( subject ) ;
44+ const { result, words } = await check ( subject ) ;
4245
43- return [ result , ' subject may not be misspelled' ] ;
46+ return [ result , ` subject may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
4447 } ,
4548 'spellcheck/type' : async ( { type } ) => {
46- const result = await check ( type ) ;
49+ const { result, words } = await check ( type ) ;
4750
48- return [ result , ' type may not be misspelled' ] ;
51+ return [ result , ` type may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
4952 } ,
5053 } ,
5154} ;
0 commit comments