1

我正在寻找一种在安装扩展程序时将初始设置写入 settings.json 的方法。

我找到了 WorkspaceConfiguration API,但这似乎是在运行时检索/更新值。

我希望将我的设置 + 注释放入默认设置文件中

例如 TSLint 是如何做到的: 在此处输入图像描述

4

1 回答 1

1

我希望我能正确回答您的问题:我假设您的意思是用户设置 settings.json,您可以通过 File>Preferences>User Settings 获得。

如果您知道 TSLint 会这样做,您可以转到您的扩展文件夹(windows:$USERFOLDER/.vscode/extensions),选择扩展名(在我的情况下是文件夹“eg2.tslint-0.6.7”)并查看文件。

...
"contributes": {
    "configuration": {
        "type": "object",
        "title": "TSLint",
        "properties": {
            "tslint.enable": {
                "type": "boolean",
                "default": true,
                "description": "Control whether tslint is enabled for TypeScript files or not."
            },
            "tslint.rulesDirectory": {
                "type": [
                    "string",
                    "array"
                ],
                "items": {
                    "type": "string"
                },
                "description": "An additional rules directory",
                "default": ""
            },
            "tslint.validateWithDefaultConfig": {
                "type": "boolean",
                "description": "Validate a file when there is only a default tslint configuration is found",
                "default": false
            },
            "tslint.configFile": {
                "type": "string",
                "description": "The path to the rules configuration file",
                "default": ""
            },
            "tslint.ignoreDefinitionFiles": {
                "type": "boolean",
                "default": true,
                "description": "Control if TypeScript definition files should be ignored"
            },
            "tslint.exclude": {
                "type": [
                    "string",
                    "array"
                ],
                "items": {
                    "type": "string"
                },
                "description": "Configure glob patterns of file paths to exclude from linting"
            },
            "tslint.run": {
                "type": "string",
                "enum": [
                    "onSave",
                    "onType"
                ],
                "default": "onType",
                "description": "Run the linter on save (onSave) or on type (onType)"
            },
            "tslint.nodePath": {
                "type": "string",
                "default": "",
                "description": "A path added to NODE_PATH when resolving the tslint module."
            },
            "tslint.autoFixOnSave": {
                "type": "boolean",
                "default": false,
                "description": "Turns auto fix on save on or off."
            }
        }
    }
...

希望这可以帮助

于 2016-12-01T23:48:45.680 回答