Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: satisfies npm-pkg-lint & publint #94

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nekomeowww
Copy link
Contributor

With the check of trending use of npm-pkg-lint and publint:

$ npm pack
$ npx npm-pkg-lint
~/Git/modelcontextprotocol/typescript-sdk/modelcontextprotocol-sdk-1.0.3.tgz
  1:1  error  dist/client/index.test.js is not allowed in tarball        no-disallowed-files
  1:1  error  dist/server/index.test.js is not allowed in tarball        no-disallowed-files
  1:1  error  dist/inMemory.test.js is not allowed in tarball            no-disallowed-files
  1:1  error  dist/client/stdio.test.js is not allowed in tarball        no-disallowed-files
  1:1  error  dist/server/stdio.test.js is not allowed in tarball        no-disallowed-files
  1:1  error  dist/shared/stdio.test.js is not allowed in tarball        no-disallowed-files
  1:1  error  dist/client/index.test.d.ts.map is not allowed in tarball  no-disallowed-files
  1:1  error  dist/server/index.test.d.ts.map is not allowed in tarball  no-disallowed-files
  1:1  error  dist/client/index.test.js.map is not allowed in tarball    no-disallowed-files
  1:1  error  dist/server/index.test.js.map is not allowed in tarball    no-disallowed-files
  1:1  error  dist/inMemory.test.d.ts.map is not allowed in tarball      no-disallowed-files
  1:1  error  dist/inMemory.test.js.map is not allowed in tarball        no-disallowed-files
  1:1  error  dist/client/stdio.test.d.ts.map is not allowed in tarball  no-disallowed-files
  1:1  error  dist/server/stdio.test.d.ts.map is not allowed in tarball  no-disallowed-files
  1:1  error  dist/shared/stdio.test.d.ts.map is not allowed in tarball  no-disallowed-files
  1:1  error  dist/client/stdio.test.js.map is not allowed in tarball    no-disallowed-files
  1:1  error  dist/server/stdio.test.js.map is not allowed in tarball    no-disallowed-files
  1:1  error  dist/shared/stdio.test.js.map is not allowed in tarball    no-disallowed-files
  1:1  error  dist/client/index.test.d.ts is not allowed in tarball      no-disallowed-files
  1:1  error  dist/server/index.test.d.ts is not allowed in tarball      no-disallowed-files
  1:1  error  dist/inMemory.test.d.ts is not allowed in tarball          no-disallowed-files
  1:1  error  dist/client/stdio.test.d.ts is not allowed in tarball      no-disallowed-files
  1:1  error  dist/server/stdio.test.d.ts is not allowed in tarball      no-disallowed-files
  1:1  error  dist/shared/stdio.test.d.ts is not allowed in tarball      no-disallowed-files
  1:1  error  ./dist/index.js (pkg.main) is not present in tarball       no-missing-main

~/Git/modelcontextprotocol/typescript-sdk/package.json
  1:1  error  "keywords" must be set      package-json-fields
  1:1  error  "repository" must be set    package-json-fields
  1:1  error  Missing engines.node field  outdated-engines

$ npx publint
@modelcontextprotocol/sdk lint results:
Warnings:
1. pkg.exports is missing the root entrypoint export, which is defined in pkg.main. Environments that support the "exports" field will ignore pkg.main as "exports" takes the highest priority. Consider adding pkg.exports["."]: "./dist/index.js".
Errors:
1. pkg.main is ./dist/index.js but the file does not exist.

Basically this means:

  1. src/**/*.test.ts files should not be bundled into the package1.
  2. specified "main": "./dist/index.js" doesn't exist, since this package is sub-directory oriented, index.ts doesn't exist
  3. specified "types": "./dist/index.d.ts" doesn't exist either
  4. since CommonJS Support #90 has specified, this is a ESM only module, where as spec of ES6 specifies2345, main is only for Node.js, "main" is not needed
  5. missing of keywords
  6. missing of repository
  7. missing of engines.node

Motivation and Context

Follow the best practice of Node.js community projects and guidelines of how package.json and distributing packages can be organized.

How Has This Been Tested?

Yes, locally tested with verdaccio (private npm registry) with my MCP projects.

Breaking Changes

No.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Footnotes

  1. node.js - Is it a good practices to add tests files in the tsconfig.json exclude field? - Stack Overflow

  2. https://rollupjs.org/es-module-syntax/

  3. Modules: Packages | Node.js v23.4.0 Documentation

  4. javascript - What is the "module" package.json field for? - Stack Overflow

  5. https://github.com/nodejs/node-eps/blob/4217dca299d89c8c18ac44c878b5fe9581974ef3/002-es6-modules.md#51-determining-if-source-is-an-es-module

Co-authored-by: 藍+85CD <50108258+kwaa@users.noreply.github.com>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming of this file was borrowed from the shorted version of this official documentation suggested one: https://www.typescriptlang.org/docs/handbook/compiler-options.html with the consideration of make it shorter for developers to type with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant