Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninmonkey/90050529ee45f6c5821dcee015e1be79 to your computer and use it in GitHub Desktop.
Save ninmonkey/90050529ee45f6c5821dcee015e1be79 to your computer and use it in GitHub Desktop.
validation of Format.ps1xml, Types.ps1xml, and custom Json configurations.md

Powershell types

Grab the addon: https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml And add this to your config (settings.json)

// schema for Powershell
"xml.fileAssociations": [
    {
        "systemId": "https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Format.xsd",
        "pattern": "**/*.Format.ps1xml"
    },
    {
        "systemId": "https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Schemas/Types.xsd",
        "pattern": "**/*.Types.ps1xml"
    }
],

You don't need to download these, but the source is: https://github.com/PowerShell/PowerShell/tree/master/src/Schemas

Related options

    // these have higher precendence than extensions
"files.associations": {
    // always highlight .json as if they are .jsonc, because many are
    "*.json": "jsonc",
    // If you don't want an addon, you can still
    // get xml syntax highlighting using:
    "*.ps1xml": "xml", 
    "*.psm1": "powershell",       
    ".batrc": "shellscript",
},

Json Schema support is builtin, choose either:

[1] using $schema

{
  "$schema": "https://json.schemastore.org/coffeelint"
}

[2] using settings.config

"json.schemas": [
    {
        "fileMatch": [
            "/.babelrc"
        ],
        "url": "https://json.schemastore.org/babelrc"
    }
]

[3] using an addon with contributes.jsonValidation

See also:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment