Unverified Commit 421c80bd authored by Jon Seager's avatar Jon Seager
Browse files

tsgolint: init at 0.10.1



Co-authored-by: default avatarPaul Meyer <katexochen0@gmail.com>
parent 4058ce9d
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
{
  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";
  };
})