diff --git a/.golangci.yml b/.golangci.yml index 6ecf7b4..6ab2599 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -376,13 +376,3 @@ linters: rules: - text: 'shadow: declaration of "err" shadows declaration at' linters: [govet] - - path: '_test\.go' - linters: - - bodyclose - - dupl - - errcheck - - funlen - - goconst - - gosec - - noctx - - wrapcheck diff --git a/Makefile b/Makefile index 381984e..b9018c2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # BEGIN: lint-install . -# http://github.com/tinkerbell/lint-install +# http://github.com/codeGROOVE-dev/lint-install .PHONY: lint lint: _lint diff --git a/Makefile.tmpl b/Makefile.tmpl index a4ff787..4826cd0 100644 --- a/Makefile.tmpl +++ b/Makefile.tmpl @@ -1,6 +1,6 @@ # BEGIN: lint-install {{.Args}} -# http://github.com/tinkerbell/lint-install +# http://github.com/codeGROOVE-dev/lint-install .PHONY: lint lint: _lint diff --git a/README.md b/README.md index 4cb12d1..31fb98a 100644 --- a/README.md +++ b/README.md @@ -3,26 +3,38 @@ [![GoReport Widget]][GoReport Status] [![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable) -[GoReport Status]: https://goreportcard.com/report/github.com/tinkerbell/lint-install -[GoReport Widget]: https://goreportcard.com/badge/github.com/tinkerbell/lint-install +[GoReport Status]: https://goreportcard.com/report/github.com/codeGROOVE-dev/lint-install +[GoReport Widget]: https://goreportcard.com/badge/github.com/codeGROOVE-dev/lint-install -Idiomatic linters for opinionated projects. +Automated linter installation and configuration for consistent code quality across teams and environments. -This tool installs well-configured linters to any project, open-source or -otherwise. The linters can be used in a repeatable and consistent way across CI, -local tests, and IDE's. +## Why lint-install? -lint-install adds linter configuration to the root of your project, and Makefile -rules to install a consistently versioned set of linters to be used in any -environment. These Makefile rules can also be upgrading by lint-install, updating -all environments simultaneously. +Maintaining consistent code quality across a team can be challenging. Different developers might use different linters, versions, or configurations, leading to: + +- **Inconsistent code reviews** - Style debates instead of logic discussions +- **CI/CD failures** - Code that passes locally but fails in CI due to different linter versions +- **Configuration drift** - Each project reinventing its own linting setup +- **Onboarding friction** - New contributors struggling with tooling setup + +lint-install solves these problems by providing: + +- **One command setup** - Instantly adds industry-standard linters to any project +- **Version pinning** - Everyone uses the exact same linter versions +- **Consistent configuration** - Opinionated, battle-tested linter rules +- **Easy updates** - Upgrade all linters across your entire team with one command +- **Multi-environment support** - Same linting in local development, CI/CD, and IDEs + +## How it works + +lint-install adds Makefile rules and linter configurations to your project root. It installs specific versions of well-configured linters that can be used consistently by all contributors, whether they're working locally, in CI, or using an IDE. Currently supported languages: -- Go -- Shell -- Dockerfile -- YAML +- **Go** - golangci-lint with comprehensive checks +- **Shell** - shellcheck for POSIX compliance and best practices +- **Dockerfile** - hadolint for security and best practices +- **YAML** - yamllint for syntax and style ## Philosophy @@ -30,21 +42,72 @@ Currently supported languages: - Improve readability as much as possible. - Be idiomatic: only raise issues that the language authors would flag +## Installation + +```bash +go install github.com/codeGROOVE-dev/lint-install@latest +``` + ## Usage -Installation: +### Basic usage -`go get github.com/tinkerbell/lint-install` +Add linters to your project: -Add Makefile rules for a git repository: +```bash +lint-install . +``` + +This creates: +- Makefile rules for installing and running linters +- Configuration files for each detected language +- A `.gitignore` entry for the linter binaries + +Run the linters: + +```bash +make lint +``` -`$HOME/go/bin/lint-install ` +### Examples -Users can then lint the project using: +**Adding linters to a Go project:** +```bash +cd my-go-project +lint-install . +make lint +``` -`make lint` +**Selective language support:** +```bash +# Only add Go and Shell linters, ignore others +lint-install -dockerfile=ignore -yaml=ignore . +``` -Other options: +**Preview changes without applying:** +```bash +lint-install -dry-run . +``` + +**CI/CD integration:** +```yaml +# GitHub Actions example +- name: Install linters + run: make lint-install + +- name: Run linters + run: make lint +``` + +**Updating linter versions:** +```bash +# Re-run lint-install to update to latest versions +lint-install . +git add Makefile .*.version +git commit -m "Update linter versions" +``` + +### Command-line options ``` -dockerfile string @@ -60,3 +123,39 @@ Other options: -yaml string Level to lint YAML with: [ignore, warn, error] (default "error") ``` + +### What gets added to your project + +1. **Makefile targets:** + - `make lint` - Run all configured linters + - `make lint-` - Run specific language linter + - `make lint-install` - Install the linter binaries + +2. **Configuration files:** + - `.golangci.yml` - Go linting rules + - `.hadolint.yaml` - Dockerfile linting rules + - `.yamllint` - YAML linting rules + - `.*.version` files - Pinned linter versions + +3. **Linter binaries:** + - Installed to `./out/linters/` (git-ignored) + - Consistent versions across all environments + +## Features + +- **Zero configuration** - Sensible defaults that work for most projects +- **Language detection** - Automatically identifies which linters to install +- **Version management** - Pins linter versions for reproducible builds +- **Makefile integration** - Works with existing build systems +- **Incremental adoption** - Control which languages to lint +- **IDE friendly** - Linters work with VSCode, GoLand, and other editors +- **Fast installation** - Downloads pre-built binaries when available +- **Cross-platform** - Works on Linux, macOS, and Windows + +## Contributing + +Contributions are welcome! Please feel free to submit issues or pull requests. + +## License + +See [LICENSE](LICENSE) for details. diff --git a/go.mod b/go.mod index b3b5257..549e1e7 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tinkerbell/lint-install +module github.com/codeGROOVE-dev/lint-install go 1.22