![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@phiresky/ts-unused-class-members
Advanced tools
Find unused class variables and methods in a typescript project
A CLI tool for finding unused class variables and methods in a TypeScript project.
@faire/ts-unused-class-members
is hosted on :octocat:GitHub Packages. To configure npm to download @faire packages from GitHub Packages registry you need to
read:packages
scopeecho "//npm.pkg.github.com/:_authToken=YOUR_TOKEN" >> ~/.npmrc
npm config set @faire:registry https://npm.pkg.github.com
In the same directory as your tsconfig.json
, run
npx @faire/ts-unused-class-members
Run ts-unused-class-members
with --help
to see all available CLI options.
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]
These options are optional, and you can also set them in a config file.
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.
Example config file for a React + MobX project:
ts-unused-class-members.config.js in the project root
module.exports = { ignoreFileRegex: "(?:(\\.d)|(\\.stories)|(\\.test))\\.tsx?$", ignoreMemberNames: [ "render", "state", "componentDidMount", "componentWillUnmount", "componentDidCatch", "componentDidUpdate", "shouldComponentUpdate", "UNSAFE_componentWillReceiveProps", "UNSAFE_componentWillUpdate", "UNSAFE_componentWillMount", ], /** * Ignore members decorated by MobX's @disposeOnUnmount */ ignoreDecoratorNames: ["disposeOnUnmount"], /** * Ignore members initialized with MobX's reaction() * e.g. public myReaction = reaction(...); */ ignoreInitializerNames: ["reaction"], };
ts-unused-class-members
consumes configuration using cosmiconfig, which supports some other config formats too.
ts-unused-class-members
property in package.jsonts-unused-class-members.config.js
or ts-unused-class-members.config.cjs
CommonJS module exporting an object.ts-unused-class-membersrc
file in JSON or YAML formatYou 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
.
// unused-class-members-ignore-next
class Unused {
...
}
class A {
// unused-class-members-ignore-next
unused = undefined;
...
}
Issues and PRs are welcome!
This project uses semantic-release to automate version management and package publishing, so make sure to follow the commit message conventions when contributing.
FAQs
Find unused class variables and methods in a typescript project
We found that @phiresky/ts-unused-class-members demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.