From 9ff62bf219171b0fddd357800f7e47b738b20365 Mon Sep 17 00:00:00 2001 From: Sebastian Cruz Date: Mon, 17 Sep 2018 17:09:54 +0100 Subject: [PATCH 1/2] Allow adding extra grammar scopes as a configuration option --- lib/atom-cfn-lint.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/atom-cfn-lint.js b/lib/atom-cfn-lint.js index 74c9850..3e77660 100644 --- a/lib/atom-cfn-lint.js +++ b/lib/atom-cfn-lint.js @@ -69,7 +69,7 @@ module.exports = { items: { type: 'string' }, - description: 'Ignore Rules (space deliminated)' + description: 'Ignore Rules (space delimited)' }, appendRules: { title: 'Append Rules Directory', @@ -78,13 +78,22 @@ module.exports = { items: { type: 'string' }, - description: 'Append Rules Directory (space deliminated)' + description: 'Append Rules Directory (space delimited)' }, overrideSpecPath: { title: 'Override Spec file path', type: 'string', description: '(Optional) Path to an override specfile json file', default: '' + }, + extraGrammarScopes: { + title: 'Extra grammar scopes', + type: 'array', + default: [], + items: { + type: 'string' + }, + 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)' } }, // activate linter @@ -108,8 +117,17 @@ module.exports = { 'atom-cfn-lint.overrideSpecPath', (value) => { this.overrideSpecPath = value } ), + atom.config.observe( + 'atom-cfn-lint.extraGrammarScopes', + (value) => { this.extraGrammarScopes = value } + ), ) + this.grammarScopes = ['source.yaml', 'source.json'] + if (Array.isArray(this.extraGrammarScopes) && this.extraGrammarScopes.length) { + this.grammarScopes.push.apply(this.grammarScopes, this.extraGrammarScopes) + } + scheduleIdleTasks() }, @@ -122,7 +140,7 @@ module.exports = { provideLinter() { return { name: 'Cfn-Lint', - grammarScopes: ['source.yaml', 'source.json'], + grammarScopes: this.grammarScopes, scope: 'file', lintsOnChange: false, lint: (activeEditor) => { From 5d50b347e92d80465422841327926aff4bf678a7 Mon Sep 17 00:00:00 2001 From: Sebastian Cruz Date: Mon, 17 Sep 2018 22:13:05 +0100 Subject: [PATCH 2/2] Use spread operator and fixed indentation to satisfy tests --- lib/atom-cfn-lint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/atom-cfn-lint.js b/lib/atom-cfn-lint.js index 3e77660..ae35ab7 100644 --- a/lib/atom-cfn-lint.js +++ b/lib/atom-cfn-lint.js @@ -125,7 +125,7 @@ module.exports = { this.grammarScopes = ['source.yaml', 'source.json'] if (Array.isArray(this.extraGrammarScopes) && this.extraGrammarScopes.length) { - this.grammarScopes.push.apply(this.grammarScopes, this.extraGrammarScopes) + this.grammarScopes.push(...this.extraGrammarScopes) } scheduleIdleTasks()