From e8885120aaffa92d6d228930e043e3076417d2eb Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 24 Jun 2023 15:36:26 +0200 Subject: [PATCH] docs: add configuration examples --- readme.md | 106 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 94 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index 1b0f587..ad2fa45 100644 --- a/readme.md +++ b/readme.md @@ -114,26 +114,108 @@ Define the rules, you want via your [golangci-lint](https://golangci-lint.run) c ```yaml linters-settings: tagliatelle: - # Check the struck tag name case. + # Check the struct tag name case. case: # Use the struct field name to check the name of the struct tag. # Default: false use-field-name: true + # Define the association between tag name and case. + # Any struct tag name can be used. + # Support string cases: + # - `camel` + # - `pascal` + # - `kebab` + # - `snake` + # - `upperSnake` + # - `goCamel` + # - `goPascal` + # - `goKebab` + # - `goSnake` + # - `upper` + # - `lower` + # - `header` + rules: + json: camel + yaml: camel + xml: camel + whatever: snake + # The field names to ignore. + # Default: [] + ignored-fields: + - Bar + - Foo + # Overrides the default/root configuration. + # Default: [] + overrides: + # The fully qualified package name. (uses `/` only) + # / + # Require + - pkg: example.com/foo/bar + # Default: false or the same as the default/root configuration. + use-field-name: true + # Default: empty or the same as the default/root configuration. + rules: + json: snake + xml: pascal + # The field names to ignore. + # Default: {} or the same as the default/root configuration. + ignored-fields: + - Bar + - Foo + # Ignore the package (take the precedence over all other configuration. + # Default: false + ignore: true +``` + +#### Examples + +Overrides case rules for the package `example.com/foo/bar`: + +```yaml +linters-settings: + tagliatelle: + case: + rules: + json: camel + yaml: camel + xml: camel + overrides: + - pkg: example.com/foo/bar + rules: + json: snake + xml: pascal +``` + +Ignore fields inside the package `example.com/foo/bar`: + +```yaml +linters-settings: + tagliatelle: + case: + rules: + json: camel + yaml: camel + xml: camel + overrides: + - pkg: example.com/foo/bar + ignored-fields: + - Bar + - Foo +``` + +Ignore the package `example.com/foo/bar`: + +```yaml +linters-settings: + tagliatelle: + case: rules: - # Any struct tag type can be used. - # Support string case: `camel`, `pascal`, `kebab`, `snake`, `upperSnake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`. json: camel yaml: camel xml: camel - overrides: - - pkg: foo/foo - use-field-name: true - rules: - json: snake - xml: pascal - ignored-fields: - - Bar - - Foo + overrides: + - pkg: example.com/foo/bar + ignore: true ``` More information here https://golangci-lint.run/usage/linters/#tagliatelle