Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

publint

Package Overview
Dependencies
Maintainers
1
Versions
32
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.1.3 to 0.1.4

2

lib/index.d.ts

@@ -62,2 +62,4 @@ export type MessageType = 'suggestion' | 'warning' | 'error'

| BaseMessage<'EXPORTS_DEFAULT_SHOULD_BE_LAST'>
| BaseMessage<'EXPORTS_MODULE_SHOULD_BE_ESM'>
| BaseMessage<'USE_EXPORTS_BROWSER'>

@@ -64,0 +66,0 @@ export interface Options {

2

package.json
{
"name": "publint",
"version": "0.1.3",
"version": "0.1.4",
"description": "Lint packaging errors",

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

@@ -200,2 +200,12 @@ import {

crawlBrowser(browser)
// if the package has both the `browser` and `exports` fields, recommend to use
// the browser condition instead
if (exports) {
messages.push({
code: 'USE_EXPORTS_BROWSER',
args: {},
path: ['browser'],
type: 'suggestion'
})
}
}

@@ -328,3 +338,16 @@

if (fileContent === false) return
// file format checks isn't required for `browser` field or exports
// the `module` condition is only used by bundlers and must be ESM
if (currentPath.includes('module')) {
const actualFormat = getCodeFormat(fileContent)
if (actualFormat === 'CJS') {
messages.push({
code: 'EXPORTS_MODULE_SHOULD_BE_ESM',
args: {},
path: currentPath,
type: 'error'
})
}
return
}
// file format checks isn't required for `browser` condition or exports
// after the node condtion, as nodejs doesn't use it, only bundlers do,

@@ -331,0 +354,0 @@ // which doesn't care of the format

@@ -48,6 +48,12 @@ import c from 'picocolors'

// prettier-ignore
return `${c.bold(fp(m.path) + '.types')} should be the first in the object as required by TypeScript.`
return `${c.bold(fp(m.path))} should be the first in the object as required by TypeScript.`
case 'EXPORTS_DEFAULT_SHOULD_BE_LAST':
// prettier-ignore
return `${c.bold(fp(m.path) + '.default')} should be the last in the object so it doesn't take precedence over the keys following it.`
return `${c.bold(fp(m.path))} should be the last in the object so it doesn't take precedence over the keys following it.`
case 'EXPORTS_MODULE_SHOULD_BE_ESM':
// prettier-ignore
return `${c.bold(fp(m.path))} should be ESM, but the code is written in CJS.`
case 'USE_EXPORTS_BROWSER':
// prettier-ignore
return `${c.bold('pkg.browser')} can be refactored to use ${c.bold('pkg.exports')} and the ${c.bold('browser')} condition instead to declare browser-specific exports.`
default:

@@ -54,0 +60,0 @@ // TODO

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc