@@ -8,14 +8,17 @@ import {
8
8
TSDocTagSyntaxKind ,
9
9
ParserContext
10
10
} from "@microsoft/tsdoc" ;
11
+ import {
12
+ TSDocConfigFile
13
+ } from '@microsoft/tsdoc-config' ;
11
14
import * as eslint from "eslint" ;
12
15
import * as ESTree from "estree" ;
13
16
14
- const messageIds : { [ x : string ] : string } = { } ;
17
+ const tsdocMessageIds : { [ x : string ] : string } = { } ;
15
18
16
19
const defaultTSDocConfiguration : TSDocConfiguration = new TSDocConfiguration ( )
17
20
defaultTSDocConfiguration . allTsdocMessageIds . forEach ( ( messageId : string ) => {
18
- messageIds [ messageId ] = `${ messageId } : {{ unformattedText }}` ;
21
+ tsdocMessageIds [ messageId ] = `${ messageId } : {{unformattedText}}` ;
19
22
} ) ;
20
23
21
24
interface IPlugin {
@@ -28,7 +31,7 @@ const plugin: IPlugin = {
28
31
// from the NPM package name, and then appending this string.
29
32
"syntax" : {
30
33
meta : {
31
- messages : messageIds ,
34
+ messages : tsdocMessageIds ,
32
35
type : "problem" ,
33
36
docs : {
34
37
description : "Validates that TypeScript documentation comments conform to the TSDoc standard" ,
@@ -41,24 +44,32 @@ const plugin: IPlugin = {
41
44
create : ( context : eslint . Rule . RuleContext ) => {
42
45
const tsdocConfiguration : TSDocConfiguration = new TSDocConfiguration ( ) ;
43
46
44
- // Create a lax configuration that allows every standard tag regardless of standardization group
45
- tsdocConfiguration . setSupportForTags ( StandardTags . allDefinitions , true ) ;
47
+ const sourceFilePath : string = context . getFilename ( ) ;
48
+ const tsdocConfigFile : TSDocConfigFile = TSDocConfigFile . loadForFolder ( sourceFilePath ) ;
49
+
50
+ if ( ! tsdocConfigFile . fileNotFound ) {
51
+ tsdocConfigFile . configureParser ( tsdocConfiguration ) ;
52
+ } else {
53
+ // If we weren't able to find a tsdoc-config.json file, then by default we will use a lax configuration
54
+ // that allows every standard tag regardless of standardization group.
55
+ tsdocConfiguration . setSupportForTags ( StandardTags . allDefinitions , true ) ;
46
56
47
- // Also add the three AEDoc tags
48
- tsdocConfiguration . addTagDefinitions ( [
49
- new TSDocTagDefinition ( {
50
- tagName : '@betaDocumentation' ,
51
- syntaxKind : TSDocTagSyntaxKind . ModifierTag
52
- } ) ,
53
- new TSDocTagDefinition ( {
54
- tagName : '@internalRemarks' ,
55
- syntaxKind : TSDocTagSyntaxKind . BlockTag
56
- } ) ,
57
- new TSDocTagDefinition ( {
58
- tagName : '@preapproved' ,
59
- syntaxKind : TSDocTagSyntaxKind . ModifierTag
60
- } )
61
- ] , true ) ;
57
+ // Also allow the three AEDoc tags.
58
+ tsdocConfiguration . addTagDefinitions ( [
59
+ new TSDocTagDefinition ( {
60
+ tagName : '@betaDocumentation' ,
61
+ syntaxKind : TSDocTagSyntaxKind . ModifierTag
62
+ } ) ,
63
+ new TSDocTagDefinition ( {
64
+ tagName : '@internalRemarks' ,
65
+ syntaxKind : TSDocTagSyntaxKind . BlockTag
66
+ } ) ,
67
+ new TSDocTagDefinition ( {
68
+ tagName : '@preapproved' ,
69
+ syntaxKind : TSDocTagSyntaxKind . ModifierTag
70
+ } )
71
+ ] , true ) ;
72
+ }
62
73
63
74
const tsdocParser : TSDocParser = new TSDocParser ( tsdocConfiguration ) ;
64
75
0 commit comments