Comparing version 0.1.12 to 0.1.13
@@ -74,3 +74,5 @@ #!/usr/bin/env node | ||
const depDir = await findDepPath(deps[i], pkgDir) | ||
const logs = depDir ? await lintDir(depDir, opts.level, opts.strict, true) : [] | ||
const logs = depDir | ||
? await lintDir(depDir, opts.level, opts.strict, true) | ||
: [] | ||
// log this lint result | ||
@@ -77,0 +79,0 @@ const log = () => { |
{ | ||
"name": "publint", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Lint packaging errors", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -214,2 +214,8 @@ import { | ||
const knownFields = ['types', 'jsnext:main', 'jsnext', 'unpkg', 'jsdelivr'] | ||
// if has typesVersions field, it complicates `types` field resolution a lot. | ||
// for now skip it, but further improvements are tracked at | ||
// https://github.com/bluwy/publint/issues/42 | ||
if (getPublishedField(rootPkg, 'typesVersions')[0]) { | ||
knownFields.splice(0, 1) | ||
} | ||
for (const field of knownFields) { | ||
@@ -473,8 +479,25 @@ const [fieldValue, fieldPkgPath] = getPublishedField(rootPkg, field) | ||
if ('types' in exports && exportsKeys[0] !== 'types') { | ||
messages.push({ | ||
code: 'EXPORTS_TYPES_SHOULD_BE_FIRST', | ||
args: {}, | ||
path: currentPath.concat('types'), | ||
type: 'error' | ||
}) | ||
// check preceding conditions before the `types` condition, if there are nested | ||
// conditions, check if they also have the `types` condition. If they do, there's | ||
// a good chance those take precendence over this non-first `types` condition, which | ||
// is fine and is usually used as fallback instead. | ||
const precedingKeys = exportsKeys.slice(0, exportsKeys.indexOf('types')) | ||
let isPrecededByNestedTypesCondition = false | ||
for (const key of precedingKeys) { | ||
if ( | ||
typeof exports[key] === 'object' && | ||
objectHasKeyNested(exports[key], 'types') | ||
) { | ||
isPrecededByNestedTypesCondition = true | ||
break | ||
} | ||
} | ||
if (!isPrecededByNestedTypesCondition) { | ||
messages.push({ | ||
code: 'EXPORTS_TYPES_SHOULD_BE_FIRST', | ||
args: {}, | ||
path: currentPath.concat('types'), | ||
type: 'error' | ||
}) | ||
} | ||
} | ||
@@ -481,0 +504,0 @@ |
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
46584
1247