Skip to content

Commit

Permalink
Minor doc edits, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Nov 3, 2024
1 parent 7ef5429 commit db3fe40
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 30 deletions.
17 changes: 10 additions & 7 deletions packages/docs/src/content/docs/features/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Knip provides the following built-in reporters:

- `codeowners`
- `compact`
- [`disclosure`](#disclosure)
- [`json`](#json)
- [`markdown`](#markdown)
- [`disclosure`][1]
- [`json`][2]
- [`markdown`][3]
- `symbol` (default)

Example usage:
Expand Down Expand Up @@ -71,7 +71,7 @@ object per file structured like this:
}
```

The keys match the [reported issue types][1]. Example usage:
The keys match the [reported issue types][4]. Example usage:

```sh
knip --reporter json
Expand Down Expand Up @@ -137,7 +137,7 @@ The above can be copy-pasted where HTML and Markdown is supported, such as a
GitHub issue or pull request, and renders like so:

<details>
<summary>Unused files (2)</summary>
<summary>Unused files (2)</summary>

```
unused.ts
Expand All @@ -147,7 +147,7 @@ dangling.js
</details>

<details>
<summary>Unused dependencies (2)</summary>
<summary>Unused dependencies (2)</summary>

```
unused-dep package.json
Expand Down Expand Up @@ -251,4 +251,7 @@ Example usage:
knip --preprocessor ./preprocess.ts
```

[1]: ../reference/issue-types.md
[1]: #disclosure
[2]: #json
[3]: #markdown
[4]: ../reference/issue-types.md
6 changes: 3 additions & 3 deletions packages/docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import Contributors from '../../components/Contributors.astro';
<CardGrid>
<Card title="Why?" icon="approve-check">

Knip finds and fixes unused files, exports and dependencies. Use it for enhanced
code and dependency management.
Knip finds and fixes unused files, exports and dependencies. Use it for
enhanced code and dependency management.

Read the full explanation: [why should I use Knip?][1]

Expand All @@ -54,7 +54,7 @@ import Contributors from '../../components/Contributors.astro';

:::div{.sponsor}

[Support Knip!][2]
Enjoying Knip? [Support it!][2]

:::

Expand Down
33 changes: 22 additions & 11 deletions packages/docs/src/content/docs/reference/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ This graph allows to report more interesting details, such as:
- List of all binaries used
- List of all used (OS) binaries not installed in `node_modules`

### Why doesn't Knip just read the lockfile?

Knip reads the `package.json` file of each dependency. Most of the information
required is in the lockfile as well, which would be more efficient. However,
there are a few issues with this approach:

- It requires lockfile parsing for each lockfile format and version of each
package manager.
- The lockfile doesn't contain whether the package [has types included][4].

## Module Resolution

### Why doesn't Knip use an existing module resolver?
Expand All @@ -143,7 +153,7 @@ seem to meet all requirements to be usable on its own by Knip:
`module.js`

A few strategies have been tried and tweaked, and Knip currently uses a
combination of [enhanced-resolve][4], the TypeScript module resolver and a few
combination of [enhanced-resolve][5], the TypeScript module resolver and a few
customizations. This single custom module resolver function is hooked into the
TypeScript compiler and language service hosts.

Expand Down Expand Up @@ -179,7 +189,7 @@ file. They're not a concept in Knip.

A TypeScript program has a 1-to-1 relationship with workspaces if they're
analyzed in isolation. However, by default Knip optimizes for performance and
utilizes [workspace sharing][5]. That's why debug output contains messages like
utilizes [workspace sharing][6]. That's why debug output contains messages like
"Installed 2 programs for 29 workspaces".

### Why doesn't Knip match my TypeScript project structure?
Expand Down Expand Up @@ -211,7 +221,7 @@ Knip shares the files of multiple workspaces in a single program if their
configuration allows it. This optimization is enabled by default, while it also
allows the module resolver (one per program) to do some more caching.

Also see [workspace sharing][5].
Also see [workspace sharing][6].

### Why doesn't Knip just use `ts.findReferences`?

Expand Down Expand Up @@ -293,7 +303,7 @@ other file types.
Knip comes with basic "compilers" for a few common non-standard file types.
They're not actual compilers, they're regular expressions only to extract import
statements. Override the built-in Vue "compiler" with the real one in your
project. Also see the answer to the previous question and [Compilers][6].
project. Also see the answer to the previous question and [Compilers][7].

## Miscellaneous

Expand Down Expand Up @@ -322,7 +332,7 @@ Which mode should've been the default? They both have their merits:
tooling, including most issues found in production mode. This mode has the
most impact on DX, for the same reason.

Also see [production mode][7].
Also see [production mode][8].

### Why doesn't Knip have...?

Expand All @@ -346,13 +356,14 @@ Examples of features that have been requested include:

These are all interesting ideas, but most increase the API surface area, and all
require more development efforts and maintenance. Time is limited and
[sponsorships][8] currently don't cover - this can change though!
[sponsorships][9] currently don't cover - this can change though!

[1]: ../guides/handling-issues.mdx#external-libraries
[2]: ../explanations/why-use-knip.md#comprehensive
[3]: ../features/script-parser.md
[4]: https://www.npmjs.com/package/enhanced-resolve
[5]: ../guides/performance.md#workspace-sharing
[6]: ../features/compilers.md
[7]: ../features/production-mode.md
[8]: /sponsors
[4]: ../guides/handling-issues.mdx#types-packages
[5]: https://www.npmjs.com/package/enhanced-resolve
[6]: ../guides/performance.md#workspace-sharing
[7]: ../features/compilers.md
[8]: ../features/production-mode.md
[9]: /sponsors
8 changes: 4 additions & 4 deletions packages/docs/src/pages/sponsors.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import SponsorsComponent from '../components/Sponsors.astro';
<div class="column">
<p>
Knip is a powerful tool that helps thousands of developers keep their
JavaScript and TypeScript projects lean and maintainable. By identifying
unused files, dependencies and exports, Knip saves teams valuable time.
JavaScript and TypeScript projects lean and maintainable. Knip saves
teams valuable time and resources.
</p>

<p>
As the creator and primary maintainer, I (<a href="https://github.com/webpro">Lars Kappert</a>) am dedicated to the continued
As the creator and primary maintainer, I'm dedicated to the continued
development and support of Knip. With my deep expertise in JavaScript
and TypeScript, its ecosystem, frameworks and tooling, I ensure Knip
remains best-in-class.
Expand Down Expand Up @@ -43,7 +43,7 @@ import SponsorsComponent from '../components/Sponsors.astro';
<p>
You or your company logo will be added to this page if you decide to
support the project on an ongoing basis. Eternal gratitude to the
companies and people that are already supporting me:
companies and people that are already supporters:
</p>

</div>
Expand Down
27 changes: 27 additions & 0 deletions packages/docs/src/styles/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,30 @@ section.plugins li {
border-color: var(--sl-color-black);
}
}

#starlight__search .pagefind-ui__result-title:not(:where(.pagefind-ui__result-nested *)):focus-within,
#starlight__search .pagefind-ui__result-nested:focus-within {
.pagefind-ui__result-link,
.pagefind-ui__result-excerpt,
.pagefind-ui__result-excerpt mark {
color: var(--sl-color-text-accent);
}
}

:root[data-theme='light'] {
#starlight__search .pagefind-ui__result-title:not(:where(.pagefind-ui__result-nested *)):focus-within,
#starlight__search .pagefind-ui__result-nested:focus-within {
.pagefind-ui__result-link,
.pagefind-ui__result-excerpt,
.pagefind-ui__result-excerpt mark {
color: var(--sl-color-black);
}
}
}

.social-icons a:hover {
opacity: 1;
svg {
color: var(--sl-color-bright-orange);
}
}
5 changes: 0 additions & 5 deletions packages/knip/src/manifest/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ export const loadPackageManifest = ({ dir, packageName, cwd }: LoadPackageManife
}
};

// type GetFilteredScriptsOptions = {
// isProduction: boolean;
// scripts?: Scripts;
// };

export const getFilteredScripts = (scripts: Scripts) => {
if (!scripts) return [{}, {}];

Expand Down

0 comments on commit db3fe40

Please sign in to comment.