{"id":14984807,"url":"https://github.com/bartekbp/typescript-checkstyle","last_synced_at":"2025-04-10T22:38:39.865Z","repository":{"id":72434138,"uuid":"332212388","full_name":"bartekbp/typescript-checkstyle","owner":"bartekbp","description":"Command line tool to convert tsc output to checkstyle format ","archived":false,"fork":false,"pushed_at":"2021-07-16T20:16:05.000Z","size":226,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T19:22:24.766Z","etag":null,"topics":["checkstyle","javascript","jenkins","tsc","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bartekbp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-23T13:06:46.000Z","updated_at":"2023-05-17T18:27:39.000Z","dependencies_parsed_at":"2023-06-01T16:15:36.966Z","dependency_job_id":null,"html_url":"https://github.com/bartekbp/typescript-checkstyle","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"c751fafec2c54732d468c739adaa26f375fdc7f6"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartekbp%2Ftypescript-checkstyle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartekbp%2Ftypescript-checkstyle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartekbp%2Ftypescript-checkstyle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartekbp%2Ftypescript-checkstyle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bartekbp","download_url":"https://codeload.github.com/bartekbp/typescript-checkstyle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312010,"owners_count":21082633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checkstyle","javascript","jenkins","tsc","typescript"],"created_at":"2024-09-24T14:09:41.934Z","updated_at":"2025-04-10T22:38:39.845Z","avatar_url":"https://github.com/bartekbp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typescript-checkstyle\nTypescript-checkstyle is a tool for reporting `typescript compiler` output in `checkstyle` format. It was created to improve pull request decoration with compiler errors.\n\n## Prerequisites\nProject requires:\n- nodejs 10\n- npm\n\n## Installation\nAll arifacts are published to npm. To use the latest version, you can install it using:\n```\nnpm i --save-dev @bartekbp/typescript-checkstyle\n```\n\n## Usage\nTypescript-checkstyle can be used from command line and javascript.\n\n### Command line\nLibrary reads `tsc` output from standard input. You may want to run both of them together. The following command typechecks your project and shows compilation errors in `checkstyle` format:\n```\n\u003e npx tsc --noEmit | npx @bartekbp/typescript-checkstyle\n```\n\nIf you already have `npm scripts` configured and want to use output from one of them to  typescript-checkstyle, you need to invoke `npm` with **--silent** to suppress npm prologue:\n```\n\u003e npm --silent run lint:tsc | npx @bartekbp/typescript-checkstyle\n```\n\n### Pull request decoration with typescript errors\nIf you want to automate adding comments to your pull request based on complier output, typescript-checkstyle will help you achieve it. To configure it, I will use `jenkins`, but the solution applies to other continuous integration systems as well.\n\n#### Jenkins pipleline\n\nYou need to setup a `jenkins pipeline` that will be triggered with [bitbucket branch source plugin](https://plugins.jenkins.io/cloudbees-bitbucket-branch-source/) or [github branch source plugin](https://github.com/jenkinsci/github-branch-source-plugin). In the pipeline you need to run typescript-checkstyle with `tsc` and redirect output to a file:\n```\nstage('tsc') {\n  steps {\n    sh  'npx tsc --noEmit | npx @bartekbp/typescript-checkstyle \u003e tsc-checkstyle.xml'\n  }\n}\n```\nDepending on your code review system, **tomasbjerre** created different plugins for pull request decoration. You can find the full list of them at the bottom of [violations-lib readme](https://github.com/tomasbjerre/violations-lib). I'll focus on the configuration for `bitbucket cloud`.\n\nYou need to update pipeline with additional stage for pr decoration:\n\u003cpre\u003e\nstage('Decorate pr') {\n  steps {\n    withCredentials([usernamePassword(credentialsId: \u003cstrong\u003e'jenkins-pr-writes'\u003c/strong\u003e, passwordVariable: 'JENKINS_VIOLATION_PASSWORD', usernameVariable: 'JENKINS_VIOLATION_USER')]) {\n      sh 'npx violation-comments-to-bitbucket-cloud-command-line -u \"$JENKINS_VIOLATION_USER\" -p \"$JENKINS_VIOLATION_PASSWORD\" -ws \u003cstrong\u003eworkspace\u003c/strong\u003e -rs \u003cstrong\u003erepoName\u003c/strong\u003e -prid \"$CHANGE_ID\" -v \"CHECKSTYLE\" \".\" \".*tsc-checkstyle.xml$\" \"tsc\" || true'\n    }\n  }\n}\n\u003c/pre\u003e\nThe bold parts in the stage needs to updated to reflect your project:\n- **jenkins-pr-writes** with credentials to bitbucket user\n- **workspace** with bitbucket workspace\n- **repoName** with repository that has an opened pull request\n\n\n### Javascript\nTypescript-checkstyle exposes one function `format`:\n```\n/**\n * Converts tsc errors to checkstyle format\n *\n * @param {string} input - errors from tsc\n * @return {string} errors in checkstyle format\n function format(input) {}\n */\n```\nYou can use it as follows:\n```\nimport format from '@bartekbp/typescript-checkstyle';\n\nconst input = `src/test.component.ts(3, 12): error TS2564: Property 'name' has no initializer`;\nconst errorsInCheckstyleFormat = format(input);\nconsole.log(errorsInCheckstyleFormat);\n```\n\nThis code prints out errors from `input` in checkstyle format.\n\n## License\n\nDistributed under the MIT License. See LICENSE for more information.\n\n## Acknowledgements\nGreat thanks to:\n- [tomasbjerre](https://github.com/tomasbjerre) for his tools enabling pull request decoration\n- [aivenkimmob](https://github.com/aivenkimmob) for tsc output parser\n- [jimf](https://github.com/jimf) for tool to convert json to xml checkstyle format\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartekbp%2Ftypescript-checkstyle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartekbp%2Ftypescript-checkstyle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartekbp%2Ftypescript-checkstyle/lists"}