fix(eslint-plugin-sdk): build the plugin at install time - #2001
Open
toiroakr wants to merge 3 commits into
Open
Conversation
…umer The package now resolves its entry point from the gitignored dist/, but nothing built it outside the pretest hook and prepack. A fresh clone had no plugin to load, so the lefthook pre-commit hook failed to lint the create-sdk templates, and any vitest invocation that skipped pretest linted a stale bundle or none at all. Build from prepare so an install produces the entry point, build from a vitest globalSetup so every test entry point covers it, and build the plugin in the lefthook checks hook alongside the SDK. Also stop skipping the library check for the published declaration, so tsconfig.dist.json verifies dist/index.d.ts itself instead of only its usage sites, and widen the vitest include so tests under src/lib run.
🦋 Changeset detectedLatest commit: 5dc81f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The generated dist/index.d.ts is derived from sources that tsc --noEmit already checks, so type-checking the artifact only guards against a dts bundler regression. src/index.test-d.ts covers the same public type contract at the source level, test-dist/index.test-d.ts was a near copy of it, and tsconfig.dist.json resolved through moduleResolution bundler rather than the way a consumer would, so it never tested what set it apart. No other package here checks its build output this way. Reverting the pre-commit hook change for the same reason: prepare covers the fresh clone that motivated it, and building the plugin on every commit only guards against dist being deleted while node_modules stays. Collapse the three copies of the named-import lookup in ImportTracker into importedName(), and build through tsdown via node rather than the pnpm shim, which is a .cmd on Windows.
@tailor-platform/create-sdk
@tailor-platform/eslint-plugin-sdk
@tailor-platform/sdk
@tailor-platform/sdk-plugin-seed
@tailor-platform/sdk-plugin-tailordb-erd
commit: |
…gnostic prepare also runs when the package is installed as a git dependency, where the installing package manager may be npm or yarn and pnpm is not guaranteed to exist. Call tsdown through its node_modules/.bin entry instead, which every package manager provides. Surface the spawn failure reason from the vitest globalSetup: a build that fails to start (ENOENT) or dies on a signal reported only a generic message before. Cover the root-level config scripts in tsconfig, so a type error in vitest.global-setup.ts fails typecheck instead of passing silently.
Code Metrics Report (packages/sdk)
Details | | main (f90f24e) | #2001 (460c7dc) | +/- |
|--------------------|----------------|-----------------|-------|
- | Coverage | 78.7% | 78.7% | -0.1% |
| Files | 464 | 464 | 0 |
| Lines | 17817 | 17817 | 0 |
- | Covered | 14026 | 14024 | -2 |
| Code to Test Ratio | 1:0.4 | 1:0.4 | 0.0 |
| Code | 128029 | 128029 | 0 |
| Test | 62942 | 62942 | 0 |Code coverage of files in pull request scope (75.0% → 72.8%)
SDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1986, which moved the plugin from committed JS to a TypeScript build. The build product is gitignored, but only
pretestandprepackproduced it, so several entry points loaded a stale bundle or none at all.Build lifecycle
preparescript sopnpm installproducesdist/. Without it, a fresh clone had no plugin entry point and the lefthook pre-commit hook failed while linting the create-sdk templates (Failed to load JS plugin: @tailor-platform/eslint-plugin-sdk), blocking every commit.preparealso runs before pack/publish, soprepackis now redundant and was dropped. It invokestsdowndirectly rather thanpnpm run build, becausepreparealso runs for git dependencies installed with npm or yarn.globalSetupand droppretest, sonpx vitest, watch mode and the IDE extension exercise the code under test rather than a previously built bundle. The build spawns tsdown's JS bin throughnoderather than the.bin/shim, which is.cmd/.ps1on Windows — matching whatsrc/rules/test-helpers.tsalready does for oxlint.Test discovery and type coverage
includetosrc/**/*.test.ts. The previous list enumerated files and directories and did not coversrc/lib/, whereast.tsandsdk-bindings.tslive, so tests added there would have been skipped silently.includeto cover the root-level config scripts, so a type error invitest.global-setup.tsfailstypecheckinstead of passing silently.Checks
publintto the barepublint --strictused by every other package. It had grown a clean rebuild that ran a secondtsdownmid-check, plus a type check hidden behind a name that did not describe it.tsconfig.dist.jsonandtest-dist/. Type-checking the generateddist/index.d.tsonly guards against a dts bundler regression: the declaration is derived from sources thattsc --noEmitalready checks,src/index.test-d.tscovers the same public type contract at the source level, andtsconfig.dist.jsonresolved throughmoduleResolution: bundlerrather than the way a consumer would, so it never tested what set it apart. No other package here checks its build output this way.Cleanup
configs.recommended.rulesfrom therulesmap instead of re-listing every rule name.ImportTrackerintoimportedName(), and drop the duplicate specifier walk inno-unconditional-permit.AstNodeinstead of a third local copy of theOptionalMemberExpressionshape, and name node types with theExtractidiom already used inlib/ast.ts.package.test.ts, which asserted package.json verbatim.publint --strictcovers the entry points.