Skip to content

Instantly share code, notes, and snippets.

@joseivanlopez
Created September 3, 2026 15:00
Show Gist options
  • Select an option

  • Save joseivanlopez/8b0aa72e4693cf11be62098f135a7548 to your computer and use it in GitHub Desktop.

Select an option

Save joseivanlopez/8b0aa72e4693cf11be62098f135a7548 to your computer and use it in GitHub Desktop.

Dependency Sanitization Analysis Report

Generated: 2026-09-03 Tool: Knip v0.65.x Project: Agama Web


Executive Summary

Initial Findings (Before Configuration)

Knip analysis found:

  • 27 unused files
  • 8 unused devDependencies
  • 7 unlisted dependencies (used but not in package.json)
  • 64 unused exports

After Configuration & Investigation

Created knip.json config and completed manual review:

  • 8 unused files (19 were false positives - translation files, build scripts)
  • 5 truly unused devDependencies (3 are peer deps of neostandard)
  • 9 unlisted dependencies (CRITICAL - must add to package.json)
  • 38 unused exports (26 were OpenAPI types)

Quick Action Items

✅ READY TO EXECUTE:

  1. Add 6 missing dependencies (2 runtime + 4 dev)
  2. Remove 5 unused devDependencies
  3. Consider removing 8 unused files after verification

⚠️ UNLISTED DEPENDENCIES - HIGH PRIORITY: These packages are used but NOT in package.json - will break if not installed globally:

  • @monaco-editor/react, @patternfly/react-icons (runtime)
  • @jest/globals, glob, gettext-parser, jed (dev/build)

1. Unused Files (27 total)

1.1 Build/Development Scripts - KEEP (False Positives)

These files are used outside the normal import graph:

  • svgo.config.js - SVGO configuration for SVG optimization
  • scripts/check-contrast.js - Development utility script (executable)
  • share/po/po-converter.js - Translation file converter (executable)
  • share/po/po.template.js - Translation template

Reason: Used by build tools or as standalone scripts, not imported directly.

1.2 Translation Files (16 files) - KEEP (Dynamically Imported)

All src/po/po.*.js files:

  • po.ca.js, po.de.js, po.es.js, po.fr.js, po.id.js, po.it.js, po.ja.js, po.ka.js
  • po.pt-BR.js, po.ru.js, po.sv.js, po.tr.js, po.uk.js, po.zh-CN.js, po.zh-TW.js

Reason: Loaded dynamically via import(\~/po/po.${language}.js`)insrc/test-utils.tsx` and runtime. Knip cannot detect dynamic imports with template literals.

1.3 Unused Components/Modules - INVESTIGATE & LIKELY REMOVE

Truly Unused Components:

  1. src/components/core/SelectTypeaheadCreatable.tsx - Component not imported anywhere
  2. src/components/storage/AutoSizeText.tsx - Component not imported anywhere
  3. src/components/storage/SizeModeSelect.tsx - Component not imported anywhere

Index Files (Export-only):

  1. src/components/l10n/index.ts - Export barrel, but exports aren't used
  2. src/components/network/index.ts - Export barrel, but exports aren't used
  3. src/components/users/index.ts - Export barrel, but exports aren't used

Action: These appear to be dead code. Before removing:

  • Grep for any dynamic imports or runtime references
  • Check if they're part of incomplete features
  • Ask: Are these planned for future use?

Unused Hooks:

  1. src/hooks/use-cancellable-promise.ts - Hook not imported anywhere
  2. src/hooks/model/config/user.ts - Hook not imported anywhere

Action: Safe to remove if truly unused. Check git history for context.


2. Unused devDependencies (8 total)

2.1 Safe to Remove - ✅ CONFIRMED

  1. @babel/eslint-parser (package.json:28)

    • ✅ Not used in eslint.config.mjs (uses @typescript-eslint/parser instead)
    • SAFE TO REMOVE
  2. @svgr/plugin-jsx (package.json:33)

    • ✅ Not configured in webpack.config.js
    • SAFE TO REMOVE
  3. ajv (package.json:46)

    • ✅ Not imported anywhere in src/ or config files
    • SAFE TO REMOVE
  4. eslint-plugin-node (package.json:58)

    • ✅ Deprecated package, replaced by eslint-plugin-n
    • SAFE TO REMOVE
  5. eslint-plugin-import-x (package.json:56)

    • ✅ Not configured in eslint.config.mjs
    • ✅ Not imported or used
    • SAFE TO REMOVE

2.2 False Positives - KEEP (Used via neostandard)

  1. eslint-plugin-n (package.json:57)

    • ✅ Used by neostandard (peer dependency)
    • Used in rules: "n/no-callback-literal": "off" (line 94)
    • KEEP
  2. eslint-plugin-promise (package.json:60)

    • ✅ Used by neostandard (peer dependency)
    • KEEP
  3. eslint-plugin-react (package.json:61)

    • ✅ Used by neostandard (peer dependency)
    • Used in rules: "react/jsx-curly-spacing", "react/jsx-indent-props", "react/prop-types" (lines 90-92)
    • KEEP

3. Unlisted Dependencies (7 total) - MUST FIX

These packages are USED but NOT in package.json:

3.1 Add to devDependencies:

  1. @jest/globals
    • Used in: 4 test files (transformations.test.ts)
    • ACTION: npm install -D @jest/globals

3.2 Add to devDependencies (Build Scripts):

  1. glob, gettext-parser, jed
    • Used in: share/po/po-converter.js (build script for translations)
    • ACTION: npm install -D glob gettext-parser jed

3.3 Add to dependencies:

  1. @monaco-editor/react

    • Used in: src/components/core/ConfigEditor.tsx:28
    • ACTION: npm install @monaco-editor/react
  2. @patternfly/react-icons

    • Used in: src/components/core/SmallWarning.tsx:25
    • Deep import: @patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon
    • ACTION: npm install @patternfly/react-icons

3.4 May be provided by other packages (verify):

  1. typescript-eslint
    • Used in: eslint.config.mjs:4
    • Provided by: neostandard@0.13.0typescript-eslint@8.63.0
    • STATUS: Installed indirectly, keep as transitive dependency

4. Unused Exports (64 total)

Categories:

  1. Type-only exports from OpenAPI generated files (majority)

    • Files: src/openapi/**/*.ts
    • These are auto-generated type definitions
    • KEEP - Part of the API contract, may be used externally or in future
  2. Component exports from index.ts barrel files

    • Multiple exports from src/components/*/index.ts
    • Examples: ChangeProductOption, FormLabel, EmailInput, MenuHeader, etc.
    • ACTION: If the barrel file is unused (see section 1.3), remove it entirely
    • Otherwise, clean up individual unused exports
  3. Utility function exports

    • Various utility functions in utils files
    • Examples: setLocationSearch, intRange, volumeLabel, etc.
    • ACTION: Review each on a case-by-case basis
  4. Test utility exports

    • mockUseRevalidator in src/test-utils.tsx
    • ACTION: Remove if truly unused in tests

5. Recommended Actions

Phase A: Critical Fixes - ✅ READY TO EXECUTE

  1. Add missing dependencies:

    # Runtime dependencies
    npm install @monaco-editor/react @patternfly/react-icons
    
    # Dev dependencies for tests and build scripts
    npm install -D @jest/globals glob gettext-parser jed
  2. Remove unused devDependencies (5 packages):

    npm uninstall @babel/eslint-parser @svgr/plugin-jsx ajv eslint-plugin-import-x eslint-plugin-node

    Impact:

    • Add: 6 packages total (2 runtime, 4 dev)
    • Remove: 5 dev packages
    • Net change: +1 package, but fixes all unlisted dependency issues

Phase B: Investigation - ✅ COMPLETE

Investigation complete. Results:

  • ✅ eslint-plugin-n, eslint-plugin-promise, eslint-plugin-react are used by neostandard - KEEP
  • ✅ @svgr/plugin-jsx not in webpack config - REMOVE
  • ✅ ajv not used anywhere - REMOVE
  • ✅ @babel/eslint-parser not used - REMOVE
  • ✅ eslint-plugin-import-x not configured - REMOVE

Phase C: Code Cleanup (After Verification)

  1. Remove unused components (if confirmed):

    • src/components/core/SelectTypeaheadCreatable.tsx
    • src/components/storage/AutoSizeText.tsx
    • src/components/storage/SizeModeSelect.tsx
  2. Remove unused hooks:

    • src/hooks/use-cancellable-promise.ts
    • src/hooks/model/config/user.ts
  3. Remove or clean up index.ts files:

    • src/components/l10n/index.ts
    • src/components/network/index.ts
    • src/components/users/index.ts
  4. Clean up unused exports (carefully, one at a time)

Phase D: Configuration - ✅ COMPLETE

Created knip.json configuration file to reduce false positives.

Results after configuration:

  • Unused files: 27 → 8 (eliminated 19 false positives)
  • Unused devDependencies: Still shows 8 (3 are false positives from neostandard)
  • Unlisted dependencies: 7 → 9 (found 3 more in build scripts)
  • Unused exports: 64 → 38 (eliminated 26 false positives)

Additional unlisted dependencies found:

  • glob, gettext-parser, jed - Used in share/po/po-converter.js
  • These are likely dev dependencies for the build process

6. False Positive Patterns Identified

  1. Dynamic imports with template literals - po.* files
  2. Config files used by tools (svgo.config.js)
  3. Executable scripts not imported (scripts/*)
  4. Transitive dependencies via neostandard
  5. Generated types in openapi/ folders
  6. Deep imports from packages (react-icons sub-paths)

7. Summary of Work Completed

Phases 1-3: ✅ COMPLETE

  • Phase 1: Installed Knip and ran initial analysis
  • Phase 2: Categorized all findings and identified false positives
  • Phase 3: Created knip.json configuration to reduce noise

Investigation Results:

Unused devDependencies:

  • 5 confirmed removable: @babel/eslint-parser, @svgr/plugin-jsx, ajv, eslint-plugin-import-x, eslint-plugin-node
  • 3 false positives (used by neostandard): eslint-plugin-n, eslint-plugin-promise, eslint-plugin-react

Unlisted dependencies:

  • 6 critical additions needed: @monaco-editor/react, @patternfly/react-icons, @jest/globals, glob, gettext-parser, jed
  • 1 transitive dependency (OK): typescript-eslint (via neostandard)

Unused files:

  • 8 potentially removable files (components, hooks, index.ts barrel files)
  • 19 false positives eliminated by configuration (po files, build scripts)

Unused exports:

  • 38 remaining (down from 64)
  • Most are intentional API surface or will be cleaned up when barrel files are removed

8. Next Steps

  1. Phase 1: Analysis complete
  2. Phase 2: Review and categorization complete
  3. Phase 3: Configuration complete
  4. ⏭️ Next: Execute Phase A (Critical Fixes) - awaiting approval
  5. ⏭️ Future: Execute Phase C (Code Cleanup) - awaiting approval

Appendix: Files Generated

Analysis Files (Untracked):

  • .claude/knip-report.json - Full machine-readable Knip output
  • .claude/dependency-analysis.md - This analysis document (you are reading this)
  • .claude/plans/sanitize-deps.md - Original plan document (updated)

Configuration Files:

  • knip.json - Knip configuration file
    • Currently untracked
    • DECISION NEEDED: Should this be committed to the repository?
    • Pros: Team benefits from reduced false positives
    • Cons: Adds another config file to maintain

Package Changes (Not Applied Yet):

  • package.json - Will be modified when Phase A is executed
  • package-lock.json - Will be updated when dependencies are installed/removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment