您可以通过多种方式将其添加到包设置菜单而不是 Atom 菜单中。
首先,有一种方法可以将其直接放入您的代码中。在我的包linter-ansible-linting 中考虑main.js 中的以下内容:
config: {
ansibleLintExecutablePath: {
title: 'Ansible-Lint Executable Path',
type: 'string',
description: 'Path to Ansible-Lint executable (e.g. /usr/bin/ansible-lint) if not in shell env path.',
default: 'ansible-lint',
},
useRulesDirs: {
title: 'Use non-default rules directories with Ansible-Lint.',
type: 'boolean',
default: false,
},
rulesDirs: {
title: 'Rules Directories',
type: 'array',
description: 'Non-default rules directories to use with Ansible-Lint. (only if use non-default rules directories checked)',
default: ['/usr/local/lib/python2.7/site-packages/ansiblelint/rules', '/usr/local/lib/python2.7/dist-packages/ansiblelint/rules'],
items: {
type: 'string'
}
}
}
你也可以把它放在package.json。考虑以下内容,Atom-Linter 组织内的其他人放入我维护的包中 linter-puppet-lint:
"configSchema": {
"executablePath": {
"title": "Executable path",
"type": "string",
"description": "Path to puppet-lint executable",
"default": "puppet-lint"
},
"automaticFix": {
"title": "Attempt to automatically fix warnings and errors",
"type": "boolean",
"default": false
},
}
这些将使配置设置在您的包的设置菜单中可用。您的具体设置将是 boolean,因此我建议您遵循该类型的格式。
buildAutomatically: {
title: 'Build Automatically',
type: 'boolean',
default: false,
}
"buildAutomatically: {
"title": "Build Automatically",
"type": "boolean",
"default": false
}