diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5af4e33..e330dbc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -152,7 +152,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: schema.json - path: schema/schema.json + path: schema.json if-no-files-found: error web: diff --git a/schema.json b/schema.json new file mode 100644 index 0000000..ef5191c --- /dev/null +++ b/schema.json @@ -0,0 +1,523 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Config", + "description": "Config represents the configuration of commitlint.", + "type": "object", + "required": [ + "rules" + ], + "properties": { + "rules": { + "description": "Rules represents the rules of commitlint.", + "allOf": [ + { + "$ref": "#/definitions/Rules" + } + ] + } + }, + "definitions": { + "BodyEmpty": { + "description": "BodyEmpty represents the body-empty rule.", + "type": "object", + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "BodyMaxLength": { + "description": "BodyMaxLength represents the body-max-length rule.", + "type": "object", + "required": [ + "length" + ], + "properties": { + "length": { + "description": "Length represents the maximum length of the body.", + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "DescriptionEmpty": { + "description": "DescriptionEmpty represents the subject-empty rule.", + "type": "object", + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "DescriptionFormat": { + "description": "DescriptionFormat represents the description-format rule.", + "type": "object", + "properties": { + "format": { + "description": "Format represents the format of the description.", + "type": [ + "string", + "null" + ] + }, + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "DescriptionMaxLength": { + "description": "DescriptionMaxLength represents the description-max-length rule.", + "type": "object", + "required": [ + "length" + ], + "properties": { + "length": { + "description": "Length represents the maximum length of the description.", + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "FootersEmpty": { + "description": "FootersEmpty represents the footer-empty rule.", + "type": "object", + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "Level": { + "description": "Level represents the level of a rule.", + "type": "string", + "enum": [ + "error", + "ignore", + "warning" + ] + }, + "Rules": { + "description": "Rules represents the rules of commitlint. See: https://commitlint.js.org/reference/rules.html", + "type": "object", + "properties": { + "body-empty": { + "anyOf": [ + { + "$ref": "#/definitions/BodyEmpty" + }, + { + "type": "null" + } + ] + }, + "body-max-length": { + "anyOf": [ + { + "$ref": "#/definitions/BodyMaxLength" + }, + { + "type": "null" + } + ] + }, + "description-empty": { + "anyOf": [ + { + "$ref": "#/definitions/DescriptionEmpty" + }, + { + "type": "null" + } + ] + }, + "description-format": { + "anyOf": [ + { + "$ref": "#/definitions/DescriptionFormat" + }, + { + "type": "null" + } + ] + }, + "description-max-length": { + "anyOf": [ + { + "$ref": "#/definitions/DescriptionMaxLength" + }, + { + "type": "null" + } + ] + }, + "footers-empty": { + "anyOf": [ + { + "$ref": "#/definitions/FootersEmpty" + }, + { + "type": "null" + } + ] + }, + "scope": { + "anyOf": [ + { + "$ref": "#/definitions/Scope" + }, + { + "type": "null" + } + ] + }, + "scope-empty": { + "anyOf": [ + { + "$ref": "#/definitions/ScopeEmpty" + }, + { + "type": "null" + } + ] + }, + "scope-format": { + "anyOf": [ + { + "$ref": "#/definitions/ScopeFormat" + }, + { + "type": "null" + } + ] + }, + "scope-max-length": { + "anyOf": [ + { + "$ref": "#/definitions/ScopeMaxLength" + }, + { + "type": "null" + } + ] + }, + "subject-empty": { + "anyOf": [ + { + "$ref": "#/definitions/SubjectEmpty" + }, + { + "type": "null" + } + ] + }, + "type": { + "anyOf": [ + { + "$ref": "#/definitions/Type" + }, + { + "type": "null" + } + ] + }, + "type-empty": { + "anyOf": [ + { + "$ref": "#/definitions/TypeEmpty" + }, + { + "type": "null" + } + ] + }, + "type-format": { + "anyOf": [ + { + "$ref": "#/definitions/TypeFormat" + }, + { + "type": "null" + } + ] + }, + "type-max-length": { + "anyOf": [ + { + "$ref": "#/definitions/TypeMaxLength" + }, + { + "type": "null" + } + ] + } + } + }, + "Scope": { + "description": "Scope represents the subject-empty rule.", + "type": "object", + "required": [ + "optional", + "options" + ], + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + }, + "optional": { + "description": "Optional scope. If true, even if the scope is not present, it is allowed.", + "type": "boolean" + }, + "options": { + "description": "Options represents the options of the rule. If the option is empty, it means that no scope is allowed.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "ScopeEmpty": { + "description": "ScopeEmpty represents the subject-empty rule.", + "type": "object", + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "ScopeFormat": { + "description": "ScopeFormat represents the scope-format rule.", + "type": "object", + "properties": { + "format": { + "description": "Format represents the format of the scope.", + "type": [ + "string", + "null" + ] + }, + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "ScopeMaxLength": { + "description": "ScopeMaxLength represents the description-max-length rule.", + "type": "object", + "required": [ + "length" + ], + "properties": { + "length": { + "description": "Length represents the maximum length of the scope.", + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "SubjectEmpty": { + "description": "SubjectEmpty represents the subject-empty rule.", + "type": "object", + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "Type": { + "description": "Type represents the subject-empty rule.", + "type": "object", + "required": [ + "options" + ], + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + }, + "options": { + "description": "Options represents the options of the rule. If the option is empty, it means that no Type is allowed.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "TypeEmpty": { + "description": "TypeEmpty represents the type-empty rule.", + "type": "object", + "properties": { + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "TypeFormat": { + "description": "TypeFormat represents the type-format rule.", + "type": "object", + "properties": { + "format": { + "description": "Format represents the format of the type.", + "type": [ + "string", + "null" + ] + }, + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + }, + "TypeMaxLength": { + "description": "TypeMaxLength represents the description-max-length rule.", + "type": "object", + "required": [ + "length" + ], + "properties": { + "length": { + "description": "Length represents the maximum length of the type.", + "type": "integer", + "format": "uint", + "minimum": 0.0 + }, + "level": { + "description": "Level represents the level of the rule.", + "anyOf": [ + { + "$ref": "#/definitions/Level" + }, + { + "type": "null" + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/web/src/content/docs/config/IDE.md b/web/src/content/docs/config/IDE.md new file mode 100644 index 0000000..7d7a4f1 --- /dev/null +++ b/web/src/content/docs/config/IDE.md @@ -0,0 +1,83 @@ +--- +title: IDE +description: Guide how to setup your IDE to work with commitlint +--- + +Commitlint offers schema by supporting [JSON schema](https://json-schema.org/) so that you can configure your IDE to work with Commitlint and have better developer experience. + +:::tip + +If you want to pin the schema to a specific version, you can configure the version in the URL. + +```console +https://github.com/KeisukeYamashita/commitlint-rs/releases/download/v0.2.0/schema.json +``` + +In this case, the schema is pinned to version `0.2.0`. + +::: + +## Visual Studio Code + +Configure your [Visual Studio Code](https://code.visualstudio.com/) to work with Commitlint. + +### Edit in `settings.json` + +Update your user `settings.json` or workspace settings (`/.vscode/settings.json`) to configure the schema. + +#### JSON + +```json +"json.schemas": [ + { + "fileMatch": [ + ".commitlintrc", + ".commitlintrc.json" + ], + "url": "https://github.com/KeisukeYamashita/commitlint-rs/releases/latest/download/schema.json" + } +] +``` + +#### YAML + +Associating schemas with YAMLs are supported by the [YAML language server](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml). + +```json +"yaml.schemas": { + "https://github.com/KeisukeYamashita/commitlint-rs/releases/latest/download/schema.json": [ + ".commitlintrc", + ".commitlintrc.yaml", + ".commitlint.yml" + ] +} +``` + +### Specify schema in the configuration file + +```json +{ + "$schema": "https://github.com/KeisukeYamashita/commitlint-rs/releases/download/v0.2.0/schema.json", + "rules": {} +} +``` + +#### JSON + +Add the following comment in your `.commitlintrc` or `.commitlintrc.json` file. + +```json +{ + "$schema": "https://github.com/KeisukeYamashita/commitlint-rs/releases/latest/download/schema.json", + "rules": {} +} +``` + +#### YAML + +Associating schemas with YAMLs are supported by the [YAML language server](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml). Add the following comment in your `.commitlintrc`, `.commitlintrc.yaml` or `.commitlintrc.yml` file. + +```yaml +# yaml-language-server: $schema=https://github.com/KeisukeYamashita/commitlint-rs/releases/latest/download/schema.json +rules: +```