Documentation
¶
Overview ¶
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2025 Benny Powers <web@bennypowers.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- func GetSchema(version string) ([]byte, error)
- func PrintValidationResult(manifestPath string, result *ValidationResult, options DisplayOptions) error
- type Context
- type DisplayOptions
- type ErrorIDRegistry
- type ErrorProcessor
- type GroupedIssues
- type GroupedWarnings
- type ImplementationDetailsRule
- type InternalMethodsRule
- type LifecycleMethodsRule
- type ManifestNavigator
- func (n *ManifestNavigator) BuildContextualNames(ctx Context) (module, declaration, member, property string)
- func (n *ManifestNavigator) DeclMemberAtIndex(moduleIndex, declIndex, memberIndex int) (RawMember, bool)
- func (n *ManifestNavigator) DeclPropertyAtIndex(moduleIndex, declIndex, propIndex int, propType string) (RawProperty, bool)
- func (n *ManifestNavigator) ModuleAtIndex(index int) (RawModule, bool)
- func (n *ManifestNavigator) ModuleDeclarationAtIndex(moduleIndex, declIndex int) (RawDeclaration, bool)
- type PrivateMethodsRule
- type RawDeclaration
- func (d RawDeclaration) Attributes() ([]RawProperty, bool)
- func (d RawDeclaration) CSSParts() ([]RawProperty, bool)
- func (d RawDeclaration) CSSProperties() ([]RawProperty, bool)
- func (d RawDeclaration) CSSStates() ([]RawProperty, bool)
- func (d RawDeclaration) Demos() ([]RawDemo, bool)
- func (d RawDeclaration) Description() string
- func (d RawDeclaration) Events() ([]RawProperty, bool)
- func (d RawDeclaration) IsCustomElement() bool
- func (d RawDeclaration) Kind() string
- func (d RawDeclaration) Members() ([]RawMember, bool)
- func (d RawDeclaration) Name() string
- func (d RawDeclaration) Slots() ([]RawProperty, bool)
- func (d RawDeclaration) Summary() string
- func (d RawDeclaration) Superclass() (RawSuperclass, bool)
- func (d RawDeclaration) TagName() string
- type RawDemo
- type RawManifest
- type RawMember
- type RawModule
- type RawProperty
- type RawSuperclass
- type SuperclassRule
- type ValidationError
- type ValidationOptions
- type ValidationPipeline
- type ValidationResult
- type ValidationWarning
- type VerboseDefaultsRule
- type WarningContext
- type WarningProcessor
- type WarningRule
Constants ¶
const DefaultLengthThreshold = 200
Default value length threshold for warnings (applies to all default values)
Variables ¶
This section is empty.
Functions ¶
func GetSchema ¶ added in v0.5.0
GetSchema returns the JSON schema for a given version, using embedded schemas and falling back to fetching from external sources if needed
func PrintValidationResult ¶
func PrintValidationResult(manifestPath string, result *ValidationResult, options DisplayOptions) error
PrintValidationResult prints the validation result with appropriate formatting
Types ¶
type Context ¶
type Context struct {
Type string // "module", "declaration", "member", "property"
ModuleIndex int
DeclIndex int
MemberIndex int
PropertyIndex int
PropertyType string // "attributes", "events", etc.
}
Context represents the parsing context for validation issues
func ParseContext ¶
ParseContext extracts context information from a JSON path
type DisplayOptions ¶
type ErrorIDRegistry ¶
type ErrorIDRegistry struct {
// contains filtered or unexported fields
}
ErrorIDRegistry provides centralized error ID assignment
func NewErrorIDRegistry ¶
func NewErrorIDRegistry() *ErrorIDRegistry
NewErrorIDRegistry creates a new error ID registry
func (*ErrorIDRegistry) AssignID ¶
func (r *ErrorIDRegistry) AssignID(message, location string) string
AssignID assigns an appropriate error ID based on the message and location
type ErrorProcessor ¶
type ErrorProcessor struct {
// contains filtered or unexported fields
}
ErrorProcessor handles the parsing and processing of validation errors
func NewErrorProcessor ¶
func NewErrorProcessor(navigator *ManifestNavigator) *ErrorProcessor
NewErrorProcessor creates a new error processor
func (*ErrorProcessor) ProcessValidationError ¶
func (p *ErrorProcessor) ProcessValidationError(cause *jsonschema.ValidationError, location string) ValidationError
ProcessValidationError processes a JSON schema validation error into structured errors
type GroupedIssues ¶
type GroupedIssues struct {
Module string
Declaration string
Issues []ValidationError
}
type GroupedWarnings ¶
type GroupedWarnings struct {
Module string
Declaration string
Warnings []ValidationWarning
}
type ImplementationDetailsRule ¶
type ImplementationDetailsRule struct{}
ImplementationDetailsRule checks for implementation details in public API
func (*ImplementationDetailsRule) Category ¶
func (r *ImplementationDetailsRule) Category() string
func (*ImplementationDetailsRule) Check ¶
func (r *ImplementationDetailsRule) Check(ctx *WarningContext) []ValidationWarning
func (*ImplementationDetailsRule) ID ¶
func (r *ImplementationDetailsRule) ID() string
type InternalMethodsRule ¶
type InternalMethodsRule struct{}
InternalMethodsRule checks for internal utility methods
func (*InternalMethodsRule) Category ¶
func (r *InternalMethodsRule) Category() string
func (*InternalMethodsRule) Check ¶
func (r *InternalMethodsRule) Check(ctx *WarningContext) []ValidationWarning
func (*InternalMethodsRule) ID ¶
func (r *InternalMethodsRule) ID() string
type LifecycleMethodsRule ¶
type LifecycleMethodsRule struct{}
LifecycleMethodsRule checks for documented lifecycle methods
func (*LifecycleMethodsRule) Category ¶
func (r *LifecycleMethodsRule) Category() string
func (*LifecycleMethodsRule) Check ¶
func (r *LifecycleMethodsRule) Check(ctx *WarningContext) []ValidationWarning
func (*LifecycleMethodsRule) ID ¶
func (r *LifecycleMethodsRule) ID() string
type ManifestNavigator ¶
type ManifestNavigator struct {
// contains filtered or unexported fields
}
ManifestNavigator provides type-safe navigation through manifest data
func NewManifestNavigator ¶
func NewManifestNavigator(manifest map[string]any) *ManifestNavigator
NewManifestNavigator creates a new navigator for the given manifest
func (*ManifestNavigator) BuildContextualNames ¶
func (n *ManifestNavigator) BuildContextualNames(ctx Context) (module, declaration, member, property string)
BuildContextualNames builds human-readable names for validation issues
func (*ManifestNavigator) DeclMemberAtIndex ¶ added in v0.2.16
func (n *ManifestNavigator) DeclMemberAtIndex(moduleIndex, declIndex, memberIndex int) (RawMember, bool)
DeclMemberAtIndex returns the member at the given indices
func (*ManifestNavigator) DeclPropertyAtIndex ¶ added in v0.2.16
func (n *ManifestNavigator) DeclPropertyAtIndex(moduleIndex, declIndex, propIndex int, propType string) (RawProperty, bool)
DeclPropertyAtIndex returns the property at the given indices for the specified property type
func (*ManifestNavigator) ModuleAtIndex ¶ added in v0.2.16
func (n *ManifestNavigator) ModuleAtIndex(index int) (RawModule, bool)
ModuleAtIndex returns the module at the given index
func (*ManifestNavigator) ModuleDeclarationAtIndex ¶ added in v0.2.16
func (n *ManifestNavigator) ModuleDeclarationAtIndex(moduleIndex, declIndex int) (RawDeclaration, bool)
ModuleDeclarationAtIndex returns the declaration at the given module and declaration indices
type PrivateMethodsRule ¶
type PrivateMethodsRule struct{}
PrivateMethodsRule checks for private methods
func (*PrivateMethodsRule) Category ¶
func (r *PrivateMethodsRule) Category() string
func (*PrivateMethodsRule) Check ¶
func (r *PrivateMethodsRule) Check(ctx *WarningContext) []ValidationWarning
func (*PrivateMethodsRule) ID ¶
func (r *PrivateMethodsRule) ID() string
type RawDeclaration ¶
func (RawDeclaration) Attributes ¶ added in v0.2.16
func (d RawDeclaration) Attributes() ([]RawProperty, bool)
func (RawDeclaration) CSSParts ¶ added in v0.2.16
func (d RawDeclaration) CSSParts() ([]RawProperty, bool)
func (RawDeclaration) CSSProperties ¶ added in v0.2.16
func (d RawDeclaration) CSSProperties() ([]RawProperty, bool)
func (RawDeclaration) CSSStates ¶ added in v0.2.16
func (d RawDeclaration) CSSStates() ([]RawProperty, bool)
func (RawDeclaration) Demos ¶ added in v0.9.5
func (d RawDeclaration) Demos() ([]RawDemo, bool)
func (RawDeclaration) Description ¶ added in v0.9.5
func (d RawDeclaration) Description() string
func (RawDeclaration) Events ¶ added in v0.2.16
func (d RawDeclaration) Events() ([]RawProperty, bool)
func (RawDeclaration) IsCustomElement ¶ added in v0.9.5
func (d RawDeclaration) IsCustomElement() bool
func (RawDeclaration) Kind ¶ added in v0.2.16
func (d RawDeclaration) Kind() string
func (RawDeclaration) Members ¶ added in v0.2.16
func (d RawDeclaration) Members() ([]RawMember, bool)
func (RawDeclaration) Name ¶ added in v0.2.16
func (d RawDeclaration) Name() string
func (RawDeclaration) Slots ¶ added in v0.2.16
func (d RawDeclaration) Slots() ([]RawProperty, bool)
func (RawDeclaration) Summary ¶ added in v0.9.5
func (d RawDeclaration) Summary() string
func (RawDeclaration) Superclass ¶ added in v0.2.16
func (d RawDeclaration) Superclass() (RawSuperclass, bool)
func (RawDeclaration) TagName ¶ added in v0.9.5
func (d RawDeclaration) TagName() string
type RawDemo ¶ added in v0.9.5
func (RawDemo) Description ¶ added in v0.9.5
type RawManifest ¶
Raw types represent the untyped JSON manifest data
func (RawManifest) Modules ¶ added in v0.2.16
func (m RawManifest) Modules() ([]RawModule, bool)
type RawMember ¶
func (RawMember) Description ¶ added in v0.9.5
type RawModule ¶
func (RawModule) Declarations ¶ added in v0.2.16
func (m RawModule) Declarations() ([]RawDeclaration, bool)
type RawProperty ¶
func (RawProperty) Default ¶ added in v0.2.16
func (p RawProperty) Default() string
func (RawProperty) Description ¶ added in v0.9.5
func (p RawProperty) Description() string
func (RawProperty) Name ¶ added in v0.2.16
func (p RawProperty) Name() string
func (RawProperty) Type ¶ added in v0.9.5
func (p RawProperty) Type() string
type RawSuperclass ¶
func (RawSuperclass) Module ¶ added in v0.2.16
func (s RawSuperclass) Module() string
func (RawSuperclass) Name ¶ added in v0.2.16
func (s RawSuperclass) Name() string
func (RawSuperclass) Package ¶ added in v0.9.1
func (s RawSuperclass) Package() string
type SuperclassRule ¶
type SuperclassRule struct{}
SuperclassRule checks for superclass attribution warnings
func (*SuperclassRule) Category ¶
func (r *SuperclassRule) Category() string
func (*SuperclassRule) Check ¶
func (r *SuperclassRule) Check(ctx *WarningContext) []ValidationWarning
func (*SuperclassRule) ID ¶
func (r *SuperclassRule) ID() string
type ValidationError ¶
type ValidationError struct {
ID string `json:"id"` // Unique identifier for this error type
Module string `json:"module,omitempty"`
Declaration string `json:"declaration,omitempty"`
Member string `json:"member,omitempty"`
Property string `json:"property,omitempty"`
Message string `json:"message"`
Location string `json:"location,omitempty"`
Index int `json:"index,omitempty"` // For array items
}
type ValidationOptions ¶
type ValidationPipeline ¶
type ValidationPipeline struct {
// contains filtered or unexported fields
}
ValidationPipeline orchestrates the validation process
func NewValidationPipeline ¶
func NewValidationPipeline(manifestData []byte) (*ValidationPipeline, error)
NewValidationPipeline creates a new validation pipeline
func (*ValidationPipeline) Validate ¶
func (p *ValidationPipeline) Validate(options ValidationOptions) (*ValidationResult, error)
Validate performs the complete validation process
type ValidationResult ¶
type ValidationResult struct {
IsValid bool `json:"valid"`
Path string `json:"path,omitempty"`
SchemaVersion string `json:"schemaVersion,omitempty"`
Errors []ValidationError `json:"errors"`
Warnings []ValidationWarning `json:"warnings"`
}
func Validate ¶
func Validate(manifestPath string, options ValidationOptions) (*ValidationResult, error)
Validate validates a custom-elements.json manifest
type ValidationWarning ¶
type ValidationWarning struct {
ID string `json:"id"` // Unique identifier for this warning rule
Module string `json:"module,omitempty"`
Declaration string `json:"declaration,omitempty"`
Member string `json:"member,omitempty"`
Property string `json:"property,omitempty"`
Message string `json:"message"`
Category string `json:"category"` // "lifecycle", "private", "verbose", etc.
}
type VerboseDefaultsRule ¶
type VerboseDefaultsRule struct{}
VerboseDefaultsRule checks for overly verbose default values in all property types
func (*VerboseDefaultsRule) Category ¶
func (r *VerboseDefaultsRule) Category() string
func (*VerboseDefaultsRule) Check ¶
func (r *VerboseDefaultsRule) Check(ctx *WarningContext) []ValidationWarning
func (*VerboseDefaultsRule) ID ¶
func (r *VerboseDefaultsRule) ID() string
type WarningContext ¶
type WarningContext struct {
Module RawModule
Declaration RawDeclaration
Member RawMember
Property RawProperty
ModulePath string
DeclName string
DeclKind string
IsLitElement bool
}
WarningContext provides context for warning rule evaluation
type WarningProcessor ¶
type WarningProcessor struct {
// contains filtered or unexported fields
}
WarningProcessor processes warnings using registered rules
func NewWarningProcessor ¶
func NewWarningProcessor() *WarningProcessor
NewWarningProcessor creates a new warning processor with default rules
func (*WarningProcessor) ProcessWarnings ¶
func (p *WarningProcessor) ProcessWarnings(navigator *ManifestNavigator) []ValidationWarning
ProcessWarnings processes all warnings for a manifest
func (*WarningProcessor) RegisterRule ¶
func (p *WarningProcessor) RegisterRule(rule WarningRule)
RegisterRule adds a warning rule to the processor
type WarningRule ¶
type WarningRule interface {
Check(ctx *WarningContext) []ValidationWarning
ID() string
Category() string
}
WarningRule interface for all warning rules