diff --git a/pkgs/by-name/ts/tsgolint/package.nix b/pkgs/by-name/ts/tsgolint/package.nix new file mode 100644 index 000000000000..c2e683725582 --- /dev/null +++ b/pkgs/by-name/ts/tsgolint/package.nix @@ -0,0 +1,63 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, + findutils, + applyPatches, + go, +}: + +buildGoModule (finalAttrs: { + pname = "tsgolint"; + version = "v0.10.1"; + + src = applyPatches rec { + src = fetchFromGitHub { + owner = "oxc-project"; + repo = "tsgolint"; + tag = finalAttrs.version; + hash = "sha256-6cDQjYVNfujIh3s+9pNCfqUEtfdvgx66oZoENqpJ7jE="; + fetchSubmodules = true; + }; + prePatch = '' + cd typescript-go + ''; + # These patches are applied to the typescript-go submodule in justfile's "init" target upstream. + patches = [ + (src + "/patches/0001-Parallel-readDirectory-visitor.patch") + (src + "/patches/0002-Adapt-project-service-for-single-run-mode.patch") + (src + "/patches/0003-patch-expose-more-functions-via-the-shim-with-type-f.patch") + (src + "/patches/0004-feat-improve-panic-message-for-extracting-TS-extensi.patch") + (src + "/patches/0005-fix-early-return-from-invalid-tsconfig-for-better-er.patch") + ]; + # We don't want to build with go.work, so we add the replacement to + # the local module to the go.mod instead. + postPatch = '' + cd .. + ${lib.getExe go} mod edit --replace=github.com/microsoft/typescript-go=./typescript-go + ''; + }; + + nativeBuildInputs = [ findutils ]; + + # From justfile's "init" target upstream. + postPatch = '' + rm go.work{,.sum} + mkdir -p internal/collections && find ./typescript-go/internal/collections -type f ! -name '*_test.go' -exec cp {} internal/collections/ \; + ''; + + proxyVendor = true; + vendorHash = "sha256-t1qyCdMeA5rh5/9yQ9LAhRO+0nSiMyFHp3sSPOJQWQA="; + + subPackages = [ "cmd/tsgolint" ]; + + env.GOEXPERIMENT = "greenteagc"; + + meta = { + description = "Type aware linting for oxlint"; + homepage = "https://github.com/oxc-project/tsgolint"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ jnsgruk ]; + mainProgram = "tsgolint"; + }; +})