Comparing version 0.1.15 to 0.1.16
@@ -61,6 +61,3 @@ export type MessageType = 'suggestion' | 'warning' | 'error' | ||
| BaseMessage<'EXPORTS_TYPES_SHOULD_BE_FIRST'> | ||
| BaseMessage< | ||
'EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE', | ||
{ conditions: string[] } | ||
> | ||
| BaseMessage<'EXPORTS_MODULE_SHOULD_PRECEDE_REQUIRE'> | ||
| BaseMessage<'EXPORTS_DEFAULT_SHOULD_BE_LAST'> | ||
@@ -67,0 +64,0 @@ | BaseMessage<'EXPORTS_MODULE_SHOULD_BE_ESM'> |
{ | ||
"name": "publint", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Lint packaging errors", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -496,26 +496,15 @@ import { | ||
// a 'module' export should always precede 'import' or 'require' | ||
if ('module' in exports) { | ||
const conditions = [] | ||
if ( | ||
'require' in exports && | ||
exportsKeys.indexOf('module') > exportsKeys.indexOf('require') | ||
) { | ||
conditions.push('require') | ||
} | ||
if ( | ||
'import' in exports && | ||
exportsKeys.indexOf('module') > exportsKeys.indexOf('import') | ||
) { | ||
conditions.push('import') | ||
} | ||
if (conditions.length > 0) { | ||
messages.push({ | ||
code: 'EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE', | ||
args: { conditions }, | ||
path: currentPath.concat('module'), | ||
type: 'error' | ||
}) | ||
} | ||
// if there is a 'require' and a 'module' condition at the same level, | ||
// then 'module' should always precede 'require' | ||
if ( | ||
'module' in exports && | ||
'require' in exports && | ||
exportsKeys.indexOf('module') > exportsKeys.indexOf('require') | ||
) { | ||
messages.push({ | ||
code: 'EXPORTS_MODULE_SHOULD_PRECEDE_REQUIRE', | ||
args: {}, | ||
path: currentPath.concat('module'), | ||
type: 'error' | ||
}) | ||
} | ||
@@ -522,0 +511,0 @@ |
@@ -59,11 +59,5 @@ import c from 'picocolors' | ||
return `${c.bold(fp(m.path))} should be the first in the object as required by TypeScript.` | ||
case 'EXPORTS_MODULE_SHOULD_PRECEDE_IMPORT_REQUIRE': { | ||
let conditions = `the ${m.args.conditions | ||
.map((cond) => `"${c.bold(cond)}"`) | ||
.join(' and ')} condition` | ||
if (m.args.conditions.length !== 1) { | ||
conditions += 's' | ||
} | ||
case 'EXPORTS_MODULE_SHOULD_PRECEDE_REQUIRE': { | ||
// prettier-ignore | ||
return `${c.bold(fp(m.path))} should come before ${conditions} so it can take precedence when used by a bundler.` | ||
return `${c.bold(fp(m.path))} should come before the "require" condition so it can take precedence when used by a bundler.` | ||
} | ||
@@ -70,0 +64,0 @@ case 'EXPORTS_DEFAULT_SHOULD_BE_LAST': |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48210
1299