From 78f66e7dc760bd8173f72f9bc7bcaa588fc996f3 Mon Sep 17 00:00:00 2001 From: Runbiao Zhong Date: Thu, 1 Jul 2021 18:26:52 -0400 Subject: [PATCH] doc: update readme --- README.md | 78 ++++++++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index aacc20d..2b83f6d 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,11 @@ A CLI tool for finding unused class variables and methods in a TypeScript projec - -
  • - Configuration -
  • -
  • Ignoring a Specifc Declaration
  • +
  • Configuration File
  • +
  • Ignoring a Specific Declaration
  • Acknowledgements
  • @@ -30,40 +25,47 @@ A CLI tool for finding unused class variables and methods in a TypeScript projec ### Prerequisites -`@faire/ts-unused-class-members` is hosted on :octocat:[GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#installing-a-package). To configure npm to download @faire packaes from Git Packages registry you'll need to - -1. Create a personal access token with the `read:packages` scope -2. Add the personall access token to ~/.npmrc -``` -echo "//npm.pkg.github.com/:_authToken=YOUR_TOKEN" >> ~/.npmrc -``` -3. Configure npm to download @faire packages from Git Packages registry -``` -npm config set @faire:registry https://npm.pkg.github.com -``` +`@faire/ts-unused-class-members` is hosted on :octocat:[GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#installing-a-package). To configure npm to download @faire packages from GitHub Packages registry you need to +1. Create a [personal access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) with the `read:packages` scope +2. Use the command below to add the personal access token to ~/.npmrc + ``` + echo "//npm.pkg.github.com/:_authToken=YOUR_TOKEN" >> ~/.npmrc + ``` +3. Use the command below to configure npm to download @faire packages from GitHub Packages registry + ``` + npm config set @faire:registry https://npm.pkg.github.com + ``` ### Usage + In the same directory as your `tsconfig.json`, run + ``` npx @faire/ts-unused-class-members ``` -## Configuration +### CLI Options -`ts-unused-class-members` supports both file and CLI configuration. +Run `ts-unused-class-members` with `--help` to see all available CLI options. -### Configuration File +``` +Options: + --project Path to the project's tsconfig.json [string] + --path Path to a single directory/file to scan [string] + --ignoreFileRegex Regex pattern for excluding files [string] +``` -`ts-unused-class-members` consumes configuration using [cosmiconfig](https://github.com/davidtheclark/cosmiconfig#cosmiconfig), which supports various config formats. +These options are optional, and you can also set them in a config file. -- a `ts-unused-class-members` property in package.json -- a `ts-unused-class-members.config.js` or `ts-unused-class-members.config.cjs` CommonJS module exporting an object -- a `.ts-unused-class-membersrc` file in JSON or YAML format +## Configuration File -Example configuration for a React + Mobx project: +By default, `ts-unused-class-members` flags every class member that has no references in the project. Depends on the framework/library you use, you may want to tell +the checker to ignore certain class members. You can do that by including a configuration file. -> ts-unused-class-members.config.js +Example config file for a React + MobX project: + +> ts-unused-class-members.config.js in the project root > > ```js > module.exports = { @@ -81,32 +83,26 @@ Example configuration for a React + Mobx project: > "UNSAFE_componentWillMount", > ], > /** -> * Ignore members decorated by Mobx's @disposeOnUnmount +> * Ignore members decorated by MobX's @disposeOnUnmount > */ > ignoreDecoratorNames: ["disposeOnUnmount"], > /** -> * Ignore members initialized with Mobx's reaction() +> * Ignore members initialized with MobX's reaction() > * e.g. public myReaction = reaction(...); > */ > ignoreInitializerNames: ["reaction"], > }; > ``` -### CLI Options - -Run `ts-unused-class-members` with `--help` to see all avaiable CLI options. +`ts-unused-class-members` consumes configuration using [cosmiconfig](https://github.com/davidtheclark/cosmiconfig#cosmiconfig), which supports some other config formats too. -``` -Options: - --project Path to the project's tsconfig.json [string] - --path Path to a single directory/file to scan [string] - --ignoreFileRegex Regex pattern for excluding files [string] -``` +- a `ts-unused-class-members` property in package.json +- a `ts-unused-class-members.config.js` or `ts-unused-class-members.config.cjs` CommonJS module exporting an object +- a `.ts-unused-class-membersrc` file in JSON or YAML format -These options are optional and you can also set them using a config file. +## Ignoring a Specific Declaration -## Ignoring a Specifc Declaration -You can also tell `ts-unused-class-members` to ignore a specifc class or class member by prefixing its declaration with `// unused-class-members-ignore-next`. +You can also tell `ts-unused-class-members` to ignore a specific class or class member by prefixing its declaration with `// unused-class-members-ignore-next`. ```js // unused-class-members-ignore-next