Repository navigation
v0.4.0
Install
pnpm add -D skif-cli # or npm install -D, yarn add -D, bun add -D
cargo binstall skif-cli # or cargo install skif-cli
brew install goldziher/tap/skifscoop bucket add goldziher https://github.com/Goldziher/scoop-bucket
scoop install skifDocs: https://goldziher.github.io/skif/
Breaking changes
- Minimum supported Rust: raised to 1.100 for building the crates from source.
- Public API:
cargo-semver-checksagainst the 0.3.0 crates on crates.io reports
semver requires new major versionforskif-js-plugins(constructible_struct_adds_field:DepRef.dir;
struct_pub_field_missing:ScriptInfo.turbo_tasks),skif-rules(enum_variant_added:ToolchainKind::Bazel) and
skif-js(constructible_struct_adds_field:UnlistedBinary.runs_in); the bullets below also list the breaks it
does not flag. - Embedders of
skif-config:Js::isolate_workspacesis workspace isolation only. An embedder that set it for
knip's strict mode setsJs::strict(with_strict), which implies production mode and isolation and adds the
direct-dependency rules;JsAnalysis::strictfollowsstrict.Js::production_modeandJs::isolatedgive the
effective modes.Jsgainsstrict,use_public_hoistingandcompilers, so a struct literal ofJsneeds them
(#221). - Implementers of
skif_js_syntax::ModuleLoader: the trait gainsis_installedandholds_no_code, bothfalse
by default. The evaluator takes adefine…helper, a copying merge and a package whose methods keep nothing at their
word only for a package the loader calls installed, so a loader that does not implementis_installedgets those
calls as unknown; without a loader, every bare specifier counts as installed. - Library users that build these structs with literals or match these enums exhaustively: new public fields must be
set.skif-js-plugins:DepRefgainsdirandreader_lists,PluginContextgainsglobs(aGlobCache) and
sources(anOption<&PackageSources>), andScriptInfo::turbo_tasksis removed.skif-js:Moduleis
#[non_exhaustive](and gainsis_build_source),UnlistedBinarygainsruns_in,ConfigDependencygainsspan
andreader_lists.skif-js-syntax:Exportgainsused_whole_in_file.skif-rules:ToolchainKindgainsBazel
(ADR 0031). - Library users of
skif-workspace:DependencyEntry::nameandDependencyEntry::specifierareArc<str>instead
ofString, so a consumer can keep a name without copying its text; read them as&strwith&*entry.name, which
also compares with a string (&*entry.name == "react") (#206). - Configurations with
[js.workspaces.<dir>.paths]: a key or target with more than one*is a configuration
error, a key without*maps only that specifier, and"alias/*"no longer maps the barealias, as in TypeScript
(#214). - Consumers of
explain-usage --format json: a file loaded withnew URL("./x", import.meta.url)is listed with
the import kindurlinstead ofrequire, a whole use of a module object is no longer listed as a user of its type
exports, and the entry kindsenclosing-incomplete-scope,script(for the source of build output a script runs) and
bin-stubreplaceunknownfor the files they describe (ADR
0125,
#165).
Added
[js] isolate-workspacesand--isolate-workspaces: workspace isolation without production mode. Each workspace
package uses only the dependencies its ownpackage.jsonlists, so one default run checks every package, its tests,
scripts and tool configs included, against its own manifest, development dependencies included.[js] strictis the
configuration counterpart of--strict(production mode, isolation and knip's direct-dependency rules), so CI no
longer needs the flag. Setting the mode in the file gives every run,skif baseline writeandpruneincluded, the
same mode, andstale-js-configjudgesignore-dependenciesentries against that one run.skif migrate --from knip
writes knip's--strictto[js] strict = truewhen every script runs knip with it; when only some scripts do, a
note leaves it to a human. knip 5's--isolate-workspaces, which only split the TypeScript programs, stays without
effect (ADR 0005,
#221).[js.compilers], the static counterpart of knip'scompilers: an extension skif has no reader for is read by regular
expressions with one capture group (html = { imports = ['<script[^>]+src="([^"]+)"'] }), whose captures are imports
resolved from the file, or with one of skif's readers (page = { as = "mdx" }). Such files join the default project,
sounused-filesjudges them, and their imports count as usage and are reported byunresolved-importsand
unlisted-dependencieslike written ones. An invalid entry is a configuration error, andskif migrate --from knip
points a compiler it cannot translate at the table (#209).[js] use-public-hoisting(defaultfalse): a package that pnpm'spublic-hoist-patternorshamefully-hoist
(pnpm-workspace.yaml, else the root.npmrcbefore pnpm 11) or rules_js'spublic_hoist_packageshoists into a
node_modulesabove a package is available to it, so importing it unlisted is nounlisted-dependenciesfinding.
unused-dependenciesand strict mode are unchanged.YamlSourceofskif-workspacegainspublic_hoist_patternand
shamefully_hoist, andskif-js-pluginsexportsbazel::public_hoist_packages(ADR
0123,
#178).- JS rules for knip's
subpathsissue type:unused-subpath-imports(warning) reports apackage.jsonimports
entry that no#specifier of the package's files selects, with an unsafe fix that removes it;
unused-subpath-exports(off by default, as knip'sincludeSubpathExports) reports anexportssubpath that no
workspace package imports by name, the package itself included, and has no fix. A pattern entry (#utils/*,
./features/*) is used when any import matches it, an exact entry wins over a pattern as in Node.js, and a subpath
that publishes no module (./package.json, a stylesheet) is not reported. Production mode reports neither, because
test files may be the only importers.--include subpathsand--fix-type subpathsselect the imports rule, and
skif migrate --from knipmapssubpaths,includeSubpathExportsand--include-subpath-exports
(#208). skif explain-usage --dependency <NAME> [--package <NAME|DIR>]explains why a dependency is used or unused in each
package that lists it: the verdictunused-dependenciesreaches and the importing files, mocks, commands, binaries,
scripts, plugins and tool configs that credit it, or the imports that count for nothing;--format jsonprints the
samereportdocument as the file explanation. The verdict and the evidence come from one record of uses. A package
that does not list the dependency has the verdictnot listed, without a credit from the@types, peer or
always-used rules, and the config files and lines that name a dependency the package does not list are listed
(unlisted-referencesin the JSON) (#150).- Bazel plugin for rules_js repositories: the
BUILD.bazelandBUILDfiles of a package are scanned as Starlark
text.node_moduleslabels (":node_modules/esbuild","//packages/app:node_modules/zod") andpackage_json.bzl
loads ("@npm//packages/app:esbuild/package_json.bzl") use the dependency of the package they name, reported at the
line of the label. A label of an enclosing package'snode_modules("//adev:node_modules/diff") in aBUILDfile
of a nested package counts only for the package it names, and a dependency so named that the labelled package does not
list is unlisted at theBUILDfile for that package. A comprehension that formats each string of a list literal
([":node_modules/%s" % name for name in ["typescript", "vite"]]) names the formatted packages; the patterns of a
glob(...)("node_modules/**"), any other format template and anode_modulestarget that is no valid npm package
name name no dependency. Theentry_pointofjs_binary,js_run_devserverandjs_testis an entry with public
exports. Thesrcsanddataofjs_libraryandts_project, and thedataof the other three, are build sources:
the files are used and what they import is followed, but their exports are not public, sounused-exports,
unused-types, the member rules andduplicate-exportsjudge them as any module's. A file that an entry rule also
matches stays an entry, and a rootBUILDfile can name the sources of a member below it. Those ofjs_testare not
used in production mode.skif-js-pluginsgainsPluginInput::BuildSource,ProductionBuildSourceand
ReaderDependencyandPluginOutput::build_sourcesandproduction_build_sources;WorkspaceInputsgains
build_sourceandproduction_build_source;UsageReportgainsbuild_sourceandchain_from_build_source,
serialized asbuild-sourceandchain-from-build-sourcewhen true, andskif explain-usagesays when a file is a
build source (ADR 0031, ADR
0124, ADR
0130,
#169, #220). - Bazel:
toolchain-pin-driftreads the root'sMODULE.bazel,WORKSPACE.bazelandWORKSPACE, a newbazel
kind read by default: thepnpm_versionofpnpm.pnpm(...)andnpm_translate_lock(...)(rules_js) and the
node_versionofnode.toolchain(...)andnodejs_register_toolchains(...)(rules_nodejs) are checked against
packageManagerand the root's Node version, statically. Afilesglob also reads.bzland*.MODULE.bazelfiles
(ADR 0031,
#175). knipplugin: in a project that runs knip next to skif, withknipas a dependency, knip's config files
(knip.json,knip.jsonc,.knip.json,.knip.jsonc,knip.*,knip.config.*, theknipkey ofpackage.json)
are configs and the JavaScript and TypeScript ones are entries, sounused-filesno longer reports them and what they
import is used. With it and thebazelplugin the table holds 207 plugins (ADR
0128,
#217).- Bun workspaces (#158): a workspace pattern with leading
..
segments (../shared,../libs/*) selects members outside the root, asbun installdoes: it is no longer an
invalid-workspace-fileerror, and counts as matched; the members it selects are listed in
DiscoveryFacts::outside_root_membersand are not linted.missing-package-manifestreports a member whose
package.jsonhas noname, which Bun skips without a warning (detailNamelessBunMember, an unsafe fix that names
it after its directory); discovery excludes such a member from analysis (DiscoveryFacts::nameless_members).
banned-dependencyandunsynced-dependency-familyreadbun.lockfor their lockfile scopes in a Bun workspace,
following each dependency to the copy Bun installs for it; abun.lockbalone is reported as not read. The members
claimed for a workspace whose root cannot be discovered keep a directory a positive pattern names by its literal path
despite a negation, as discovery does. - Bun plugin:
[test] rootandpathIgnorePatternsofbunfig.tomlreplace the default test entries with the
filesbun testruns,[lint] pluginsnames packages and files that are used, and aBun.buildentry point computed
fromimport.meta.diris resolved from the calling file, not the package
(#158). - Lerna:
stale-lerna-config(warn) reportsuseWorkspacesinlerna.jsonand alerna.jsonwithoutversion,
which Lerna 7 and later reject, and scripts that runlerna bootstrap,lerna addorlerna link, which Lerna 9
removed; the Lerna release is read fromnode_modules/lerna, else from the rootpackage.json, and without one
nothing is reported.lerna-packages-mismatch(warn) reportspackagesoflerna.json, which Lerna reads before
the package manager's workspaces, that select other packages than the workspace declaration skif follows; the finding
names both lists and the packages only one selects.DiscoveryFacts::lernarecords a valid rootlerna.json
(LernaFacts) also when another file declares the members (ADR
0119,
#189, #190).
Changed
- JS: a use of a module object as a whole (a namespace import passed around, spread, indexed with a computed key or
named intypeof ns, andrequire("./m")orimport("./m")) uses every value export of the module and none of its
interfaces and type aliases, which it cannot reach; such a type stays used when read by name (ns.Type) or when the
importer exports the namespace itself (export default ns), and is otherwise reported byunused-types. A file
loaded withnew URL("./x", import.meta.url)runs as a program of its own and keeps using every export, types
included, as an entry does (ADR 0018). unused-dependenciesandunused-dev-dependenciesno longer report a dependency on a workspace member that has no
main,module,exports,bin,browser,typesortypingsand no source file (a tooling, asset or style
package): such a dependency only orders tasks, as Turborepo's^buildand Nx's task dependencies do (ADR
0119,
#191).explain-usage: a file that the narrowed incomplete scope of an enclosing package makes an entry (a root test config
whose globs reach the files of the members below it, ADR 0016) has the entry kindenclosing-incomplete-scope, with
that package's directory inscope-packageand its scope and reasons inincomplete-scopeandincomplete; the
source of the build output a script runs (node dist/cli.jsforsrc/cli.ts) has the entry kindscript, and a file
an extensionlessbinstub loads the kindbin-stub.skif_js::EntryReasongainsEnclosingIncompleteScopeand
BinStub, andUsageReportgainsscope_package(#165).- Under
[js] discovery = "git"the toolchain scan (version files, Dockerfiles, shell scripts, workflows and the
filesglobs) and the search ofstray-lockfilefor BazelBUILDfiles and Dockerfiles beside a lockfile list
directories from the git index, as the JS discovery does, instead of walking them;autoandwalkwalk as before.
The git index reader moves fromskif-jstoskif-workspace, which exportsTrackedFiles(withreadand
for_discovery),IndexedFs<F>(generic over the wrapped file system),IndexCache,git_dirsand
git_common_dir.skif-lintgainsLintContext::tracked_files,LintContext::listing_fs,
LintContext::index_cacheandRunOptions::with_index_cache; the JS provider reads the index through the run's cache
when the host passes one, and theskiffacade'sLinterdoes, so a run parses the index once (ADR
0121, #200). - Performance (#206): the linters of a run read through the cache of
root discovery,yarn.lockis read only as far as its header, the claimed directories of an ancestor workspace are
found without loading its members, and several lookups use an index instead of a scan. The plugins that search a
package's sources (pino,zx,execa,nano-spawn,bun) list and read each source file once between them,
plugin globs are compiled once per run instead of being kept for the life of the process, the fix planner parses each
file once for all its fixes,--fixfinds the roots below the linted root without loading that root again,--watch
finds the directory it watches without discovering every root, the language server reads a file only for diagnostics
with a span, and the dependency analysis keeps names without copying them. The output is unchanged. The public API
gainsFileSystem::read_prefix(with a default),Workspace::claimed_dirs_with_fs,Selector::only_literals,
Selector::literal_key,Override::literal_packages,resolve_plugins_in,GlobCacheandPackageSourcesof
skif-js-plugins,WorkspaceListing::globsofskif-js,Documentofskif-edit, which parses a file once to plan
several sets of operations against it, anddiscover_targets_belowofskif;RenderOptions::with_sourcetakes
impl Into<Arc<str>>. - The GitHub Action is named
skif dependency linter, because the GitHub Marketplace needs a name that no other action,
user or organization holds; theuses:reference (Goldziher/skif@v0.4) does not change with the name. - The benchmark results moved from the README to a benchmarks
page in the docs, with the speed tables, the accuracy and knip
agreement results, a link to thebenchworkflow and its run, and the methodology. The README links to that page
and shows no numbers; the comparison guide shows generated headline claims instead (bench:claims: each tool's range of median ratios to skif, rounded
down), andmise run bench:importandmise run parity:publishwrite the tables to the new page. - The docs gain a Bazel guide (what skif reads from
BUILDand
MODULE.bazelfiles, fetching the release archives,bazel run,bazel testinputs, CI and the limits;
#173) and a Turborepo, Nx and Lerna
guide (what skif reads from each, running it as a root
task, task-ordering dependencies and the limits; #195). The npm and
Bun section no longer says thatrun()changes directory underbazel run: only the package'sskifbin does. - Parity harness:
skif-bench paritysets apart six more known deviations, so the parity baseline is recorded
again:imported-by-knip-unused-fileandimported-by-skif-unused-file(an export or member only one tool reports
that only files that tool lists as unused import, through re-exports),entry-module-duplicate(a duplicate only knip
reports in a default entry or published source, whichduplicate-exportsskips),bazel-build-file(a dependency a
BazelBUILDfile names, an unlisted finding at such a file, and a dependency only knip reports unused that is a peer
dependency of a dependency aBUILDfile credits, as skif credits the peers of a used package),declaration-file(a
.d.tsfile only knip reports unused) andsignature-type(a type or export a used export's signature names, ADR
0029). It reads theBUILDfiles below acoverage,outortargetdirectory that is not directly in the root or
a package directory, as skif's file discovery does.published-sourcemaps published paths through the tsconfig
outDirandrootDirof the package and covers the exports, types and members of the published sources;
not-judged-by-skifapplies the narrowed scope of an enclosing incomplete package to the members below it;
non-member-projectcovers skif-only unused files, unlisted dependencies and binaries, and the exports of a nested
root's default entries. An import one tool reports as unlisted and the other as unresolved counts as shared. The n8n
corpus entry also generates@n8n/db's gitignored migration indexes after its build, so knip no longer reports the
migrations they list as unused files, and theknip-config-errordescription inparity.mdsays that files of other
packages only a failed configuration's entries reach stay compared (next-js's rootjest.config.js).
Removed
skif_js_plugins::scripts::ScriptInfo::turbo_tasks: the task names passed toturbowere collected but never read;
turboarguments are still never taken for binaries or files (#193).
Fixed
- Working directories: a package that a workflow step, a tool config's command or a source file loads after
cd <dir>(run: cd packages/web && node -r @x/register x.js) is needed by the workspace package in that directory,
not by the package where the command starts. A step'sworking-directory(its own, or thedefaults.runof its job
or workflow), an Azure PipelinesworkingDirectoryand thecwdof a tool's command are read as a leadingcd, so
the binaries and packages of such a step are credited to the package there
(#147).unlisted-binariesreports a binary that a script, a workflow
step or a source file runs aftercdinto another workspace package that does not provide it, at the command and
naming the package (script `a` runs `x` in `packages/web`, which no dependency of `web` provides); a script of
that package that a package manager runs there is not a binary. Aftercdinto a project of its own below the
workspace (a directory with apackage.jsonthat is no workspace member, such as a nested root ofskif -r), the
binary is judged against that project's manifest, andReport::ancestor_dependency_useslists the dependencies of
that project that provide it, soskif -rcounts them as used by that root
(#163). Under npm withinstall-strategy=linkedin the root.npmrc,
a member's binary satisfies only the packages that list the member, as under pnpm's isolated linker
(#162).BinaryRefofskif-js-pluginsgainsjudged, false for a
binary that is only a credit, andPluginOutput::referenced_binariesleaves out the binaries a command runs in
another directory, whichrun_binariesholds;RunBinaryofskif-jsgainsjudged,WorkspaceInputsgains
relocated_dependencies, andRunsInis exported (ADR
0120). - Config evaluation reads more of a config as known (#148,
#166). An optional member (base?.setupFiles,undefinedwhenbase
isnullorundefined) and a computed member whose key evaluates to a string (base['setupFiles'],base[KEY])
read a known object asbase.setupFilesdoes..map,.flatMapand.filterof a known array call their callback
(an inline function, or one the config declares) with each element and its index, so Vitest projects spread from
['light', 'dark'].map((theme) => ({ test: { name: `browser-${theme}` } }))are known; an unknown element stays
unknown and a predicate whose result is not known keeps the element.Object.fromEntriesof a known list of
[key, value]pairs is their object, so a Vite input built as
Object.fromEntries(PAGES.map((p) => [p, path.resolve(__dirname, `${p}.html`)]))names its HTML pages. Template
literals and+with a string also write known numbers and booleans,+adds two numbers,===and!==compare
known primitives, and a constant index reads a known array (LIST[0]). The existing files given to a call the
evaluator cannot follow are entries wherever the call sits in the exported config
({ test: createTest({ setupFiles: ['./setup.ts'] }) }), not only when the config is the call's result; a file under
an exclusion key is still left out. A call of a well-known function that changes nothing it is given (path.join,
fs.readFileSync,JSON.stringify,console.log), where its name resolves to the module or global that declares it
and not to a local of the same name, no longer makes the config holding its result partly unknown, aresolvecall
(require.resolve, the functioncreateRequirereturns) is no change of the object it is called on, and aconst
holding a string or number shares no object with what it is given to, so a literalentrynext to
cert: fs.readFileSync(CERT)stays known.define…helpers of an installed package, copying merges (webpack-merge,
deepmerge,defu, themergeConfigof Vite and Vitest),createRequireand the sources ofObject.assignchange
nothing they are given and keep none of their arguments in another, so a change of one argument
(defineConfig({ test: { ...options }, resolve: { alias: aliases(pinCjs) } })) leaves the others known;
Object.assignonto an object literal (Object.assign({}, base)) copies the keys of what it is given, as a spread
does. A callback or loop over aconstlist of strings, or over the entries or values of aconstobject of strings,
that no change reaches changes nothing in it
(Object.entries(pages).map(([name, template]) => new HtmlWebpackPlugin({ chunks: [name], template }))), so a
multi-page webpack config keeps itsentryknown. A change leaves only what it may reach partly unknown: a change
through a part of a config (config.module.rules.unshift(…),config.output.path = …,foo(config.module)) leaves
only that part unknown, also in what shares it (a local a function returns);pushandunshiftof a local list add
their elements, and under a condition the evaluator cannot decide the part is one of its values before and after. A
change made through aconstthat takes a part of a local of the same function
(const { coverage } = config.test; coverage.enabled = true) is applied to that part of the local, and a call given
only such an alias (const { build } = config; applyDefaults(build)) leaves that part partly unknown; what else may
hold that part is partly unknown where it is read after the alias is declared, and a local with more than one such
alias, one shared with another function, or one that is assigned again, is not followed through it. A write through
one key also reaches another key of the same local that holds the same object (config.b = config.a; config.a.x = 1).
A spread of a local ({ ...options }) copies its keys: a change below one of them reaches the copy at that key only,
and a new value of a key of either leaves the other as it was; a change through a value spread from an object literal
(...(ci ? { plugins: list } : {})) reaches only the key it is spread at. A change below a key the config neither has
nor inherits leaves the config as it is; below an inherited key (__proto__,constructor) it leaves the config
partly unknown, and one below a key inherited from{ __proto__: base }reachesbase. A call of a function the
config declares (const r = set(config)) shares with the config only what the function may return of it, a change
through what a method returns (config.plugins.find(…)) reaches the object it is called on, and a function the config
only calls by name takes each argument as its parameter, apart from what it returns, so a value a call may change
(_.defaults({}, env)) passed to a function that builds a fresh config no longer leaves that config'sentry
unknown; one that returns its parameter, or stores it in what it returns ({ e: env },config.x = env), still
shares it there, as do a getter, method or callback in what it returns and a parameter's default (b = a). A change
of what a workspace factory returns
(const config = createVitestConfig(options); config.test.setupFiles.push('./setup.ts')) leaves only that part partly
unknown, and the values imported from the factory's module known, when the factory builds new objects. Configs
exported side by side (module.exports = [a(), b()]) no longer leave each other partly unknown. A call that may
change the whole config still leaves all of it partly unknown. - Config evaluation no longer reads values code may change as known. A call whose effect is not known (a function
the config or a library declares, anewof a class other than a builtin one) may change every object it is given, in
any position and through a spread, also when the call's result is used, and every local an object or array literal it
is given holds, at any depth (kit.fill({ cfg: config }),foo([config])); a spread of a local there
(foo({ ...options })) leaves all of the local partly unknown. A list or string method (push,concat,slice)
counts as changing only its object when that object is known to be a list or string, and a change through an element
of a list leaves every element open. A loop name (for (const rule of config.module.rules)), a callback parameter
(rules.forEach((r) => …), also one after the element:forEach((name, index, list) => list.push(…)), over aconst
list of strings too), a name a destructuring assignment sets and a function assigned with=share with what they
take, an alias of a local that shares an object with a changed one is no longer applied to it, a write in a class body
leaves what it reaches unknown, and the object of awithstatement is partly unknown after it.
Object.defineProperty,Reflect.definePropertyandObject.definePropertiesare nodefine…helpers: they change
their first argument, the first two only at the key they name when it is a string. A write,delete,pushor
Object.assignthrough an object that is not a name or a member chain (config.module.rules.find(…).loader = …,
(prod ? config.prod : config.dev).devtool = false) reaches each part of a local that object may be instead of being
dropped. A list method that calls a function it is given with the list's elements (configs.forEach(withSentry),
list.forEach(fn, thisArg)) changes nothing only when that function is written in place or declared by the config and
nothisobject follows it; otherwise the elements and that object are partly unknown. Calling a local that holds a
function the evaluator does not follow (const addAlias = aliaser(config); …; addAlias('~', './lib')) leaves what it
was made from partly unknown.Object.assign,Object.defineProperty,Reflect.defineProperty,JSON.stringifyand
JSON.parsegiven their arguments through a spread (Object.assign(...[config, extra])) may change every object the
spread gives, andJSON.stringifyandJSON.parsegiven a replacer or reviver other than a literal holding no
function (JSON.stringify(config, replacer)) may change what they are given. A merge given options that may hold a
function (deepmerge(a, b, { arrayMerge })), and an export of a merge package that is no copying merge
(deepmergeInto,defuFn,mergeWithCustomize), may change what it is given; the value ofdeepmergegiven options
and ofmergeWithis unknown, as they may merge any way. Adefine…helper, a copying merge and a package whose
methods keep nothing are trusted only for an installed package: a bare specifier the evaluator does not follow that
names a workspace package or that nonode_modulesdirectory above the config, up to the workspace root, holds (a
tsconfigalias such as@app/tools) is code of the project, but in a project whosenode_modulesdirectories hold
no package (none at all, or only caches such as.vite) every name of no workspace package counts as installed, and
under Yarn Plug'n'Play (a.pnp.cjsat the root) a dependency the importing package or the root declares from a
registry is installed. Such a helper or merge from a module of the project (require('./tools'),#tools,@/tools,
import { defineConfig } from './define') or a workspace package that the evaluator cannot follow, and adefine…
function taken from an object the config declares (const { defineProperty } = Object,
globalThis.Object.defineProperty(…)), is unknown instead of the value it is given or the merge of it. A method of a
package keeps nothing it is given in the package only when the config does nothing else with the package
(_.merge(…)) and the evaluator does not follow it: what a method of a workspace package returns (base.self()), or
of one the config stores a value in (pkg.config = local), may hold what the package holds, as may what a method of a
package returns once the config gives a method a function, a call's result or an object holding one
(store.set(() => config)), which the package may keep and give back. An imported value the config changes
(base.build.outDir = 'out',withPlugins(base), a write through a local holding it) is read as changed instead of
as its module computes it; a change through one import of a module reaches its other imports (ns.defaultand the
default import, two exports that may be one object), and a change of a value of another module the config imports
reaches it too. A call of a function of a project module or a workspace package that changes a value of a module (an
import of its own, a binding it exports, directly or through a function of another module it calls), and a module
imported or required only for its effects (import './setup'), leave every value the config imports from such modules
partly unknown; a module whose functions change no such value (name()returning a string, a factory that builds and
returns a new config, also one the module calls when it is loaded) leaves them known. A function of a followed module
changes a value of a module also through what it keeps for every call (f.cache = base,add.bind(null, base), what
a generator or anasyncfunction made when the module is loaded was given), throughthisorsuperwhere that may
be such a value, also through a binding taking whatthisholds (const list = this.plugins), through a function it
re-exports (export { tweak } from './tweak',export * from './tools') or hands out
(import { tweak } from './tweak'; export { tweak },export const tools = { tweak }), also from a module that is
neither followed nor installed, and by calling a function of such a module (import { setup } from '@app/setup').
What a function imported from a followed module returns (getBase()), and what a function read other than by name or
as a method returns ((0, base.self)()), may hold any value the config imports from such modules. A write through
thisin a constructor or a field initialiser giving the new instance a key (this.options = options), or in a
method of a class or of a plugin's hooks object a factory returns (load(id) { this.addWatchFile(id); }), changes no
value of a module, so a local Vite, Rollup or webpack plugin leaves the shared config it is used with known, and a
re-export of a file that holds no code (a declaration file, JSON, a stylesheet, an asset) changes nothing. What a
module imported for its values does when it is loaded, code a value runs implicitly (a getter,toStringthrough a
template literal orString(x),toJSONthroughJSON.stringify) and a later change an imported function makes to
an object an earlier call gave it are still not followed. - Vite and Vitest plugins: a
rootthat is one of several relative directories (a condition the evaluator cannot
decide, such asprocess.env.X ? path.resolve('ui') : __dirname) reads the HTML entries of each instead of leaving
the package incomplete. A path function, a template literal or+over such a value is one of the results of each
(path.join(dir, 'vitest.setup.ts')is one of two paths), and a list of files or patterns whose value or element is
one of several known strings (Vitest and Jest setup files and test globs, Vite, Rollup, tsup and webpack entries)
makes each an entry candidate: one that names no file is what another branch would give and is dropped, and the
package is judged. An alternative that is not a known string still leaves it incomplete. - JS,
paths:[js.workspaces.<dir>.paths]keys are matched astsconfigpathsare: one*anywhere in the key
matches any text, so the catch-all"*"and keys such as"serv*"or"*.svg"map imports instead of being dropped,
and the matching keys are tried longest prefix first, an exact key before every wildcard; relative and absolute
specifiers are never mapped (#214). An import that a package's own
tsconfigpathsmap into its sources (src/*to./src/*) is no longer an import of the workspace package whose
name it starts with (a member namedsrc). Strict mode reported it as that package unlisted, and the other modes
counted it as a use of the member (#215). - JS, production mode: the development entries of plugins (Storybook stories, test files, Vitest
setupFiles) are
left out of the project, as knip does, so they are no longer reported byunused-files
(#210), and thestartscript ofpackage.json, knip's production
script, is kept, so the files it runs are production entries and no longer reported byunused-files
(#216). - JS: a directory that an
[js] ignore-workspacesglob matches also leaves the packages above it, as knip's
ignoreWorkspacesdoes: its files that belong to no skipped member are no longer analysed and reported in the root
(ADR 0005,
#218). - JS, exports:
ignore-exports-used-in-fileexempts an import binding the file re-exports and reads as a value
(import a from "./a"; export { a, bMod as b }; export default { a, b: bMod }), as it exempts a local declaration,
and amodule.exports = { X }member whose binding the file reads outside that object, also under
unused-namespace-exports; a barrel that exports every module by name and again through its default object is no
longer reported in full (#211). The exports of a Svelte component's
instance<script>(export let label,export const,export function) are props and instance accessors, so
unused-exportsno longer reports them; the exports of the module script (<script context="module">in Svelte 4,
<script module>in Svelte 5) are still judged, and a package with a reached.sveltefile usessvelte, which is
no longer reported byunused-dependencies(#212). A namespace import
read through JSX member tags (<S.Button />,<S.Button></S.Button>) reads the member after the namespace, as
S.Buttondoes, instead of using the module as a whole; a nested tag (<S.Ctx.Provider />) readsCtx, and the
other exports of the module are reported byunused-namespace-exports
(#213). Pattern keys ofexportsandimportsmaps are selected as
Node.js orders them: of two patterns with the same prefix, the longer one wins (./features/*.cssover./features/*
for./features/a.css). - JS, enums: a whole use of an enum in the file that declares it (
Object.values(E),Object.keys(E),E[key], a
spread,for (k in E), passing, storing or returningE,typeof E,keyof typeof E,`${E}`in a template
literal type) uses every member, as a whole use in another file does;unused-enum-membersreported them all. A type
annotationx: Estill uses no member. skif now reports fewer enum members than knip in such files (ADR
0126); the parse cache schema is raised. - JS, declaration files:
.d.mtsand.d.ctsfiles are declaration files wherever.d.tsfiles are: a declaration
file outside the module graph is left out ofunused-filesand itsdeclare moduleblocks name ambient modules,
explain-usagegives it thedeclaration-fileabsence, and the AWS CDK and Knex plugins skip it when scanning
sources. Before, those checks named.d.tsonly.skif-js-syntaxgainsis_declaration_fileand
DECLARATION_SUFFIXES(#100). unlisted-dependencies: a peer dependency that a listed package marks optional
(peerDependenciesMeta.<name>.optionalin its installed manifest,optionalPeersinbun.lock, the same field in
the other lockfiles) no longer provides an unlisted import of it, because the package manager does not install an
optional peer for its host. A required peer still does; crediting a listed dependency as a peer of a used one is
unchanged (#96).stale-js-config(package-entry) reports abinpath that a build running only the TypeScript compiler
("build": "tsc") cannot write, because no file of the package is named after it, also when a.gitignorehides it
(*.js, as CDK templates ship), and the package is judged from its other entries instead of being listed in
incomplete-packageswithunmapped-published. Abinpath a source file is named after, or that another build step
may write, keeps the package unjudged as before, gitignored or not.- pnpm: a
pnpm-lock.yamlof pnpm 11 and later that holds two YAML documents, the package manager's environment
(configDependencies,packageManagerDependencies) and the project's lockfile, is read: the lockfile checks
(banned-dependencyandunsynced-dependency-familywith a lockfile scope,stale-patched-dependencies) judge the
project's document instead of reporting that the lockfile cannot be read, and the binaries and peers the JS analysis
takes from the lockfile no longer include pnpm's own packages. Both documents must be lockfile format 9
(#223). - Migrate:
--mergeunites lists by entry name. A string and a{ name, reason }table with that name are one
entry, which keeps the existing reason or takes the migrated one, instead of both staying in the list. In[js]
entryandproject, a migratedx!replaces the existing plainx, which in production mode excluded the file the
!pattern makes an entry; the report names the list (replaced-existing). In the[js]ignore lists,xcovers
x!. Elsewhere a trailing!is part of the entry (ADR
0127, #219).
--merge --output <FILE>writes the merge of the existingskif.tomland the migration toFILEinstead of the
translation alone, and leaves the existing file as it is; an existingFILEis refused. A merge with theexact
profile no longer turns off the default rules a file without asourcesline relies on: it writes nooffvalue into
a file that has content, and the report lists those checks (left-as-existing). Migrating knip into a file with
[js] enabled = falsesets it totrue, which the report names (replaced-existing);Mergedgains
left_as_existingandreplaced_existing, andMigration::merge_summaryrenders the report of a merge
(#207). - Migrate: a knip ignore entry without a comment of its own takes the comment heading its group (the nearest comment
above an earlier entry of the same list) as itsreason, else the comment on the list's key (above
ignoreDependencies: [, after its opening bracket, or after the list on its line); before, a group heading reached
only the first entry and a key comment none, so a fully commented knip config failedrequire-ignore-reasonsafter
migration. The note of a list names its entries left without a comment.skif-js-syntaxgains
extract_config_comments, which reports group headings (ElementComment::heading) andPropertyComments. - Bazel: in a Bazel repository the JS analysis no longer reads the
bazel-*output trees, whose contents depend on
the last build: an import that reaches a file there is generated code, and a relative import of a missing file that
the nearestBUILDfile declares as an output (outs,out,stdout,out_dirs,out_dir) is not unresolved,
whether or notrootDirspoint intobazel-binand whatever was built. An import that noBUILDfile declares is
unresolved in every state (ADR 0031,
#170). - Bazel:
unlisted-binariesno longer reportsbazel,bazeliskandibazel: they are build tools of the
machine, asdockerandmakeare, unlessignore-global-binariesis off. A listed@bazel/bazeliskor
@bazel/ibazelis still used by the scripts that run them (#172). - Bazel:
nested-workspace-rootreports a workspace member inside a Bazel convenience link (bazel-<name>,
bazel-bin), which a*or glob segment of a pattern follows as pnpm's does, once with the detail
BazelConvenienceLinkand!bazel-*as the pattern to add. The member stays in the workspace but is excluded from
analysis, so the root's findings are no longer repeated underbazel-<name>/(ADR
0116,
#174). - Bazel:
stray-lockfilesees more Bazel consumers of a member lockfile: a label inside a longer string where
$(location ...),$(execpath ...)or another location function expands it (agenrule'scmd), and aglob(...)
of the lockfile's package whose include patterns match it and whose exclude patterns do not; a docstring no longer
counts as a label (#199). It no longer reports a member lockfile that
only another package'sBUILDfile names, or a macro such a file loads: when the files Bazel reads for a lockfile do
not name it, the Bazel repository is listed for itsBUILDfiles, skipping hidden directories,node_modules,
symbolic links and.bazelignored directories (ADR
0116,
#198). - Bazel: under
bazel test(TEST_TMPDIRset),--cachewithout--cache-locationkeeps its store in
$TEST_TMPDIR/skifinstead of writingnode_modules/.cache/skifinto Bazel's output tree through the runfiles links
(ADR 0031, #177),
andskif explain-usagefinds a file below a linked directory (bazel-bin) by its path through the link, as the lint
report names it, instead of failing with the canonical path as outside the workspace
(#176). stray-lockfilealso sees a Dockerfile elsewhere built from a member's directory: a
docker build -f <file> <context>(alsodocker buildx build,podman build) in a script or workflow, or a Compose
file'sbuild.context, gives that Dockerfile the member's directory as its context
(#199).- Nx: local plugins, executors and generators are followed. A
pluginsentry,executoror generator that is a
path relative to the workspace root or apathsalias of the roottsconfig.base.jsonis no longer an unlisted
package; a local plugin's module is an entry, and theimplementation,batchImplementationandfactoryfiles of
theexecutors,builders,generatorsandschematicscollections itspackage.jsonnames (or a workspace
package's own) are entries (#185). In a project scope (ADR 0032) whose
project.jsontargets run a tool's Nx executor (@nx/vite:build,@nrwl/vite:*), the tool's plugin runs without a
config file and applies its config-less conventions: Vite'sindex.htmlmakessrc/main.tsxan entry
(#202). A Cypresse2econfig that spreads Nx'snxE2EPreset()has
the preset'ssupportFileandspecPattern(src/support/e2e.{js,ts}andsrc/**/*.cy.{js,jsx,ts,tsx}, below
cypressDir), so the support files of Nx e2e projects are no longer unused (ADR
0118,
#188). - Scripts: the command of
lerna exec [flags] [--] <cmd>andnx exec [flags] -- <cmd>is walked as a command of
the package, aspnpm -r execis:lerna exec -- rimraf distusesrimraf, and an unlisted binary there is
reported.lerna runandnx runkeep reading task names (#187). - Turborepo and workspaces: a recursive run no longer lints the output of
turbo prune --dockeras two extra roots:
below the start path, thejsonandfulltrees of a directory without apackage.jsonthat holds a lockfile next
to them are skipped (#194).missing-package-manifestno longer
reports an Nx project (a directory with aproject.json) or a grouping directory whose content is only directories
the patterns select too, such aslibs/cartunder["libs/*", "libs/*/*"](ADR
0119,
#192). skif configaccepts--config <FILE>and--no-config, so--showand--explainreport the configuration a lint
run with the same flag uses; with-rand--configeach root below the start names the directory the file's
[js.workspaces]keys select it by (#149).
Full changelog: v0.3.0...v0.4.0