From 73db588080bce2c75eb1a737d25cc0465a9cc6e0 Mon Sep 17 00:00:00 2001 From: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com> Date: Wed, 18 Jan 2023 15:20:42 +1300 Subject: [PATCH] chore(linting): configure go linter EE-4871 (#8288) --- api/.golangci.yaml | 26 ++++++++++++++++++++++++++ api/go.sum | 2 -- lint-staged.config.js | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 api/.golangci.yaml diff --git a/api/.golangci.yaml b/api/.golangci.yaml new file mode 100644 index 000000000..f6f418b8e --- /dev/null +++ b/api/.golangci.yaml @@ -0,0 +1,26 @@ +linters: + # Disable all linters. + disable-all: true + enable: + - depguard +linters-settings: + depguard: + list-type: denylist + include-go-root: true + packages: + - github.com/sirupsen/logrus + - golang.org/x/exp + packages-with-error-message: + - github.com/sirupsen/logrus: 'logging is allowed only by github.com/rs/zerolog' + ignore-file-rules: + - "**/*_test.go" + # Create additional guards that follow the same configuration pattern. + # Results from all guards are aggregated together. + # additional-guards: + # - list-type: allowlist + # include-go-root: false + # packages: + # - github.com/sirupsen/logrus + # # Specify rules by which the linter ignores certain files for consideration. + # ignore-file-rules: + # - "!**/*_test.go" \ No newline at end of file diff --git a/api/go.sum b/api/go.sum index b458ae933..141febe3c 100644 --- a/api/go.sum +++ b/api/go.sum @@ -344,8 +344,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/portainer/docker-compose-wrapper v0.0.0-20221122145319-915b021aea84 h1:d1P8i0pCPvAfxH6nSLUFm6NYoi8tMrIpafaZXSV8Lac= -github.com/portainer/docker-compose-wrapper v0.0.0-20221122145319-915b021aea84/go.mod h1:03UmPLyjiPUexGJuW20mQXvmsoSpeErvMlItJGtq/Ww= github.com/portainer/docker-compose-wrapper v0.0.0-20221215210951-2c30d1b17a27 h1:PceCpp86SDYb3lZHT4KpuBCkmcJMW5x1qrdFNEfAdUo= github.com/portainer/docker-compose-wrapper v0.0.0-20221215210951-2c30d1b17a27/go.mod h1:03UmPLyjiPUexGJuW20mQXvmsoSpeErvMlItJGtq/Ww= github.com/portainer/libcrypto v0.0.0-20220506221303-1f4fb3b30f9a h1:B0z3skIMT+OwVNJPQhKp52X+9OWW6A9n5UWig3lHBJk= diff --git a/lint-staged.config.js b/lint-staged.config.js index 488d1e385..c8ddbc757 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -2,4 +2,5 @@ module.exports = { '*.(js|ts){,x}': 'eslint --cache --fix', '*.(ts){,x}': () => 'tsc --noEmit', '*.{js,ts,tsx,css,md,html,json}': 'prettier --write', + '*.go': 'golangci-lint run -c api/.golangci.yaml', };