@@ -11,12 +11,14 @@ export class Configuration {
1111 - format: (required) `text` | `json`
1212 - rules: [string array] whitelist rules
1313 - customRulePaths: [string array] path to additional custom rules to be loaded
14+ - commentDescriptions: [boolean] use old way of defining descriptions in GraphQL SDL
1415 - oldImplementsSyntax: [boolean] use old way of defining implemented interfaces in GraphQL SDL
1516 */
1617 constructor ( schema , options = { } ) {
1718 const defaultOptions = {
1819 format : 'text' ,
1920 customRulePaths : [ ] ,
21+ commentDescriptions : false ,
2022 oldImplementsSyntax : false ,
2123 } ;
2224
@@ -27,6 +29,10 @@ export class Configuration {
2729 this . rulePaths = this . options . customRulePaths . concat ( this . builtInRulePaths ) ;
2830 }
2931
32+ getCommentDescriptions ( ) {
33+ return this . options . commentDescriptions ;
34+ }
35+
3036 getOldImplementsSyntax ( ) {
3137 return this . options . oldImplementsSyntax ;
3238 }
@@ -55,23 +61,23 @@ export class Configuration {
5561 let specifiedRules ;
5662 if ( this . options . rules && this . options . rules . length > 0 ) {
5763 specifiedRules = this . options . rules . map ( toUpperCamelCase ) ;
58- rules = this . getAllRules ( ) . filter ( ( rule ) => {
64+ rules = this . getAllRules ( ) . filter ( rule => {
5965 return specifiedRules . indexOf ( rule . name ) >= 0 ;
6066 } ) ;
6167 }
6268
6369 // DEPRECATED - This code should be removed in v1.0.0.
6470 if ( this . options . only && this . options . only . length > 0 ) {
6571 specifiedRules = this . options . only . map ( toUpperCamelCase ) ;
66- rules = this . getAllRules ( ) . filter ( ( rule ) => {
72+ rules = this . getAllRules ( ) . filter ( rule => {
6773 return specifiedRules . indexOf ( rule . name ) >= 0 ;
6874 } ) ;
6975 }
7076
7177 // DEPRECATED - This code should be removed in v1.0.0.
7278 if ( this . options . except && this . options . except . length > 0 ) {
7379 specifiedRules = this . options . except . map ( toUpperCamelCase ) ;
74- rules = this . getAllRules ( ) . filter ( ( rule ) => {
80+ rules = this . getAllRules ( ) . filter ( rule => {
7581 return specifiedRules . indexOf ( rule . name ) == - 1 ;
7682 } ) ;
7783 }
@@ -93,9 +99,9 @@ export class Configuration {
9399 const expandedPaths = expandPaths ( rulePaths ) ;
94100 const rules = new Set ( [ ] ) ;
95101
96- expandedPaths . map ( ( rulePath ) => {
102+ expandedPaths . map ( rulePath => {
97103 let ruleMap = require ( rulePath ) ;
98- Object . keys ( ruleMap ) . forEach ( ( k ) => rules . add ( ruleMap [ k ] ) ) ;
104+ Object . keys ( ruleMap ) . forEach ( k => rules . add ( ruleMap [ k ] ) ) ;
99105 } ) ;
100106
101107 return Array . from ( rules ) ;
@@ -128,7 +134,7 @@ export class Configuration {
128134 }
129135 }
130136
131- const ruleNames = rules . map ( ( rule ) => rule . name ) ;
137+ const ruleNames = rules . map ( rule => rule . name ) ;
132138
133139 let misConfiguredRuleNames = [ ]
134140 . concat (
@@ -137,7 +143,7 @@ export class Configuration {
137143 this . options . rules || [ ]
138144 )
139145 . map ( toUpperCamelCase )
140- . filter ( ( name ) => ruleNames . indexOf ( name ) == - 1 ) ;
146+ . filter ( name => ruleNames . indexOf ( name ) == - 1 ) ;
141147
142148 if ( this . getFormatter ( ) == null ) {
143149 issues . push ( {
@@ -164,6 +170,6 @@ export class Configuration {
164170function toUpperCamelCase ( string ) {
165171 return string
166172 . split ( '-' )
167- . map ( ( part ) => part [ 0 ] . toUpperCase ( ) + part . slice ( 1 ) )
173+ . map ( part => part [ 0 ] . toUpperCase ( ) + part . slice ( 1 ) )
168174 . join ( '' ) ;
169175}
0 commit comments