Skip to content

Commit f9f7a95

Browse files
committed
Fix --cwd to --dir and minor edits in docs
1 parent d1e3e90 commit f9f7a95

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ✂️ Knip
22

3-
Knip scans your JavaScript and TypeScript projects for **unused files, dependencies and exports**. Things that should be
4-
eliminated. Less code means better performance and less to maintain, important for both UX and DX!
3+
Knip scans your JavaScript and TypeScript projects for **unused files, dependencies and exports**: things that can be
4+
removed! Less code means better performance and less to maintain, important for both UX and DX!
55

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

@@ -142,7 +142,7 @@ As always, make sure to backup files or use Git before deleting files or making
142142

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

147147
Excluding non-production files from the `projectFiles` allows Knip to understand what production code can be removed
148148
(including dependent files!).
@@ -162,8 +162,7 @@ and add `dev: true` to a file named such as `knip.dev.json`:
162162
}
163163
```
164164

165-
Use `-c knip.dev.json` and unused files and exports for the combined set of files as configured in `entryFiles` will be
166-
reported.
165+
Now use `-c knip.dev.json` to find unused files and exports for the combined set of files as configured in `entryFiles`.
167166

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

@@ -192,7 +191,7 @@ This way, the `--dev` flag will use the `dev` options (and also add `devDependen
192191

193192
#### Separate packages
194193

195-
In repos with multiple (published) packages, the `--cwd` option comes in handy. With similar package structures, the
194+
In repos with multiple (published) packages, the `--dir` option comes in handy. With similar package structures, the
196195
packages can be configured using globs:
197196

198197
```json
@@ -209,8 +208,8 @@ Packages can also be explicitly configured per package directory.
209208
To scan the packages separately, using the first match from the configuration file:
210209

211210
```
212-
knip --cwd packages/client
213-
knip --cwd packages/services
211+
knip --dir packages/client
212+
knip --dir packages/services
214213
```
215214

216215
#### Connected projects

src/util/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const resolveConfig = (
2323

2424
if (!resolvedConfig.entryFiles || !resolvedConfig.projectFiles) {
2525
console.error('Unable to find `entryFiles` and/or `projectFiles` in configuration.');
26-
console.info(`Add these properties at root level, or use --cwd and match one of: ${configKeys.join(', ')}\n`);
26+
console.info(`Add these properties at root level, or use --dir and match one of: ${configKeys.join(', ')}\n`);
2727
return;
2828
}
2929

src/util/ignore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const readIgnoreFile = async (filePath: string) => {
1010
try {
1111
contents = (await fs.readFile(filePath)).toString();
1212
} catch (error) {
13-
// TODO
13+
// Ignore silently (not every folder of every repo has a .gitignore file)
1414
}
1515
return contents.split(/\r?\n/).filter(line => line && !line.startsWith('#'));
1616
};

0 commit comments

Comments
 (0)