Vscode-yaml: Disable schema detection for certain files

Created on 7 Nov 2019  路  5Comments  路  Source: redhat-developer/vscode-yaml

First of all, great extension. It is really useful to have yaml files validated (and auto-completed).

However, I have a file in my codebase called some.thing-sam.yml and I get red squiggle marks (linting errors) on valid properties. I believe what happens is that this extension treats the file as a AWS CloudFormation Serverless Application Model (SAM) file, which it isn't.

I have found a similar issue #98 where the schemaStore validation is disabled completely. But this is not what I want. Ideally I could provide a re-mapping of the file extension, as I believe the filename pattern is the culprit. Renaming the file to anything else but *sam.yml works.

Paraphrasing: Naming a yaml file *sam.yml will trick this extension (or the yaml-language-server) into treating the file as an AWS CloudFormation Serverless Application Model. There should be a way to fix this for the user.

I tried to provide a mapping in my VSCode settings myself, but without any luck:

{
    "yaml.schemas": {
        "https://raw.githubusercontent.com/awslabs/goformation/master/schema/sam.schema.json": "foo.bar"
    }
}

Also noteworthy, the catalog.json has this configuration in place:

    [...]
    {

      "name": "AWS CloudFormation Serverless Application Model (SAM)",

      "description": "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.",

      "fileMatch": [

        "*.sam.json",

        "*.sam.yml",

        "*.sam.yaml",

        "sam.json",

        "sam.yml",

        "sam.yaml"

      ],

      "url": "https://raw.githubusercontent.com/awslabs/goformation/master/schema/sam.schema.json"

    },
    [...]

Judging from the glob patterns my file (some.thing-sam.yml) shouldn't have been picked up for linting with that schema in the first place, should it?

[EDIT]
It seems the user configuration is merged. I can successfully create a file foo.barand change the file type to YAML and the linting errors are the same. Changing the file extension mapping to foo.foo makes the squiggle lines disappear.

enhancement help wanted

Most helpful comment

Same issue here with a file called something.deploy.yml, seems to think my file should match "https://raw.githubusercontent.com/deployphp/deployer/master/src/schema.json", but it is just a GitHub Actions workflow...

All 5 comments

I'm hitting a weirder one where a file named somethingcodegen.yaml is detected as some other schema, probably this one:

   {
      "name": "GraphQL Code Generator",
      "description": "JSON Schema for GraphQL Code Generator config file",
      "url": "https://raw.githubusercontent.com/dotansimha/graphql-code-generator/master/website/static/config.schema.json",
      "fileMatch": [
        "codegen.yml",
        "codegen.yaml",
        "codegen.json",
        "codegen.js",
        ".codegen.yml",
        ".codegen.yaml",
        ".codegen.json",
        ".codegen.js"
      ]
    },

Despite the patterns not having a glob asterisk, and there doesn't seem to be a way to ignore that... Annoyingly codegen.yaml is a rather generic name that conflicts with others but that's a problem with schemastore.

Same issue here with a file called something.deploy.yml, seems to think my file should match "https://raw.githubusercontent.com/deployphp/deployer/master/src/schema.json", but it is just a GitHub Actions workflow...

Running into something similar as above with a file named docker-compose.deploy.yml. It seems to register the Docker and DeployPHP schemas simultaneously. It would nice if I could just disable the DeployPHP schema for files with this name.

running into similar issue with golangci.yml would be nice if i can exclude this explicitly an example of the configuration could be found https://github.com/golangci/golangci-lint here

I have the same problem with file match from Ansible in a file structure for Concourse CI (like in https://github.com/redhat-developer/vscode-yaml/issues/145#issuecomment-478661866).

|- ci
   |- pipeline.yml
   |- tasks
      |- task1.yml
      |- task2.yml

Even if I add a more specific custom schema for tasks, it would stack both schemas and the error persists:

    "yaml.schemas": {
        "https://gist.githubusercontent.com/JohnLBevan/5580a2cb17eac18c646c7c87021e5169/raw/79a0bef617b8a88e2d4d2de41904a4f677abaf8f/concourse.task.schema.json": "ci/tasks/*.yml"
    }
}

image

Have the ability to disable a specific schema, or override its path would be great. I also don't want to completely disable yaml.schemaStore.enableby setting it as false (that would work to get rid of the errors, but at the same time I lost the validation from all other schemas).

Was this page helpful?
0 / 5 - 0 ratings