🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

publint

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

publint - npm Package Compare versions

Comparing version
0.3.20
to
0.3.21
+1
-1
package.json
{
"name": "publint",
"version": "0.3.20",
"version": "0.3.21",
"description": "Lint packaging errors",

@@ -5,0 +5,0 @@ "type": "module",

@@ -69,2 +69,3 @@ export type MessageType = 'suggestion' | 'warning' | 'error'

| BaseMessage<'USE_FILES'>
| BaseMessage<'USE_SIDE_EFFECTS'>
| BaseMessage<'USE_TYPE'>

@@ -71,0 +72,0 @@ | BaseMessage<'USE_LICENSE', { licenseFilePath: string }>

@@ -83,3 +83,5 @@ import {

const [module, modulePkgPath] = getPublishedField(rootPkg, 'module')
const [browser, browserPkgPath] = getPublishedField(rootPkg, 'browser')
const [exports, exportsPkgPath] = getPublishedField(rootPkg, 'exports')
const [imports, importsPkgPath] = getPublishedField(rootPkg, 'imports')

@@ -387,4 +389,25 @@ // Check if package published internal tests or config files

// Check if package likely targets bundlers and can benefit from sideEffects hinting
if (rootPkg.sideEffects == null) {
const hasBundlerSignals =
module != null ||
browser != null ||
(exports != null &&
typeof exports === 'object' &&
(objectHasKeyNested(exports, 'browser') || objectHasKeyNested(exports, 'module'))) ||
(imports != null &&
typeof imports === 'object' &&
(objectHasKeyNested(imports, 'browser') || objectHasKeyNested(imports, 'module')))
if (hasBundlerSignals) {
messages.push({
code: 'USE_SIDE_EFFECTS',
args: {},
path: ['name'],
type: 'suggestion',
})
}
}
// check file existence for browser field
const [browser, browserPkgPath] = getPublishedField(rootPkg, 'browser')
if (browser) {

@@ -463,3 +486,2 @@ crawlBrowser(browser, browserPkgPath, !!exports)

// recursively check imports
const [imports, importsPkgPath] = getPublishedField(rootPkg, 'imports')
if (imports && ensureTypeOfField(imports, ['object'], importsPkgPath)) {

@@ -466,0 +488,0 @@ crawlExportsOrImports(imports, importsPkgPath, true)

@@ -135,2 +135,4 @@ import picocolors from 'picocolors'

return `The package ${h.bold('publishes internal tests or config files')}. You can use ${h.bold('pkg.files')} to only publish certain files and save user bandwidth.`
case 'USE_SIDE_EFFECTS':
return `The package appears to be consumed by bundlers but does not specify ${h.bold('"sideEffects"')}. Consider adding ${h.bold('"sideEffects"')}: ${h.bold('false')} so bundlers can optimize tree-shaking if your package has no side effects.`
case 'USE_TYPE':

@@ -137,0 +139,0 @@ return `The package does not specify the ${h.bold('"type"')} field. Node.js may attempt to detect the package type causing a small performance hit. Consider adding ${h.bold('"type"')}: "${h.bold('commonjs')}".`