Comments (10)
Thanks @weilbith!
I didn't know about .git/info/exclude
, that looks useful indeed.
For now, you could consider using a dynamic knip.ts
, read .git/info/exclude
, and its items to knip ignore
patterns (or as negated entry/project patterns).
from knip.
Wow, that was a fast reply! 😱
Thank you very much!
Ah, cool. That actually sounds like a sound idea!
I'll implement that for now. Do you think it will make it as a feature upstream? Should I contribute a PR?
In case someone stumbles across this issue and it is not (yet) implemented upstream, here is my version of adding it to my knip.ts
configuration:
import { readFile } from "fs/promises";
import type { KnipConfig } from "knip";
// TODO: Remove once feature was implemented upstream.
async function readGitInfoExcludePatterns(): Promise<string[]> {
const buffer = await readFile(".git/info/exclude");
return buffer
.toString("utf-8")
.split(/\r\n|\r|\n/)
.filter((line) => !!line.trim())
.filter((line) => !line.startsWith("#"))
.map((line) => (line.endsWith("/") ? `${line}**` : line));
}
export default async function composeConfiguration(): Promise<KnipConfig> {
const gitInfoExcludePatterns = await readGitInfoExcludePatterns();
return {
ignore: [
...gitInfoExcludePatterns,
// ... more patterns
],
// ... more configuration
};
}
from knip.
Thanks for sharing your solution!
Feel free to give this a shot. That part of the code is here: https://github.com/webpro/knip/blob/main/packages/knip/src/util/globby.ts#L59
from knip.
Feel free to give this a shot. That part of the code is here: https://github.com/webpro/knip/blob/main/packages/knip/src/util/globby.ts#L59
Hui, that's a function 😄
Let me see. Thinking about how to integrate it best. Because the current logic seem to be quite evolved, acting on various levels including the search for .gitignore
files, while there is always only a single .git/info/exclude
. 🤔
from knip.
Maybe you could consider something like moving everything inside the if
clause of entryFilter
to a separate function and call that function once for .git/info/exclude
.
from knip.
@weilbith Is this still something you fancy picking up? I have absolutely no hurries with this one, just checking up.
from knip.
Related Issues (20)
- Nx plugin doesn't look in `package.json`
- Nx plugin doesn't detect binaries without explicit executor
- File index.js and extensions that are omitted by default HOT 4
- storybook: @storybook/builder-vite is incorrectly listed as unused devDependencies HOT 1
- False positive for dev dependency listed in jest config HOT 1
- Add support for Ionic / enhance the capacitor plugin HOT 7
- Consider the file in package.json types not to be unused HOT 3
- Add a brief page to the documentation showing how to use on CI HOT 2
- `peerDependency` range conflicts with `typescript` beta releases
- Module Resolution Issues Across Multiple Workspaces with TSConfig Paths
- knip generates undesired code near to console.log lines HOT 1
- Autofix - remove trailing commas HOT 4
- TypeScript Namespace - Unsed exported constants not detected HOT 6
- Lazy imports not accessible when accessed by key HOT 10
- Workspaces no longer correctly identified since 5.10 HOT 6
- Issue a warning or fail if a specific file given as an entry point does not exist HOT 1
- Marked as unused if used only in Vue <template> HOT 11
- To read TypeScript configuration files Jest requires "ts-node" HOT 2
- Re-exported type reported as unused with `ignoreExportsUsedInFile` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knip.