From 0f57b7f8178807625b564f5f242d3569991c835a Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 00:11:38 +0900 Subject: [PATCH 1/9] chore: change workflow name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96b0afb..d64ee4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ci +name: CI on: [push] From 71a59122a80ffcbccffdb1bf36b6c9a1e0b041b0 Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 00:14:05 +0900 Subject: [PATCH 2/9] docs: update readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7c6c6bf..7a755f0 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# ts-remove-unused - +

ts-remove-unused

+

Remove unused code from your TypeScript Project

+
[![npm version](https://badge.fury.io/js/@line%2Fts-remove-unused.svg)](https://badge.fury.io/js/@line%2Fts-remove-unused) - -> Remove unused code from your TypeScript project +[![CI](https://github.com/line/ts-remove-unused/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/line/ts-remove-unused/actions/workflows/ci.yml) ## Introduction From 43efb9eff0e9bcebe4e0a682d8262fc5d046c6c5 Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 00:32:30 +0900 Subject: [PATCH 3/9] docs: add features section --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7a755f0..05f0235 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ [![npm version](https://badge.fury.io/js/@line%2Fts-remove-unused.svg)](https://badge.fury.io/js/@line%2Fts-remove-unused) [![CI](https://github.com/line/ts-remove-unused/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/line/ts-remove-unused/actions/workflows/ci.yml) +## Features + +- ๐Ÿ› ๏ธ Auto-fix unused exports โ€” removes the `export` keyword from the declaration or the whole declaration based on its usage +- ๐Ÿงน Deletes TypeScript modules that have no referenced exports +- ๐Ÿ•ต๏ธ `--check` mode - reports unused exports and deletable files without writing changes + ## Introduction When you enable `compilerOptions.noUnusedLocals` for your TypeScript project, it's possible to detect declarations that are not referenced in your file. @@ -73,7 +79,7 @@ npm i -D @line/ts-remove-unused ``` Usage: - $ ts-remove-unused + $ ts-remove-unused Commands: There are no subcommands. Simply execute ts-remove-unused @@ -82,12 +88,12 @@ For more info, run any command with the `--help` flag: $ ts-remove-unused --help Options: - --project Path to your tsconfig.json - --skip Specify the regexp pattern to match files that should be skipped from transforming - --include-d-ts Include .d.ts files in target for transformation - --check Check if there are any unused exports without removing them - -h, --help Display this message - -v, --version Display version number + --project Path to your tsconfig.json + --skip Specify the regexp pattern to match files that should be skipped from transforming + --include-d-ts Include .d.ts files in target for transformation + --check Check if there are any unused exports without removing them + -h, --help Display this message + -v, --version Display version number ``` The CLI will respect the `tsconfig.json` for loading source files. From 5d88457c46a53b6f6b968f8c188cd97fc4ae6d3b Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 00:35:50 +0900 Subject: [PATCH 4/9] docs: update introduction explanation --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 05f0235..b2ad5ba 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ However when this declaration is exported and is not referenced by any file in t export const a = 'a'; ``` -This is when ts-remove-unused comes in handy. ts-remove-unused is a CLI tools made on top of TypeScript that reports/fixes unused exports. +This is when ts-remove-unused comes in handy. ts-remove-unused is a CLI tool made on top of TypeScript that reports/fixes unused exports. Let's say you have the following file: @@ -64,9 +64,9 @@ export const e = 'e'; When `d` and `e` are not used in all other files across the project, ts-remove-unused will delete the file for you. -Now you don't have to worry about removing your unused code! +ts-remove-unused supports various types of exports including variable declarations (`export const`, `export let`), function declarations, class declarations, interface declarations, type alias declarations, default exports and more... -ts-remove-unused supports various exports including variable declarations (`export const`, `export let`), function declarations, class declarations, interface declarations, type alias declarations, default exports... +Now you don't have to worry about removing unused code by yourself! ## Install From 42ffd08b924fcb74c32996458d7e4aa297122561 Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 00:42:12 +0900 Subject: [PATCH 5/9] docs: add author --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b2ad5ba..5eb6895 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,10 @@ export const hello = 'world'; By default, .d.ts files are skipped. If you want to include .d.ts files, use the --include-d-ts option. +## Author + +Kazushi Konosu (https://github.com/kazushisan) + ## License ``` From 2537e3c432150308d1aeb5017436ff8e19316e9e Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 00:53:28 +0900 Subject: [PATCH 6/9] docs: update docs expression --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5eb6895..48913d7 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ## Introduction -When you enable `compilerOptions.noUnusedLocals` for your TypeScript project, it's possible to detect declarations that are not referenced in your file. +When TypeScript's `compilerOptions.noUnusedLocals` is enabled, it's possible to detect declarations that are not referenced in your file. ```typescript // TypeScript will throw error: 'a' is declared but its value is never read. @@ -54,7 +54,7 @@ export const c = 'c'; console.log(b); ``` -If you have another file in your project: +Let's say you have another file in your project: ```typescript export const d = 'd'; @@ -106,8 +106,7 @@ npx ts-remove-unused --skip 'src\/index\.ts' ### Check -Use `--check` to check for unused files and exports without making changes to project files. The command will exit with -code: 1 if there are any unused files or exports discovered. +Use `--check` to check for unused files and exports without making changes to project files. The command will exit with exit code 1 if there are any unused files or exports discovered. ``` npx ts-remove-unused --check @@ -137,7 +136,7 @@ When you add a comment `// ts-remove-unused-skip` to your export declaration, th export const hello = 'world'; ``` -By default, .d.ts files are skipped. If you want to include .d.ts files, use the --include-d-ts option. +By default, `.d.ts` files are skipped. If you want to include `.d.ts` files, use the `--include-d-ts` option. ## Author From 8653a73543817e3e61fa4f0bcfc5dbc3411eaa26 Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 00:55:27 +0900 Subject: [PATCH 7/9] docs: use em dash --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48913d7..26584ed 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ - ๐Ÿ› ๏ธ Auto-fix unused exports โ€” removes the `export` keyword from the declaration or the whole declaration based on its usage - ๐Ÿงน Deletes TypeScript modules that have no referenced exports -- ๐Ÿ•ต๏ธ `--check` mode - reports unused exports and deletable files without writing changes +- ๐Ÿ•ต๏ธ `--check` mode โ€” reports unused exports and deletable files without writing changes ## Introduction From ab9e4b26964cd490af02c34b807109b3844ef6c8 Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 01:00:45 +0900 Subject: [PATCH 8/9] docs: update example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26584ed..b87da77 100644 --- a/README.md +++ b/README.md @@ -98,10 +98,10 @@ Options: The CLI will respect the `tsconfig.json` for loading source files. -Here's an example of using the cli. +Here's an example of using the cli. Make sure to skip your entrypoint file. ``` -npx ts-remove-unused --skip 'src\/index\.ts' +npx ts-remove-unused --skip 'src\/main\.ts' ``` ### Check From 6661acabde55272c9876fb0a1e3e5bfa9b13ff83 Mon Sep 17 00:00:00 2001 From: Kazushi Konosu Date: Thu, 12 Sep 2024 01:01:52 +0900 Subject: [PATCH 9/9] docs: remove hr --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b87da77..6cf9867 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@

Remove unused code from your TypeScript Project

-
[![npm version](https://badge.fury.io/js/@line%2Fts-remove-unused.svg)](https://badge.fury.io/js/@line%2Fts-remove-unused) [![CI](https://github.com/line/ts-remove-unused/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/line/ts-remove-unused/actions/workflows/ci.yml)