Repository navigation
v0.5.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
- Public API:
cargo-semver-checksagainst the 0.4.0 crates on crates.io reports
semver requires new major versionforskif-core(constructible_struct_adds_field:Tokens.empty_commands),
skif-js-syntax(enum_marked_non_exhaustiveandenum_no_repr_variant_discriminant_changed:ImportKind) and
skif-js-plugins(constructible_struct_adds_field:PluginContext.members); the bullets below also list the
breaks it does not flag. - Public API:
skif-js-syntax'sImportKindgainsResolve(enum_variant_added) and is#[non_exhaustive],
so amatchon it outside the crate needs a wildcard arm, and later kinds are no longer a breaking change
(#225). - Consumers of
explain-usage --format json,explain-usage --dependencyand--trace-dependency --format json:
arequire.resolve("x"),createRequire(…).resolve("x")orimport.meta.resolve("x")is listed with the import
kindresolveinstead ofrequire(#225). - Library users that build
PluginContextofskif-js-pluginswith a literal: it gainsmembers, the
directories of the run's other packages below the package, whose sources theexeca,zx,nano-spawnandbun
plugins leave out;&[]reads them all (#97). - Library users that build
skif_core::shell::Tokenswith a literal: it gainsempty_commands, the commands of
redirections alone (> "$(x)") asEmptyCommands (#97). - Library hosts that lint nested roots themselves: the files of other projects that a plugin names as build
sources (a Bazelsrcs) moved fromReport::other_project_filesto the new
Report::other_project_build_sources. Pass those below the root, made relative to the nested root that owns them,
toRunOptions::with_extra_build_sourcesof its run, and credit those outside it as the files of
other_project_filesare; a host that reads onlyother_project_filesno longer makes them used
(ADR 0034,
#226).
Added
-
stale-js-configreports a plainentryorprojectpattern that cancels a pattern ending in!of its list
([js]or a[js.workspaces]table): any plain pattern matching the file a!pattern names, as in
entry = ["src/**", "src/main.js!"], or the same glob as a!glob. In a production run the plain pattern excludes
what the!one selects, while in a normal run the!one selects it alone. The hint says to remove the plain
pattern, or the!one if the files are not production code.skif migrate --from knipkeeps both patterns, since
knip also excludes them in production mode (#227). -
Public API (#206):
PackageSources::withinofskif-js-plugins
makes a listing of a package's sources that shares the texts it reads with another listing, and
WorkspaceListing::package_sourcesofskif-jsmakes one that shares them with the run's other packages. -
Public API (#97):
skif-js-syntaxexportsis_plain_word,
shell_quoteandshell_word, which quote a word of a command line as the command plugins do. -
Public API (#226): the build sources a multi-root host hands a
nested root.skif-core:Report::other_project_build_sourcesandReport::with_other_project_build_sources.
skif-lint:Emitter::report_other_project_build_source,Emitter::take_other_project_build_sources,
LintContext::extra_build_sourcesandRunOptions::with_extra_build_sources.skif:
RunOptions::with_extra_build_sources.
Changed
-
Performance (#206):
--watchscans the tree on up to four
threads, so on a large repository it polls more often and sees a change sooner; scanning takes up to about four
thirds of a core instead of a third. The files it compares are unchanged. The plugins that search a
package's sources (pino,zx,execa,nano-spawn,bun) share the texts they read between all packages of a
workspace and their Nx projects, so a source file is usually read once per workspace instead of once for every
package or project that searches it (pinoand theBun.check ofbunalso search a member's sources from the
root package, and every one of them searches an Nx project's sources from its package); packages resolved in
parallel can still read the same file at the same time. The output is unchanged. -
Performance (#224): evaluating a config that follows its imports
parses and analyses a module inside a cycle of imports once per distinct set of answers its imports give, instead of
at every entry; the analysis budget and the findings are unchanged. A change that reaches a whole class of linked
bindings is applied to that class once instead of once per change.ModuleLoader::holds_no_codeis asked once per
importing directory and specifier, asis_installedalready was. -
Performance: the
execa,zx,nano-spawnandbunplugins no longer walk the directories of a package's
members when they list its own sources, so a workspace root lists only its own directories and each member lists
its own, instead of the root walking every member's tree too; when a plugin of the package already listed every
source (pino), the own sources are taken from that listing. The source texts a plugin searches are read in
parallel, or one after the other on a single-threaded run (a library host sets it with the new
PackageSources::sequentialofskif-js-plugins). The output is unchanged. -
Performance: the analysis of which bindings may share a changed object follows a change only where it can reach
a binding the pass asks about, skips a change of a class of linked bindings an earlier change reached in full, and
applies the getters, setters and iterators code may run implicitly once per list of them, so large bundled modules
(a 2.8 MB GitHub Action bundle) parse several times faster. The output is unchanged.
Fixed
- Resolve calls:
require.resolve(x),createRequire(…).resolve(x)andimport.meta.resolve(x)return a path
and load nothing, so they no longer count as a use of every export of the module they name. The file they name stays
in use, what it imports is followed, and a package they name is still a used dependency, but its exports are judged:
unused-exportsnow reports the value exports nothing else imports (unused-typesalready reported its types, as a
resolve call never credited them). A module otherwise read only through a namespace (ns.a) stays namespace-only,
so its unread exports areunused-namespace-exports. A resolve call is no edge ofcircular-imports, and a module
an extensionless JavaScript mise file task only resolves is used but no entry, so its exports are judged too. A
computed relative specifier (require.resolve(`./tpl/${name}`)) is followed as a glob, as a computedrequire
is, and the call is found behind a TypeScript assertion ((require as NodeRequire).resolve(x)).skif-js-syntax
reports the call asImportKind::Resolve, and the analysis cache is invalidated. knip reports nothing for these exports, so the
findings are skif's alone (#225). - Nested roots under
-r: a file of a nested root that an enclosing root's plugin names as a build source (a
Bazelsrcsof the outerBUILDfile) is a build source of the nested root instead of an entry, so its unused
exports are reported there, as they are for a build source of a workspace member; a file the enclosing root also
imports or names as an entry stays an entry. A package of the nested root that such a build source belongs to is no
longer taken as one another root imports, sounused-subpath-exportsnow judges itsexportsunless an enclosing
root imports or runs one of its files
(ADR 0034,
#226). explain-usage: an importer that uses no export says what it takes instead ofthe whole module: a resolve call
its path, no export, a side-effect importruns it, no exportand a test-runner mocka test-runner call, no export(#225).unlisted-binaries: anode:child_process,execa, nano-spawn orBun.spawncall with a literal argument that
is not a plain word (execFileSync("sqlite3", [db, "select …"])) runs its program: the argument is one quoted word
of the command instead of dropping the call, so the binary is judged. The analysis cache is invalidated
(#97).unlisted-binaries,unused-files: a computed argument of such a call ends its command, instead of being left
out while the literals after it stay:spawn("node", [script, "out.js"])no longer runs a fileout.js. The
analysis cache is invalidated (#97).unlisted-binaries,unused-files: a short flag group whose letters all take a value reads as those flags, the
last taking the next word, as Node.js readsnode -pe "require('./package.json').version": the code is no file
and loads no package (#97).unlisted-binaries: every word of a command array (moonrepocommand,typescript.contentMapper.exec) that is
not a plain word is quoted the same way, so a word such as&&or#is an argument instead of shell syntax
(#97).unlisted-binaries: a command substitution runs in the directory of the command that holds it, after acdor
a workflow step'sworking-directory, instead of where the text starts:SUITE=$(pnpm exec tsx x.ts)in a step
withworking-directory: packages/webcreditstsxtopackages/webinstead of judging it at the root. So does a
substitution in a command of redirections alone (cd a && > "$(x)"runsxina), and one after apushdcan
popdback (#97).unlisted-binaries: theexeca,zxand nano-spawn plugins of a package read only its own source files, as the
bunplugin does, so a root that lists execa no longer judges the commands of its members' files against itself: a
member'sexeca(require.resolve(".bin/jscodeshift"))runsjscodeshiftof the member that lists it. A directory
with apackage.jsonthat is no workspace member, such asscripts/package.jsonwith only"type": "module", is
the package's own: thebunplugin no longer skips its files (#97).declare modulere-exports:export * from "x"andexport { a } from "x"inside adeclare moduleblock are
type-only imports ofx, as animportthere already was, so they usexor its@typespackage: a
declare module 'commander' { export * from '@commander-js/extra-typings'; }no longer leaves
@commander-js/extra-typingsunused. The block adds no export to the file, and a relative specifier there, which
TypeScript rejects, is no import. The analysis cache is invalidated
(#98).- Stylesheet
url(): aurl()that names a file of a package,~pkg/fileor@scope/pkg/filewith
npm-valid names (src: url("@ibm/plex/fonts/a.woff2")), uses the package, so it is no longer reported unused; its
query or fragment (a.eot?#iefix) is dropped. Otherurl()values stay assets: an unscoped bare path is relative to
the stylesheet and@/…is an alias. Such aurl()of a package that no manifest lists and that is not installed
is a bundler alias skif cannot see (url('@assets/images/bg.png'), Nuxt'surl(~assets/logo.svg)) or a missing
asset, so it is no unlisted import.skif-js-syntaxreports it asImportKind::Url, and the analysis cache is
invalidated (#98). - Subpath directories: a
package.jsonthat adds onlymain,module,types,typingsorbrowserin a
directory its parent package publishes as a subpath (exportshas./<dir>, orfileslists it) no longer makes a
project of its own, so the files there belong to the package:module.exports = require('@vue/compiler-sfc')in
vue/compiler-sfc/index.jsuses the dependency ofvue. The files that manifest points at are entries of the
package, soserver/index.jsof"files": ["server"]and what it requires are not unused. Afilesentry of
server/*orserver/**publishes the directory too (#98). - Configs inside
node_modules: a tool config that extends or references a config file by a relative path into a
node_modulesdirectory ("extends": ["./node_modules/ultracite/config/oxlint/core/.oxlintrc.json"]in
.oxlintrc.json) names that package, so it is used, also when it is not installed and the file cannot be read.
Only a config of the workspace names it this way: a config file that an installed config reaches in turn is a
dependency of that installed package (#98). @typesof typed packages: an import of a package whose installedpackage.jsondeclares its own types
(a non-emptytypesortypingsnaming a file the package holds) no longer uses its@typespackage, which
TypeScript does not read then, so a leftover@types/eslintbesideeslint9 is reported unused, as knip does. A
package that is not installed keeps its@typespackage used, and so does a subpath import (kit/helpers), which
the package's own types may not cover (#98).- Config evaluation: a getter, a setter or an iterator of an object or class instance a module makes, also one
Object.defineProperty,Object.defineProperties,Reflect.definePropertyorObject.createdefines, that writes
throughthis(get grow() { this.list.push(…) }) now changes what the object holds where code runs it with no call
written: a read or a write of its key, a destructuring (also of a parameter or a callback parameter), a spread,
for…ofandyield*(also throughnext,returnandthrow), a tagged template, a call skif does not follow, a
builtin that reads the object's keys (JSON.stringify) or anewof a class that is no builtin. A binding ofthis
(const self = this) counts asthis, a getter that gives a key ofthisa new value leaves only that key unknown,
and a method called onthiscounts only as far as it writes. A value the config reads that such a run may change is
unknown instead of read as unchanged, so a file the config reaches only through the change is no longer reported as
unused-files; adefine…helper orpath.joingiven the object runs none of them. Static getters,toString,
valueOf,toJSON,thenand the accessors of an object another module makes are not followed
(#228). - Build-output entries: a file a tool configuration names as an entry that does not exist, such as a webpack
entryofpath.join(__dirname, 'lib-esm', 'entry.js'), now stands for its source as a published path does:
through theoutDirandrootDirof atsconfig, then from a build output directory to itssrctwin, with.js
mapping to.tsand.tsx. The files the source reaches and the dependencies they import are no longer reported as
unused-filesandunused-dependencies. Such an entry in build output that maps to no source file makes its
package incomplete with the new causeunmapped-entry, whosefileis the entry, instead of being dropped while
the package was judged; an entry into nothing outside build output is still no entry
(ADR 0035).