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
258 stars 136 forks source link

Limit Linter to Specific Files or Patterns #68

Open sgtoj opened 4 years ago

sgtoj commented 4 years ago

Can a setting be added to use cfn-lint extension to lint specific GLOB patterns? I would like to set yaml.validate VS Code setting to enable for non-CloudFormation templates.

kddejong commented 4 years ago

I think the appropriate thing to do here, for now. Is to allow a person to configure if the YAML completion is enabled or disabled.

I'm trying to figure out a clever way to enable/disable as needed but it may be messy.

coyoteecd commented 4 years ago

It would be useful to exclude specific patterns as well. In my case, I use Serverless Framework to do deploys, and rely on this VSCode plugin + cfn-python-lint to do validation of the yml resources. This works reasonably well, except that the plugin tries to be smart and runs linting on the autogenerated .serverless/*.json files, which contains a json file that's not a CloudFormation template but seems to be picked as such.

A simple way to ignore a path via e.g. plugin settings would be great for my use case. A better way is for the plugin to take into account the .cfnlintrc that I have defined in the workspace root, in the same way as the cfn-lint command does when I run it there. This also addresses the use case mentioned in the top comment.

Thoughts?

sodaru-it commented 4 years ago

+1

r0zar commented 3 years ago

Just ran into this issue today as well working with serverless-state.json files

dead-claudia commented 2 years ago

I ran into this today with it picking up my local package.json (an exceptionally common Node config file - I shouldn't need to explain its significance), and its attempt to format the file ended up breaking it.

I decided to simply disable format on paste for JSON files specifically, as this isn't the only formatter that's given me grief with files of that format.

PatMyron commented 2 years ago

@dead-claudia as far as I'm aware, the cfn-lint extension does not currently format any files, any chance another extension is causing that formatting on paste?

kddejong commented 2 years ago

@sgtoj the current version of the plugin will only validate against CloudFormation templates. It no longer overrides the settings of redhat.vscode-yaml

@dead-claudia I will look into it. You can set cfnLint.format.enable so it doesn't format.

dead-claudia commented 2 years ago

@kddejong I normally use YAML exclusively for CFN configs anyways, so it wasn't all that painful to just disable.

@PatMyron Nothing else shows up in my list of JSON formatters when I ran "Format document with...", and it's extremely unlikely this is being caused by any other extension.

kddejong commented 2 years ago

Looking into better logic on the formatting functionality now.

Agreed let me see what it would look like to add some file pattern matching