use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(super) enum Reason {
BarePackageOutsideWorkspace,
EsmExtensionRequired,
DirectoryImportNotAllowed,
ExportsSubpathNotMatched,
ImportsSpecifierNotMatched,
NoMatchingCondition,
BuildOutputWithoutSourceMapping,
DeclarationOnlyTarget,
TargetNotIndexed,
AmbiguousWorkspaceName,
ConfigurationRefused,
}
impl Reason {
pub fn as_str(self) -> &'static str {
match self {
Self::BarePackageOutsideWorkspace => "bare-package-outside-workspace",
Self::EsmExtensionRequired => "esm-extension-required",
Self::DirectoryImportNotAllowed => "directory-import-not-allowed",
Self::ExportsSubpathNotMatched => "exports-subpath-not-matched",
Self::ImportsSpecifierNotMatched => "imports-specifier-not-matched",
Self::NoMatchingCondition => "no-matching-condition",
Self::BuildOutputWithoutSourceMapping => "build-output-without-source-mapping",
Self::DeclarationOnlyTarget => "declaration-only-target",
Self::TargetNotIndexed => "target-not-indexed",
Self::AmbiguousWorkspaceName => "ambiguous-workspace-name",
Self::ConfigurationRefused => "configuration-refused",
}
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UnresolvedImport {
pub from_file: String,
pub from_line: usize,
pub target: String,
pub reason: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UnsupportedModeScope {
pub config: String,
pub mode: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RefusedConfigRecord {
pub file: String,
pub field: String,
}
pub(super) const REASONS: &[Reason] = &[
Reason::BarePackageOutsideWorkspace,
Reason::EsmExtensionRequired,
Reason::DirectoryImportNotAllowed,
Reason::ExportsSubpathNotMatched,
Reason::ImportsSpecifierNotMatched,
Reason::NoMatchingCondition,
Reason::BuildOutputWithoutSourceMapping,
Reason::DeclarationOnlyTarget,
Reason::TargetNotIndexed,
Reason::AmbiguousWorkspaceName,
Reason::ConfigurationRefused,
];