Skip to content

Commit 39a0adb

Browse files
committed
Allow adding extra grammar scopes as a configuration option
1 parent 266288d commit 39a0adb

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

lib/atom-cfn-lint.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = {
6969
items: {
7070
type: 'string'
7171
},
72-
description: 'Ignore Rules (space deliminated)'
72+
description: 'Ignore Rules (space delimited)'
7373
},
7474
appendRules: {
7575
title: 'Append Rules Directory',
@@ -78,13 +78,22 @@ module.exports = {
7878
items: {
7979
type: 'string'
8080
},
81-
description: 'Append Rules Directory (space deliminated)'
81+
description: 'Append Rules Directory (space delimited)'
8282
},
8383
overrideSpecPath: {
8484
title: 'Override Spec file path',
8585
type: 'string',
8686
description: '(Optional) Path to an override specfile json file',
8787
default: ''
88+
},
89+
extraGrammarScopes: {
90+
title: 'Extra grammar scopes',
91+
type: 'array',
92+
default: [],
93+
items: {
94+
type: 'string'
95+
},
96+
description: '(Optional) Allows to apply the linter to other grammar scopes than the defaults source.yaml and source.json. E.g.: source.yaml.cf (Space delimited)'
8897
}
8998
},
9099
// activate linter
@@ -108,8 +117,17 @@ module.exports = {
108117
'atom-cfn-lint.overrideSpecPath',
109118
(value) => { this.overrideSpecPath = value }
110119
),
120+
atom.config.observe(
121+
'atom-cfn-lint.extraGrammarScopes',
122+
(value) => { this.extraGrammarScopes = value }
123+
),
111124
)
112125

126+
this.grammarScopes = ['source.yaml', 'source.json']
127+
if (Array.isArray(this.extraGrammarScopes) && this.extraGrammarScopes.length) {
128+
this.grammarScopes.push.apply(this.grammarScopes, this.extraGrammarScopes)
129+
}
130+
113131
scheduleIdleTasks()
114132
},
115133

@@ -122,7 +140,7 @@ module.exports = {
122140
provideLinter() {
123141
return {
124142
name: 'Cfn-Lint',
125-
grammarScopes: ['source.yaml', 'source.json'],
143+
grammarScopes: this.grammarScopes,
126144
scope: 'file',
127145
lintsOnChange: false,
128146
lint: (activeEditor) => {

0 commit comments

Comments
 (0)