aws-cloudformation / cfn-lint-visual-studio-code

CloudFormation Linter IDE integration, autocompletion, and documentation
https://marketplace.visualstudio.com/items?itemName=kddejong.vscode-cfn-lint
Apache License 2.0
259 stars 143 forks source link

How to work with .template #28

Open lesley-tw opened 5 years ago

lesley-tw commented 5 years ago

I have several *.template file, and all file begin with AWSTemplateFormatVersion: '2010-09-09' at first line, but I cannot get any lint on the file.

When I click other .yml file, it will output Don't believe this is a CloudFormation template., it correct, because it really not a cloudformation template, but when I click the cloudformation template .template file, it doesn't have any output messages.

Anyone could help? Should I modify any config?

kddejong commented 5 years ago

We do look for yaml and json files. From there we try to determine if they are a CloudFormation template.

Let me test a few things here. I think I can give you a more definitive solution.

kddejong commented 5 years ago

The quick fix on an individual file is to switch the language of the file.
https://code.visualstudio.com/docs/languages/overview#_changing-the-language-for-the-selected-file

You can more permanently make that change by following this. https://code.visualstudio.com/docs/languages/overview#_can-i-map-additional-file-extensions-to-a-language

@cmmeyer Not sure how far down this we should go. There is absolutely a contingent of .template folks. I'm not sure we could more globally enable .template as a CloudFormation template that we would then lint. I may have to see if there are some easier options for this. These workarounds above should provide a solution until we can discuss this more.

cmmeyer commented 5 years ago

I certainly have .template files on my laptop as well, but I've always expected I would have to tell my IDE what the actual contents were (YAML/JSON). CloudFormation isn't the only software that uses templates, and I'd hate to muck things up for folks who use ".template" to mean something else.

lesley-tw commented 5 years ago

@kddejong Thank you for the comment. It can work now.

rjlohan commented 5 years ago

Can we just expose the file mappings as a configuration option? Leave the defaults alone but allow overrides?

kddejong commented 5 years ago

@rjlohan possibly. We could change this to *. https://github.com/awslabs/aws-cfn-lint-visual-studio-code/blob/master/package.json#L19-L22

https://github.com/awslabs/aws-cfn-lint-visual-studio-code/blob/master/client/src/extension.ts#L39-L42

I think the problem is the .template doesn't associate with a language (unless someone installed a language plugin). We could add the ability to associate to an extension but I would have to look into this... I'm just not sure off the top of my head. The good thing is cfn-lint doesn't care about json or yaml.

We could better document this fix as well.

"files.associations": {
    "*.template": "yaml"
}