@@ -3,49 +3,52 @@ import { spellCheckDocument } from 'cspell-lib';
3
3
async function check ( text ) {
4
4
const result = await spellCheckDocument (
5
5
{
6
- languageId : 'plaintext' ,
7
- locale : 'en' ,
8
6
text,
9
7
uri : '' ,
8
+ languageId : 'plaintext' ,
9
+ locale : 'en' ,
10
10
} ,
11
11
{ } ,
12
12
{ } ,
13
13
) ;
14
14
15
- return result . issues . length === 0 ;
15
+ return {
16
+ result : result . issues . length === 0 ,
17
+ words : result . issues . map ( issue => issue . text ) ,
18
+ } ;
16
19
}
17
20
18
21
export default {
19
22
rules : {
20
- 'spellcheck/body ' : async ( { body } ) => {
21
- const result = await check ( body ) ;
23
+ 'spellcheck/header ' : async ( { header } ) => {
24
+ const { result, words } = await check ( header ) ;
22
25
23
- return [ result , 'body may not be misspelled' ] ;
26
+ return [ result , `header may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
24
27
} ,
25
- 'spellcheck/footer ' : async ( { footer } ) => {
26
- const result = await check ( footer ) ;
28
+ 'spellcheck/body ' : async ( { body } ) => {
29
+ const { result, words } = await check ( body ) ;
27
30
28
- return [ result , 'footer may not be misspelled' ] ;
31
+ return [ result , `body may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
29
32
} ,
30
- 'spellcheck/header ' : async ( { header } ) => {
31
- const result = await check ( header ) ;
33
+ 'spellcheck/footer ' : async ( { footer } ) => {
34
+ const { result, words } = await check ( footer ) ;
32
35
33
- return [ result , 'header may not be misspelled' ] ;
36
+ return [ result , `footer may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
34
37
} ,
35
38
'spellcheck/scope' : async ( { scope } ) => {
36
- const result = await check ( scope ) ;
39
+ const { result, words } = await check ( scope ) ;
37
40
38
- return [ result , ' scope may not be misspelled' ] ;
41
+ return [ result , ` scope may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
39
42
} ,
40
43
'spellcheck/subject' : async ( { subject } ) => {
41
- const result = await check ( subject ) ;
44
+ const { result, words } = await check ( subject ) ;
42
45
43
- return [ result , ' subject may not be misspelled' ] ;
46
+ return [ result , ` subject may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
44
47
} ,
45
48
'spellcheck/type' : async ( { type } ) => {
46
- const result = await check ( type ) ;
49
+ const { result, words } = await check ( type ) ;
47
50
48
- return [ result , ' type may not be misspelled' ] ;
51
+ return [ result , ` type may not be misspelled: ${ words . join ( ', ' ) } ` ] ;
49
52
} ,
50
53
} ,
51
54
} ;
0 commit comments