✂️ Find unused files, dependencies and exports in your TypeScript project

Overview

✂️ Knip

Knip scans your JavaScript and TypeScript projects for unused files, dependencies and exports: things that can be removed! Less code means better performance and less to maintain, important for both UX and DX!

For comparison, ESLint finds unused variables inside files in isolation, but this will not be flagged:

export const myVar = true;

Unused files will also not be detected by ESLint. So how do you know which files, dependencies and exports are no longer used? This requires an analysis of all the right files in the project.

This is where Knip comes in:

  • Resolves all (unused) files in your project and reports unused files, dependencies and exports.
  • Verifies that exported symbols are actually used in other files, even when part of an imported namespace.
  • Finds dependencies not listed in package.json.
  • Finds duplicate exports of the same symbol.
  • Supports JavaScript inside TypeScript projects ("allowJs": true)
  • Supports JavaScript-only projects using ESM (without a tsconfig.json)

Knip really shines in larger projects where you have non-production files (such as /docs, /tools and /scripts). The includes setting in tsconfig.json is often too broad, resulting in too many false negatives. Similar projects either detect only unimported files, or only unused exports. Most of them don't work by configuring entry files, an essential feature to produce good results. This also allows to unleash knip on a specific part of your project, and work these separately.

✂️ Knip is another fresh take on keeping your projects clean & tidy!

Installation

npm install -D knip

Usage

Create a configuration file, let's give it the default name knip.json with these contents:

{
  "entryFiles": ["src/index.ts"],
  "projectFiles": ["src/**/*.ts", "!**/*.spec.ts"]
}

The entryFiles target the starting point(s) to resolve production code dependencies. The projectFiles should contain all files it should match them against, including potentially unused files.

Then run the checks:

npx knip

This will analyze the project and output unused files, exports, types and duplicate exports.

Use --include files when configuring knip the first time for faster initial results.

How It Works

Knip works by creating two sets of files:

  1. Production code is the set of files resolved from the entryFiles.
  2. They are matched against the set of projectFiles.
  3. The subset of project files that is not production code will be reported as unused files (in red).
  4. Then the production code (in blue) will be scanned for unused exports.

How it works

Please read on if you think you have too many results: too many false positives?

Options

❯ npx knip
knip [options]

Options:
  -c/--config [file]     Configuration file path (default: ./knip.json or package.json#knip)
  -t/--tsConfig [file]   TypeScript configuration path (default: ./tsconfig.json)
  --dir                  Working directory (default: current working directory)
  --include              Report only listed issue group(s) (see below)
  --exclude              Exclude issue group(s) from report (see below)
  --ignore               Ignore files matching this glob pattern (can be set multiple times)
  --no-gitignore         Don't use .gitignore
  --dev                  Include `devDependencies` in report(s)
  --no-progress          Don't show dynamic progress updates
  --max-issues           Maximum number of issues before non-zero exit code (default: 0)
  --reporter             Select reporter: symbols, compact (default: symbols)
  --jsdoc                Enable JSDoc parsing, with options: public

Issue groups: files, dependencies, unlisted, exports, nsExports, types, nsTypes, duplicates

Examples:

$ knip
$ knip --dir packages/client --include files
$ knip -c ./knip.js --reporter compact --jsdoc public
$ knip --ignore 'lib/**/*.ts' --ignore build

More info: https://github.com/webpro/knip

🚀 Knip is considerably faster when only the files and/or duplicates groups are included.

Reading the report

After analyzing all the files resolved from the entryFiles against the projectFiles, the report contains the following groups of issues:

  • files - Unused files: did not find references to this file
  • dependencies - Unused dependencies: did not find references to this dependency
  • unlisted - Unlisted dependencies: this dependency is used, but not listed in package.json (1)
  • exports - Unused exports: did not find references to this exported variable
  • nsExports - Unused exports in namespaces: did not find direct references to this exported variable (2)
  • types - Unused types: did not find references to this exported type
  • nsTypes - Unused types in namespaces: did not find direct references to this exported variable (2)
  • duplicates - Duplicate exports: the same thing is exported more than once with different names

Each group type can be an --include or --exclude to slice & dice the report to your needs.

  1. This may also include dependencies that could not be resolved properly, such as local/dir/file.ts.
  2. The variable or type is not referenced directly, and has become a member of a namespace. That's why Knip is not sure whether this export can be removed, so please look into it:

Now what?

As always, make sure to backup files or use Git before deleting files or making changes. Run tests to verify results.

  • Unused files can be deleted.
  • Unused dependencies can be removed from package.json.
  • Unlisted dependencies should be added to package.json.
  • Unused exports and types: remove the export keyword in front of unused exports. Then you (or tools such as ESLint) can see whether the variable or type is used within its own file. If this is not the case, it can be removed.

🔁 Repeat the process to reveal new unused files and exports. Sometimes it's so liberating to delete things.

Too many false positives?

The default configuration for Knip is very strict and targets production code. For best results, it is recommended to exclude files such as tests from the project files. Here's why: when including tests and other non-production files, they may import production files, which will prevent them from being reported as unused.

Excluding non-production files from the projectFiles allows Knip to understand what production code can be removed (including dependent files!).

Non-production code includes files such as end-to-end tests, tooling, scripts, Storybook stories, etc.

Think of it the same way as you would split dependencies and devDependencies in package.json.

To include both production and test files to analyze the project as a whole, include both sets of files to entryFiles, and add dev: true to a file named such as knip.dev.json:

{
  "dev": true,
  "entryFiles": ["src/index.ts", "src/**/*.spec.ts", "src/**/*.e2e.ts"],
  "projectFiles": ["src/**/*.ts"]
}

Now use -c knip.dev.json to find unused files and exports for the combined set of files as configured in entryFiles.

An alternative way to store dev configuration is in this example package.json:

{
  "name": "my-package",
  "scripts": {
    "knip": "knip"
  },
  "knip": {
    "entryFiles": ["src/index.ts"],
    "projectFiles": ["src/**/*.ts", "!**/*.spec.ts"],
    "dev": {
      "entryFiles": ["src/index.ts", "src/**/*.spec.ts", "src/**/*.e2e.ts"],
      "projectFiles": ["src/**/*.ts"]
    }
  }
}

This way, the --dev flag will use the dev options (and also add devDependencies to the dependencies report).

More configuration examples

Monorepos

Separate packages

In repos with multiple (published) packages, the --dir option comes in handy. With similar package structures, the packages can be configured using globs:

{
  "packages/*": {
    "entryFiles": ["src/index.ts"],
    "projectFiles": ["src/**/*.{ts,tsx}", "!**/*.spec.{ts,tsx}"]
  }
}

Packages can also be explicitly configured per package directory.

To scan the packages separately, using the first match from the configuration file:

knip --dir packages/client
knip --dir packages/services

Connected projects

A good example of a large project setup is a monorepo, such as created with Nx. Let's take an example project configuration for an Nx project using Next.js, Jest and Storybook. This configuration file can also be a JavaScript file, which allows to add logic and/or comments (e.g. knip.js):

const entryFiles = ['apps/**/pages/**/*.{js,ts,tsx}'];

const projectFiles = [
  '{apps,libs}/**/*.{ts,tsx}',
  // Next.js
  '!**/next.config.js',
  '!**/apps/**/public/**',
  '!**/apps/**/next-env.d.ts'
  // Jest
  '!**/jest.config.ts',
  '!**/*.spec.{ts,tsx}',
  // Storybook
  '!**/.storybook/**',
  '!**/*.stories.tsx',
];

module.exports = { entryFiles, projectFiles };

This should give good results about unused files and exports for the monorepo. After the first run, the configuration can be tweaked further to the project structure.

Example Output

Default reporter

$ knip
--- UNUSED FILES (2)
src/chat/helpers.ts
src/components/SideBar.tsx
--- UNUSED DEPENDENCIES (1)
moment
--- UNLISTED DEPENDENCIES (1)
react
--- UNUSED EXPORTS (5)
lowercaseFirstLetter  src/common/src/string/index.ts
RegistrationBox       src/components/Registration.tsx
clamp                 src/css.ts
restoreSession        src/services/authentication.ts
PREFIX                src/services/authentication.ts
--- UNUSED TYPES (4)
enum RegistrationServices  src/components/Registration/registrationMachine.ts
type RegistrationAction    src/components/Registration/registrationMachine.ts
type ComponentProps        src/components/Registration.tsx
interface ProductDetail    src/types/Product.ts
--- DUPLICATE EXPORTS (2)
Registration, default  src/components/Registration.tsx
ProductsList, default  src/components/Products.tsx

Compact

$ knip --reporter compact
--- UNUSED FILES (2)
src/chat/helpers.ts
src/components/SideBar.tsx
--- UNUSED DEPENDENCIES (1)
moment
--- UNLISTED DEPENDENCIES (1)
react
--- UNUSED EXPORTS (4)
src/common/src/string/index.ts: lowercaseFirstLetter
src/components/Registration.tsx: RegistrationBox
src/css.ts: clamp
src/services/authentication.ts: restoreSession, PREFIX
--- UNUSED TYPES (3)
src/components/Registration/registrationMachine.ts: RegistrationServices, RegistrationAction
src/components/Registration.tsx: ComponentProps
src/types/Product.ts: ProductDetail
--- DUPLICATE EXPORTS (2)
src/components/Registration.tsx: Registration, default
src/components/Products.tsx: ProductsList, default

Why Yet Another unused file/dependency/export finder?

There are already some great packages available. Getting good results when finding unused files, dependencies and exports is not trivial. Repositories don't seem to get any smaller and with the rise of monorepos even more so. Tools like this need to analyze potentially many and/or large files, which is memory and time-consuming. Although I normally try to stick to the Unix philosophy, here I believe it's efficient to merge these issue reports into a single tool. When building a dependency graph of the project, an abstract syntax tree for each file, and traversing all of this, why not collect the various issues in one go?

Comparison

This table is a work in progress, but here's a first impression. Based on their docs (please report any mistakes):

Feature knip depcheck unimported ts-unused-exports ts-prune find-unused-exports
Unused files - - - -
Unused dependencies - - -
Unlisted dependencies - - -
Custom dependency resolvers #7 (1) - - -
Unused exports - -
Duplicate exports - -
Search namespaces - -
Custom reporters - - - - -
Pure JavaScript/ESM - -
Configure entry files
Support monorepo 🟠 (2) - - - - -
ESLint plugin available - - - - -

= Supported, = Not supported, - = Out of scope

  1. unimported is strict and works based on production files and dependencies, so does not have custom dependency resolvers which are usually only needed for devDependencies.
  2. knip wants to support monorepos properly, the first steps in this direction are implemented.

Knip?!

Knip is Dutch for a "cut". A Dutch expression is "to be geknipt for something", which means to be perfectly suited for the job. I'm motivated to make knip perfectly suited for the job of cutting projects to perfection! ✂️

Comments
  • Error:  is not a valid owner name in rule * @username

    Error: is not a valid owner name in rule * @username

    Hello,

    I was playing around with the CLI in my local project, and I got an error when running it in the following context:

    command:

    pnpx knip --reporter json --include files,duplicates
    

    output:

    failed to load codeowners file from C:\coding-work\halo-discord\halo-discord-bot\.github\CODEOWNERS Error:  is not a valid owner name in rule * @elijaholmos
        at createMatcherCodeownersRule (C:\Users\eliol\AppData\Local\pnpm\store\v3\tmp\dlx-19668\node_modules\.pnpm\@[email protected]\node_modules\@snyk\github-codeowners\dist\lib\ownership\OwnershipEngine.js:72:23)
        at Function.FromCodeownersFile (C:\Users\eliol\AppData\Local\pnpm\store\v3\tmp\dlx-19668\node_modules\.pnpm\@[email protected]\node_modules\@snyk\github-codeowners\dist\lib\ownership\OwnershipEngine.js:50:28)
        at exports.default (C:\Users\eliol\AppData\Local\pnpm\store\v3\tmp\dlx-19668\node_modules\.pnpm\[email protected]\node_modules\knip\dist\reporters\json.js:21:106)
        at async run (C:\Users\eliol\AppData\Local\pnpm\store\v3\tmp\dlx-19668\node_modules\.pnpm\[email protected]\node_modules\knip\dist\cli.js:62:9)
    

    knip.json:

    {
    	"dev": true,
    	"entryFiles": ["index.js"],
    	"projectFiles": ["/**/*.js"]
    }
    

    The project I'm testing knip in is open-source and can be found at https://github.com/elijaholmos/halo-discord-bot. In my CODEOWNERS file, I'm using the global owners syntax, as specified here.

    opened by elijaholmos 15
  • Incorrect unlisted dependency with import for type-only dependency

    Incorrect unlisted dependency with import for type-only dependency

    I installed knip on one of my projects and faced an issue with a dependency I have on @types/estree.

    Specifically, @types/estree only exists as a @types/ package - there's no estree package. However, to import types from @types/ package in TypeScript, you must (I believe) import it from the "base" package (which happens here). But since estree doesn't exist, knip cannot find the dependency and reports an unlisted dependency.

    Even if this can be fixed by updating my TypeScript configuration, I would expect knip to support the import style I'm currently using.

    bug 
    opened by ericcornelissen 7
  • Error with earlier version of Node 16. (FYI)

    Error with earlier version of Node 16. (FYI)

    Running Knip with Node v16.14.2 results in the following Error:

    node_modules/knip/dist/cli.js:13
    const { values: { help, dir, config: configFilePath = 'knip.json', tsConfig: tsConfigFilePath, include = [], exclude = [], ignore = [], 'no-gitignore': isNoGitIgnore = false, dev: isDev = false, 'no-progress': noProgress = false, reporter = 'symbols', 'reporter-options': reporterOptions = '', 'max-issues': maxIssues = '0', jsdoc: jsDoc = [], debug: isDebug = false, 'debug-level': debugLevel = '1', }, } = (0, node_util_1.parseArgs)({
                                                                                                                                                                                                                                                                                                                                                                                                                                                      ^
    
    TypeError: (0 , node_util_1.parseArgs) is not a function
    

    After upgrading to Node v16.18.0 this issue was resolved. If this is expected, I suggest adding a check and urging the user to upgrade their version of Node.

    opened by Moppler 5
  • Memory usage

    Memory usage

    Hi @webpro, when I was testing this out on the freecodecamp repo, node ran out of memory when I used the tool. The proximate cause was that a bunch of build artifacts were included in the projectFiles, ballooning the memory usage. The ultimate cause (as far as I can see) is that ts-morph has to hold the entire project's AST in memory at once and that gets quite large.

    It might be worth saying something in the docs to help mitigate this. Maybe a troubleshooting section?

    opened by ojeytonwilliams 5
  • InvalidOperationError: A child of the kind Identifier was expected.

    InvalidOperationError: A child of the kind Identifier was expected.

    I wanted to try this great tool for our project, but I get this error message:

    Processing: packages/store/src/Reducer/OptimisticReduce.ts
    /var/www/html/node_modules/@ts-morph/common/dist/ts-morph-common.js:448
                throw new InvalidOperationError(typeof errorMessage === "string" ? errorMessage : errorMessage());
                      ^
    
    InvalidOperationError: A child of the kind Identifier was expected.
        at Object.throwIfNullOrUndefined (/var/www/html/node_modules/@ts-morph/common/dist/ts-morph-common.js:448:19)
        at FunctionDeclaration.getFirstChildByKindOrThrow (/var/www/html/node_modules/ts-morph/dist/ts-morph.js:3776:36)
        at file:///var/www/html/node_modules/knip/dist/runner.js:115:54
        at Array.forEach (<anonymous>)
        at file:///var/www/html/node_modules/knip/dist/runner.js:85:34
        at Map.forEach (<anonymous>)
        at file:///var/www/html/node_modules/knip/dist/runner.js:84:36
        at Array.forEach (<anonymous>)
        at findIssues (file:///var/www/html/node_modules/knip/dist/runner.js:61:29)
        at main (file:///var/www/html/node_modules/knip/dist/index.js:108:40)
    
    Node.js v18.12.0
    

    Is there anything I can do to find out where the problem is in OptimisticReduce.ts?

    I'm using the latest version of knip.

    opened by fxOne 4
  • findPostCssDependencies results in error when using autoprefixer

    findPostCssDependencies results in error when using autoprefixer

    I'm getting the following error in [email protected]

    /node_modules/knip/dist/util/modules.js:6
        const match = value.replace(/\\/g, '/').match(/(?<=node_modules\/)(@[^/]+\/[^/]+|[^/]+)/);
                            ^
    
    TypeError: value.replace is not a function
        at getPackageName (/node_modules/knip/dist/util/modules.js:6:25)
        at Array.map (<anonymous>)
        at findPostCSSDependencies (/node_modules/knip/dist/plugins/postcss/index.js:13:90)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async /node_modules/knip/dist/workspace-worker.js:232:34
        at async Promise.all (index 0)
        at async WorkspaceWorker.findDependenciesByPlugin (/node_modules/knip/dist/workspace-worker.js:231:45)
        at async WorkspaceWorker.findDependenciesByPlugins (/node_modules/knip/dist/workspace-worker.js:209:42)
        at async main (/node_modules/knip/dist/index.js:179:80)
        at async run (/node_modules/knip/dist/cli.js:21:46)
    

    It seems to break when reading the package name from postcss.config.js

    Our postcss.config.js contains the autoprefixer import which is a function instead of a string :)

    module.exports = {
      plugins: [require('autoprefixer')],
    };
    
    opened by Aaronkala 3
  • Analyzing React.lazy loaded components

    Analyzing React.lazy loaded components

    Hi, really awesome project! Thanks!

    Any chances there is a way / plan to add a feature to analyze React.lazy() loaded components?

    For example:

    import React, { Suspense } from 'react';
    
    const OtherComponent = React.lazy(() => import('./OtherComponent'));
    
    function MyComponent() {
      return (
        <div>
          <Suspense fallback={<div>Loading...</div>}>
            <OtherComponent />
          </Suspense>
        </div>
      );
    }
    
    

    I would like to have 'OtherComponent' code analyzed.

    opened by kranux 3
  • [BUG] error count seems to not work as expected

    [BUG] error count seems to not work as expected

    Hello, when I run knip on my project, I get unused types in my report but the command still returns 0 as exit code.

    By reading the code here

    const reportGroup = report.files ? 'files' : (Object.keys(report) as IssueGroup[]).find(key => report[key]);
    const counterGroup = reportGroup === 'unlisted' ? 'unresolved' : reportGroup;
    if (counterGroup) {
      const count = counters[counterGroup];
      if (count > Number(maxIssues)) process.exit(count);
    }
    

    It seems to always take the file counter instead of aggregating all the counters. Is it expected?

    I can do a pull request if you need help :)

    opened by juliensnz 3
  • Sometimes imported jsx/tsx files are not recognised as `productionFiles`

    Sometimes imported jsx/tsx files are not recognised as `productionFiles`

    I've found that in a test project, ts-morph seems to not properly resolve React components.

    const productionFiles = production.getSourceFiles();
    
    // Now resolve dependencies of entry files to find all production files
      production.resolveSourceFileDependencies();
      const productionFiles = production.getSourceFiles();
      debugLogSourceFiles(options, 1, 'Included production source files', productionFiles);
    

    productionFiles simply ignores imports that are React imports

    Seems to be a related issue https://github.com/dsherret/ts-morph/issues/1250

    Will follow up with a minimal viable repro / repo later.

    opened by molszanski 3
  • Does not work with `js` entry points

    Does not work with `js` entry points

    Any way to get this working with .js entry points? Renaming my entry point from index.js to index.ts fixes the issue, but I have a large code base where this isn't so practicle.

    Cheers

    invalid 
    opened by CarltonHowell 3
  • Using knip's `$schema` may result in a warning about the `$schema` key

    Using knip's `$schema` may result in a warning about the `$schema` key

    Using the knip schema for the config on the next branch, e.g.[^1]:

    {
      "$schema": "./node_modules/knip/schema.json",
      "entry": ["lib/index.ts!"],
      "project": ["lib/**/*.ts!"],
      "ignoreBinaries": ["actionlint"],
      "ignoreDependencies": [
        "@ericcornelissen/eslint-plugin-top",
        "eslint-v6",
        "eslint-v7",
        "eslint-v8"
      ]
    }
    

    results in the following warning by VSCode[^2]:

    [{
    	"resource": ".../eslint-plugin-top/knip.json",
    	"owner": "_generated_diagnostic_collection_name_#3",
    	"severity": 4,
    	"message": "Property $schema is not allowed.",
    	"startLineNumber": 2,
    	"startColumn": 3,
    	"endLineNumber": 2,
    	"endColumn": 12
    }]
    

    This seems to be the result of having the following line in the schema:

    https://github.com/webpro/knip/blob/1052ec842606f63b9a26f2e25443f4b8bb9e06e7/schema.json#L43

    as removing this line from the scheme makes the warning go away.

    However, removing that lines makes the scheme stop complaining about all extraneous options. Hence, it might be better to add the "$schema" key to the schema like so:

      // ...
      "properties": {
        "$schema": {
          "type": "string"
        },
        // ...
      },
      // ...
    

    [^1]: Or with "$schema": "https://unpkg.com/knip@alpha/schema.json". [^2]: I don't know which schema validation library is used by VSCode under the hood, and I also couldn't quickly find a CLI to reproduce the issue...

    opened by ericcornelissen 1
  • Add CLI flag for process exit 0

    Add CLI flag for process exit 0

    The default process exit code with the total number of errors should probably be optional.

    Here's our use case that caused issues recently:

    • When I added knip in our stack I had to add a knip ... || true in our CI command that runs this tool, to not block the CI workflow
    • We use automatic dependency upgrades with Renovate
    • When v0.13.1 was released, which has a bug preventing it to run #25, the CI command executed successfully due to the || true there, but in reality it errored out.

    Proposal: Add an optional CLI flag to always use process exit code 0.

    enhancement feature request 
    opened by avaly 4
  • In the monorepo, How are webpack aliases properly addressed

    In the monorepo, How are webpack aliases properly addressed

    example:

    common
      |-- index.js
    src
      |-- monoA
         |-- entry.js
      |-- monoB
         |-- entry.js
    

    and npm run monoA, webpack alias "@": 'dir/monoA' and npm run monoB, webpack alias "@": 'dir/monoB'

    then: How are aliases properly addressed

    enhancement question 
    opened by zhongmeizhi 3
  • Add custom dependency resolvers

    Add custom dependency resolvers

    Add something so (dev) dependencies that are not imported using import or require are also marked as used.

    For example, ESLint plugins or Babel presets are listed in configuration files using string literals. Would be nice to detect those and mark them as a used/referenced dependency (and thus also list unused ones).

    But it should be trivial to add such custom resolvers. And probably ignore patterns to fill the holes.

    enhancement 
    opened by webpro 0
  • Add reporters

    Add reporters

    Ideas:

    • [x] json
    • [ ] csv
    • [ ] tsv
    • [x] table (https://nodejs.org/api/console.html#consoletabletabulardata-properties) - done through json + external tools
    • [ ] minimal with just total numbers
    • [ ] aggregated exports + exports in namespace into a single group, same for types (json has this)
    • ...
    • ...
    enhancement 
    opened by webpro 0
Releases(1.0.0-beta.6)
  • 1.0.0-beta.6(Dec 31, 2022)

    • Update dependencies (89d1b8c)
    • Use root workspace name constant where possible (aec03d5)
    • Fix bug where plugin config as array is not handled properly (444ce80)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.5(Dec 31, 2022)

    • Tweak npm publish/release scripts (645f0f1)
    • Minor fixes in glob helper (cc277e3)
    • Use plugin title in debug output (e485769)
    • Add script to create plugin and mention in docs (2a99cf7)
    • Add ignoreDependencies to npm test config (32d45ab)
    • Generate plugin docs (8b02325)
    • Prepare all plugins for docs generator (2afd5bd)
    • Add script to generate plugin docs and update index (c0e75a8)
    • Prepend ignore patterns in descendant workspace glob (a8b1879)
    • Add script to update cli arguments help text in README.md (4becc1a)
    • Co-locate help text with parsed cli arguments (d9c5813)
    • Remove unused isStrict var (a95ae22)
    • Reverse --ignore-entry-exports to --include-entry-exports (better default) (97b0fb7)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.4(Dec 29, 2022)

    • Back to minimal test matrix config (now that the Windows tests pass) (9df6cae)
    • Fix and improve zero-config spec (529f741)
    • Update dependencies (6aeefe4)
    • Use ensurePosixPath to fix issues on Windows/PS (62bd617)
    • Fix issue (in Windows) in tests with dynamic import (b745ba9)
    • Remove unused cli argument (3036e0a)
    • Refactor unused members helpers for cleaner API (2b02141)
    • Restore --include-entry-files (with --ignore-entry-exports) (2f37ab9)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.3(Dec 27, 2022)

    • Add new dir and binaries to ignore (d38b216)
    • Update dependencies (92b6c0e)
    • A bit of housekeeping in tests (3050f8e)
    • Exclude template literals with substitutions (410a65d)
    • Rename util file (52ff0a5)
    • Improve handling of descendent workspaces including negated patterns (a5d27c6)
    • Also use defaults in production mode (af87f53)
    • Minor refactoring (7d88a75)
    • Improve docs and schema.json (9aa46f6)
    • Add convenience for creating new plugins (9164321)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.2(Dec 22, 2022)

    • Add entry files to postcss plugin and tests (39c80a1)
    • Move cypress spec (7c7aed4)
    • Allow to disable config, entry and project globs with empty array (45ec3dd)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.1(Dec 22, 2022)

    • Update dependencies (b5ce140)
    • Remove old exclude glob in tsconfig.json (d0f9bac)
    • Add support for .eslintrc.yml, fix plugin name resolver, and more tests to the eslint plugin (32634df)
    • Use one try/catch in the generic loader (02793b9)
    • Update docs (da11dc4)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta.0(Dec 21, 2022)

    • Update docs (a67bb70)
    • Move plugin fixtures to their own dir (479b0b0)
    • Add fixture + test for js-only project (w/o tsconfig.json) (bae6533)
    • Some housekeeping in plugins (00a2fb2)
    • Improve test dir structure (722ce74)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.8(Dec 19, 2022)

  • 1.0.0-alpha.7(Dec 19, 2022)

    • Add prettier plugin (c30a351)
    • Shorten skipExportsAnalysisFor a bit (4d335d7)
    • Use defaults for entry/project config per workspace (edb1165)
    • Now run tests in sub dirs too (85e3feb)
    • Build knip before eating own dog food (a113aba)
    • Restore error log in JSON loader, only show in debug/no-progress in generic esm loader (f1aaa60)
    • Add sentry plugin (10d4371)
    • Add nyc plugin (a93863f)
    • Improve a few glob patterns (d980214)
    • Allow to disable plugin (per workspace) using false (ccbaa20)
    • Fix scoped definitely typed package name helpers (d2b7ef1)
    • Improve handling of loader/require args in npm scripts + more tests (efd08aa)
    • Refactor workspace init/sort (8faa1c9)
    • Move "static" class member resolvePackageName to helper (788fc8c)
    • Update dependencies (2bc78c1)
    • Patch esbuild-register to use recent target, so @esbuild-kit/esm-loader uses the same as Knip itself (17cd1a2)
    • Add commitlint plugin (1b7d373)
    • Add config file and exception for prettier config to eslint plugin (68fe292)
    • Extend/improve webpack plugin (20f0b7c)
    • Add option to ignore dependencies (9a859ca)
    • Add support for plugins configurations in typescript plugin (6e569cb)
    • Add support for env configurations in babel plugin and fix/resolve package names (0cc8d42)
    • Defer reading TS project options and add test (8bf9937)
    • Add webpack plugin (3972c3a)
    • Minor change to increase readability (2c4e5c2)
    • Add tmp folder to .gitignore (b52f270)
    • Add some new keywords to manifest file (6810665)
    • Fix missing addons in storybook plugin (8ecf399)
    • Fix preset handling in jest plugin (2f6404c)
    • Improve (progress) output (c74a7ec)
    • Refactor and improve resolving entry files (834ac56)
    • Refactor handling of binaries (5b5fa5e)
    • Add JSON Schema for project configuration (175abac)
    • Refactor configuration schema (breaking change) (70bfe6a)
    • Remove obsolete paths from config (66026b4)
    • Add server.ts to production file entry file patterns in remix plugin (d7e9ac7)
    • Remove duplicate patterns and sample file paths in eslint plugin (0f388ca)
    • Use constants for issue types and titles (c606202)
    • Include root workspace only when configured (56c0452)
    • Restore negated workspace patterns (263e326)
    • Filter knip itself from dependency issues (4aafb8e)
    • Add debug info to eslint plugin (1d39b6c)
    • Improve handling of installed binaries/unused dependencies (782c786)
    • Move some CLI arguments to constructor for testability (82964a9)
    • Remove debug-level arg (0b53d93)
    • Remove quotes from enum members (6d3074a)
    • Fix issue type titles (016aa4e)
    Source code(tar.gz)
    Source code(zip)
  • 0.13.3(Dec 6, 2022)

  • 1.0.0-alpha.6(Dec 2, 2022)

  • 1.0.0-alpha.5(Dec 1, 2022)

    • Replace total sum from performance table with actual total time (831d222)
    • Timerify loader (5294626)
    • Memoize glob function calls (3ec1420)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.4(Nov 30, 2022)

    • Don't use non-positionals as first argument binary (43a2dfc)
    • Include only plugins with production entry files in production mode (1427e48)
    • Fix multiple dependencies sharing the same binary name (46bf9f7)
    • Add typescript plugin (cb1675f)
    • Fix using eslint-config prefix in extends (c84e4fd)
    • Include (only start) npm scripts in production mode (db16e56)
    • Exclude plugin globs from source code project file pattern (ebd1a5e)
    • Ignore typed dependencies that have a peer dependency that's referenced (c41b504)
    • Add npx to binaries that take a binary as their first (positional) argument (415be5b)
    • Fix initial NaN in progress updater (e1e8b68)
    • Add getter for peer dependencies (WIP) (cb68bd2)
    • Add installed binaries in root workspace referenced from descendant workspaces (dfe59b9)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.3(Nov 26, 2022)

    • Refactor for readability (1b44c23)
    • Defer production suffix removal until usage (63e9f03)
    • Refactor eslint plugin to find samples for calculateConfigForFile (5c80263)
    • Start support for yaml files in loader (b93e530)
    • Add deno and git to global binaries to ignore (4b9a949)
    • Some housekeeping in test folder (4330b62)
    • No need to sort glob patterns (f23f2ae)
    • Fix overrides for plugin configs (c07061b)
    • Update docs (12723af)
    • Update dependencies (b3135b2)
    • Minor refactorings (10bbf9e)
    • Improve babel plugin + spec (93d4a9f)
    • Add docs for plugins (2359c39)
    • Improve eslint plugin (3f417cd)
    • Add stryker plugin (cf181a7)
    • Add mocha plugin (394da64)
    • Remove unused/empty arrays from plugins (269e3c3)
    • Some housekeeping across codebase (50c64d9)
    • Add --no-exit-code flag (9ea5ce9)
    • Less repetition when adding new plugins (2c17f2c)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.2(Nov 24, 2022)

    • Extend rollup entry file patterns for rollup.config.ts files (ecda91e)
    • Add sampleFiles to (eslint) plugin config & pass config to custom resolver (763e675)
    • Improve separation of concerns around source file analyzer (7fb4c1f)
    • Refactor and improve handling of DefinitelyTyped (@types/*) packages (5b71a56)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.1(Nov 24, 2022)

    • Housekeeping (0f6ea29)
    • Streamline issue objects (b0c65c6)
    • Decouple last bit of entanglement in classes (de7bbaf)
    • Add remaining test coverage for plugins (f1e5c8f)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-alpha.0(Nov 22, 2022)

    This release marks the support for workspaces and plugins. The major drivers are less configuration in your projects and a better architecture for future work. A lot of groundwork has been done, using unit tests and a few pretty large codebases. Releasing this early version allows interested developers to try out the new features. In this early stage, expect bugs and false positives, although I believe Knip can already provide a lot of value.

    Knip's core idea is to find unused files, exports and dependencies, which isn't trivial given the wide range of project structures and the many ways to configure repositories and frameworks nowadays. When exploring the matters in various projects, it has become clear that Knip will never be perfect and 100% accurate, and without any configuration for Knip, large projects will likely have false positives. But I think this is only normal in this type of software development. For instance, ESLint will also not prevent bugs in your code, it helps to find problems in your code. Knip has a similar ambition, but beyond the scope of single files. Motivation and ambition has only grown to do as good as possible to keep projects of any size more maintainable. I believe the investment in developing Knip is totally worth it!

    Fun fact: this release is named after the Atlantic Ocean since it was done from a height of 10K above sea level:

    IMG_1841

    Source code(tar.gz)
    Source code(zip)
  • 0.13.2(Nov 14, 2022)

  • 0.13.1(Nov 7, 2022)

    • Fix up info message (1b98eae)
    • Add esm-loader (fixes #23) (0560728)
    • Fix ts import (closes #24) (4069971)
    • Move unused class/enum members to current features in docs (2a80f35)
    Source code(tar.gz)
    Source code(zip)
  • 0.13.0(Oct 28, 2022)

    • Update docs (782eff5)
    • Rename helper boolean (02a9f3b)
    • Move findUnusedClassMembers and findUnusedEnumMembers to util module (a4d74c9)
    • Fix runner bail-outs (65cbaec)
    • Use easy-table for symbols reporter (567f814)
    • Add enumMembers and classMembers to json reporter (a51646a)
    • Add parentSymbol to issues (bbaaac1)
    • Add initial support for finding unused enum and class members (#11 and #20) (4ff8cc9)
    Source code(tar.gz)
    Source code(zip)
  • 0.12.2(Oct 27, 2022)

  • 0.12.1(Oct 27, 2022)

    • Update docs (2475576)
    • Add remark + remark-preset-webpro (dc8bb40)
    • Remove jsdoc options and always read JSDoc public tag (510da6b)
    • Set package names in specs (1dafd8d)
    Source code(tar.gz)
    Source code(zip)
  • 0.13.0-members.1(Oct 26, 2022)

    • Fix runner bail-outs (9cfc0d9)
    • Use easy-table for symbols reporter (edc2ac3)
    • Add enumMembers and classMembers to json reporter (43aac85)
    • Add parentSymbol to issues (1dced2e)
    Source code(tar.gz)
    Source code(zip)
  • 0.13.0-members.0(Oct 26, 2022)

  • 0.12.0(Oct 25, 2022)

    • Update dependency & bump required engine to v18.6 (eaa10cf)
    • Use createRequire to loadJSON (for Windows compat) (af56457)
    • Use the built-in isBuiltin module (f50700d)
    • Add --performance to measure running time of expensive functions and display stats table (bdcbd5d)
    • Fix and simplify handling of --dev argument (3fe06c4)
    • Migrate to ESM (b2f2f7b)
    Source code(tar.gz)
    Source code(zip)
  • 0.11.2(Oct 24, 2022)

  • 0.11.1(Oct 24, 2022)

  • 0.11.0(Oct 23, 2022)

    • Update docs (62c927d)
    • Remove external source files from project (fd31f9d)
    • Move globbing to its own module (952230b)
    • Add (dev) dependencies issues to json reporter (733a663)
    • Throw without package.json and assign (dev) dependencies issues to it (c85664e)
    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Oct 21, 2022)

    • Use path.posix in pattern modifiers for globs (9ab4d81)
    • Normalize key in issues (838f666)
    • Add globstar for Windows globbing in npm script (e375f37)
    • Add windows-latest to test matrix (aca2223)
    • Always ignore node_modules when globbing (cd9e1ce)
    • Add devDependencies to base config in specs (1abb0b2)
    • Add specs to cover tsconfig paths & globs (03b2e3f)
    • Doc edits (fb94502)
    • Fix include/exclude CLI argument overrides (db4ebdc)
    • Housekeeping the unresolved dependency analyzer (2ae97ec)
    • Pass only debug to loggers (08ca0c9)
    Source code(tar.gz)
    Source code(zip)
  • 0.9.1(Oct 19, 2022)

    • Knip everything again (3b910ea)
    • Match issue and report types to simplify code and types (726d403)
    • Include dev property when resolving config (f570af5)
    • Replace path.relative with relative from cwd (26dad4a)
    • Update index.ts (f8e585a)
    Source code(tar.gz)
    Source code(zip)
Owner
Lars Kappert
Freelance developer/architect. I care about JavaScript, Performance, Automation, Open Source.
Lars Kappert
This Photoshop script exports all top-level layers and groups to cropped PNG and JPEG files and creates a file usable in Tumult Hype 4 based on your Photoshop document.

Export To Hype (Photoshop Edition) This Photoshop script exports all top-level layers and groups to cropped PNG and JPEG files and creates a file usab

Max Ziebell 6 Nov 9, 2022
Save resources by suspending unused tabs after 20 min.

Tab Suspender [WIP] Save resources by suspending unused tabs after 20 min. Instalation Enable Epiphany extension. Optional if not done. Download the l

null 5 May 7, 2022
A file manager plugin for logseq(Search unused assets file)

logseq-plugin-file-manager Search files from assets and draws but not used in journals or pages. Please backup files before operation, and before dele

Hayden Chen 17 Dec 23, 2022
This module exports all the commands that Redis supports

This module exports all the commands that Redis supports

ioredis 5 Mar 24, 2022
Exports a JPDB deck to a Yomichan compatible frequency list.

JPDB Frequency List A frequency list generated using most of the jpdb corpus can be found in the releases. It is not exhaustive, as there is no deck a

marv 17 Nov 16, 2022
Userland module that implements the module path mapping that Node.js does with "exports" in package.json

exports-map Userland module that implements the module path mapping that Node.js does with "exports" in package.json npm install exports-map Usage co

Mathias Buus 9 May 31, 2022
Get exports of an local npm package.

pkg-exports Get exports of an local npm package. Install npm i pkg-exports Usage getExportsRuntime Get the exports by evaluate the module in worker th

Anthony Fu 103 Nov 12, 2022
Visual scraper interface, exports to puppeteer script which you can run anywhere.

Jawa - Visual Scraper Visual scraper interface, exports to puppeteer script which you can run anywhere. You can try it out here https://jawa.kickass.c

Ante Barić 4 Nov 16, 2022
Find stale dependencies in the package.json file(s).

staledeps Find stale dependencies in the package.json file(s). Installation npm install -g staledeps Or simply using npx, the package runner bundled

Michael Mok 6 Dec 15, 2022
Use PageRank to find the most important files in your codebase.

Deprank Deprank uses the PageRank algorithm to find the most important files in your JavaScript or TypeScript codebase. It uses dependency-cruiser to

codemix 680 Dec 30, 2022
Find duplicate object values of your JSON files (VSCode Extension)

JASON Lint VS Code Extension Make your life easier, use this extension to defeat the horror of duplicate values from your JSON files. Very useful when

Leonardo Pizzoquero 3 Oct 20, 2022
Piplup: decompile Playdate Pulp .pdx files back to .json project files

Piplup: decompile Playdate Pulp .pdx files back to .json project files This doesn't work yet: I still need to: convert the graphics (.pdt files) back

null 6 Mar 25, 2022
A GitHub Action for creating Changesets files for dependencies updates.

changesets-dependencies-action A GitHub Action for creating Changesets files for dependencies updates. This action will automatically monitor all your

The Guild 19 Sep 28, 2022
typescript-to-jsonschema generates JSON Schema files from your Typescript sources.

fast-typescript-to-jsonschema English | 简体中文 a tool generate json schema from typescript. Feature compile Typescript to get all type information conve

yunfly 21 Nov 28, 2022
Find Your DUO Project: instructed by Rodrigo Gonçalves and Diego Fernandes CTO at Rocketseat

Find-your-DUO NextLevelWeek eSports ?? Find-your-DUO Project | Technologies | Layout | How To Use | How to contribute | License ?? Project The project

Eliezer Nascimento 2 Dec 14, 2022
Find out how many lines of code you have written for your project 📜

?? TLOC (Tomper Lines Of Code) Find out how many lines of code you have written for your project. ?? Installation (Install the package globally) npm i

Varun Tiwari 9 Oct 17, 2022
Analyze dependencies in your Deno project

Analyze dependencies in your Deno project

DjDeveloper 3 Feb 20, 2022
Easy-to-use tool to inform you about potential risks in your project dependencies list

sdc-check Easy-to-use tool to inform you about potential risks in your project dependencies list Usage Add to your project Add new npm command to scri

Maksim Balabash 132 Dec 4, 2022