qleaner 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +24 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,6 +11,7 @@ A powerful CLI tool to analyze and clean up your React codebase by finding unuse
11
11
  - ⚙️ **Flexible configuration**: Exclude directories and files from scanning
12
12
  - 🚀 **Fast performance**: Efficient file scanning across large codebases
13
13
  - 💪 **TypeScript support**: Works with TypeScript, JavaScript, JSX, and TSX files
14
+ - 🧪 **Dry run mode**: Preview what would be deleted without actually deleting files
14
15
 
15
16
  ## Installation
16
17
 
@@ -78,6 +79,7 @@ qleaner qlean-scan <path> [options]
78
79
  - `-f, --exclude-file <file...>` - Exclude files from the scan
79
80
  - `-F, --exclude-file-print <files...>` - Do not print the excluded files
80
81
  - `-t, --table` - Display results in a formatted table
82
+ - `-d, --dry-run` - Show what would be deleted without actually deleting (skips prompt)
81
83
 
82
84
  **Examples:**
83
85
 
@@ -99,6 +101,12 @@ qleaner qlean-scan src -e node_modules dist -f "**/*.config.js"
99
101
 
100
102
  # Scan with table output and exclusions
101
103
  qleaner qlean-scan src --table -e __tests__ dist -f "**/*.config.js"
104
+
105
+ # Dry run - preview what would be deleted without deleting
106
+ qleaner qlean-scan src --dry-run
107
+
108
+ # Dry run with table output
109
+ qleaner qlean-scan src --dry-run --table
102
110
  ```
103
111
 
104
112
  ## Output Formats
@@ -109,18 +117,21 @@ Qleaner provides two output formats:
109
117
  - Green for files
110
118
  - Yellow for imports
111
119
  - Red for unused files
120
+ - Cyan for dry run mode messages
112
121
 
113
122
  2. **Table output**: Formatted tables with organized columns (use `--table` flag)
114
123
  - Import tables show: File, Line, Column, and Import path
115
124
  - File tables show: File path
116
- - Unused files table shows: Unused file paths
125
+ - Unused files table shows: Unused file paths (or "Would Delete" in dry run mode)
117
126
 
118
127
  ## How It Works
119
128
 
120
129
  1. **File Discovery**: Recursively finds all `.tsx`, `.ts`, `.js`, and `.jsx` files in the specified directory
121
- 2. **Import Extraction**: Parses files and extracts all import statements
122
- 3. **Analysis**: Compares file paths with import paths to identify unused files
123
- 4. **Reporting**: Outputs the results in standard or table format based on your preferences
130
+ 2. **Import Extraction**: Parses files using Babel AST and extracts all import statements
131
+ 3. **Module Resolution**: Uses enhanced-resolve to properly resolve import paths (supports path aliases like `@/` and `~/`)
132
+ 4. **Analysis**: Compares file paths with resolved import paths to identify unused files
133
+ 5. **Reporting**: Outputs the results in standard or table format based on your preferences
134
+ 6. **Safe Deletion**: In dry run mode, shows what would be deleted without making changes. In normal mode, prompts for confirmation before deletion
124
135
 
125
136
  ## Supported File Types
126
137
 
@@ -156,11 +167,12 @@ You can exclude directories and files from scanning using the command-line optio
156
167
  ## Tips and Best Practices
157
168
 
158
169
  1. **Start with a small scope**: Begin by scanning a specific directory before scanning the entire project
159
- 2. **Use exclusions**: Exclude test files and build outputs when scanning for unused files
160
- 3. **Review before deleting**: Always review the unused files list before removing them - some files might be used dynamically (e.g., through dynamic imports, configuration files, or asset references)
161
- 4. **Use table format**: The table format is easier to read for large results
162
- 5. **Combine options**: Use multiple flags together for comprehensive analysis
163
- 6. **Check dynamic imports**: Files imported using dynamic imports (`import()`) may appear as unused but are actually needed
170
+ 2. **Use dry run first**: Always run with `--dry-run` first to preview what would be deleted before actually deleting files
171
+ 3. **Use exclusions**: Exclude test files and build outputs when scanning for unused files
172
+ 4. **Review before deleting**: Always review the unused files list before removing them - some files might be used dynamically (e.g., through dynamic imports, configuration files, or asset references)
173
+ 5. **Use table format**: The table format is easier to read for large results
174
+ 6. **Combine options**: Use multiple flags together for comprehensive analysis
175
+ 7. **Check dynamic imports**: Files imported using dynamic imports (`import()`) may appear as unused but are actually needed
164
176
 
165
177
  ## Important Notes
166
178
 
@@ -170,6 +182,8 @@ You can exclude directories and files from scanning using the command-line optio
170
182
  - Required for build processes
171
183
  - Used as entry points that aren't directly imported
172
184
 
185
+ 💡 **Tip**: Always use `--dry-run` first to preview what would be deleted. This is especially important in CI/CD pipelines or when scanning large codebases.
186
+
173
187
  ## Requirements
174
188
 
175
189
  - Node.js 14+
@@ -185,4 +199,4 @@ MIT
185
199
 
186
200
  ## Version
187
201
 
188
- Current version: 1.0.9
202
+ Current version: 1.0.13
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qleaner",
3
3
  "packageManager": "yarn@4.6.0",
4
- "version": "1.0.13",
4
+ "version": "1.0.15",
5
5
  "main": "command.js",
6
6
  "bin": "./bin/cli.js",
7
7
  "scripts": {