Skip to content

Commit 795aed6

Browse files
committed
Add additional configration values
1 parent 3245e14 commit 795aed6

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ Requires cfn-lint to be installed. `pip install cfn-lint`
1717
## Extension Settings
1818

1919
* `cfnLint.path`: path to the cfn-lint command
20+
* `cfnLint.appendRules`: Array of paths containing additional Rules
21+
* `cfnLint.ignoreRules`: Array of Rule Ids to be ignored
22+
* `cfnLint.overrideSpecPath`: Path to an Specification overrule file

package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,23 @@
4545
"type": "string",
4646
"default": "cfn-lint",
4747
"description": "Path to cfn-lint"
48+
},
49+
"cfnLint.appendRules": {
50+
"type": "array",
51+
"default": [],
52+
"description": "Append Rules Directories"
53+
},
54+
"cfnLint.ignoreRules": {
55+
"type": "array",
56+
"default": [],
57+
"description": "Ignore Rules"
58+
},
59+
"cfnLint.overrideSpecPath": {
60+
"type": "string",
61+
"default": "",
62+
"description": "(Optional) Path to an override specfile json file"
4863
}
4964
}
5065
}
5166
}
52-
}
67+
}

server/src/server.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,29 @@ interface Settings {
6666
// file
6767
interface CloudFormationLintSettings {
6868
path: string;
69+
appendRules: Array<string>;
70+
ignoreRules: Array<string>;
71+
overrideSpecPath: string;
6972
}
7073

71-
// hold the Path setting
74+
// hold the Settings
7275
let Path: string;
76+
let AppendRules: Array<string>;
77+
let IgnoreRules: Array<string>;
78+
let OverrideSpecPath: string;
79+
7380
// The settings have changed. Is send on server activation as well.
7481
connection.onDidChangeConfiguration((change) => {
7582
console.log('Settings have been updated...');
7683
let settings = <Settings>change.settings;
77-
console.log('Settings: ' + settings);
84+
console.log('Settings: ' + JSON.stringify(settings));
85+
7886
Path = settings.cfnLint.path || 'cfn-lint';
87+
IgnoreRules = settings.cfnLint.ignoreRules;
88+
OverrideSpecPath = settings.cfnLint.overrideSpecPath;
89+
AppendRules = settings.cfnLint.appendRules;
90+
7991
// Revalidate any open text documents
80-
console.log('Path set to: ' + Path);
8192
documents.all().forEach(validateCloudFormationFile);
8293
});
8394

@@ -122,6 +133,26 @@ function validateCloudFormationFile(document: TextDocument): void {
122133
if (is_cfn) {
123134
let args = ['--format', 'json', '--template', file_to_lint];
124135

136+
if (IgnoreRules.length > 0) {
137+
args.push('--ignore-checks')
138+
139+
for (var ignoreRule of IgnoreRules) {
140+
args.push(ignoreRule)
141+
}
142+
}
143+
144+
if (AppendRules.length > 0) {
145+
args.push('--append-rules')
146+
147+
for (var appendRule of AppendRules) {
148+
args.push(appendRule)
149+
}
150+
}
151+
152+
if (OverrideSpecPath !== "") {
153+
args.push('--override-spec', OverrideSpecPath)
154+
}
155+
125156
connection.console.log(`running............. ${Path} ${args}`);
126157

127158
let child = spawn(

0 commit comments

Comments
 (0)