-
Notifications
You must be signed in to change notification settings - Fork 723
Forbid platform specific package uses in agnostic files #1911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a linter rule to prevent accidental usage of Go's standard path
and path/filepath
packages, enforcing the use of the internal tspath
package instead. This helps external contributors avoid compatibility issues since the codebase uses custom path handling.
- Enables the
forbidigo
linter to detect and flag usage of standard path libraries - Configures exemptions for test files, tools, and specific internal packages where standard path usage is acceptable
- Adds a lint suppression comment to one existing legitimate use case in
extension.go
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
.golangci.yml | Adds forbidigo linter with pattern rules to forbid path/filepath packages and defines exemption paths for tests and tools |
internal/tspath/extension.go | Adds nolint comment to exempt legitimate filepath.Ext usage |
cmd := exec.Command("npm", args...) | ||
cmd.Dir = cwd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of a hack but I prefer this greatly to there being any chance that tests run npm install
.
Mainly for external PRs which don't realize that our paths are usually incompatible with the stdlib packages (especially
filepath
) outside certain circumstances.Same goes for
os
,runtime.GOOS
.