npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sass-error

v2.0.1

Published

Sass utility functions for building error messages — per the Error Message Specification

Readme

sass-error

Sass utility functions for building error messages — per the Error Message Specification.


Message Format

As defined by the specification, every error message is a single structured string composed of a machine-readable code and a human-readable message.

[CODE] <EntityType> "<EntityName>" [@ <Path>]: <Issue> → <Action> [context: ...]

Example

[TOKEN_TIER_VALUE] Token "font-weight" @ settings > tier: Invalid value "random" → Allowed: primitive | semantic | component

Note: See the Error Message Specification for a step-by-step guide on how to construct error messages.


Installation

npm install sass-error sass-funcs

Requires sass or sass-embedded >= 1.33.0 — install one, not both (sass-embedded recommended). Also requires sass-funcs.


Configuration

All constants are configurable via @use ... with (...):

@use 'sass-error' as e with (
  $PATH_SEPARATOR: '/',
  $EXPECTED_LIMIT: 3,
  $EXPECTED_MORE_LABEL: 'plus'
);

| Variable | Default | Description | | ---------------------- | -------- | ------------------------------------------ | | $PATH_PREFIX | ' @ ' | Prefix before the path string | | $PATH_SEPARATOR | ' > ' | Separator between path segments | | $PATH_ID_PLACEHOLDER | '<id>' | Placeholder when the key itself is invalid | | $EXPECTED_LIMIT | 5 | Max values shown before truncating | | $EXPECTED_SEPARATOR | ' \| ' | Separator between values | | $EXPECTED_MORE_LABEL | 'more' | Label for the remaining count |


Module: Error

@use 'sass-error' as e;

| Function | Description | | --------------------------------------------------- | ---------------------------------------------- | | path | Builds a formatted path string from segments | | received | Renders a received value as a string | | expected | Formats expected values into a readable string |


e.path($path, $is-id-error, $separator)

Builds a formatted path string from path segments for use in error messages.

| Parameter | Type | Default | Description | | -------------- | ---------------- | ----------------- | ----------------------------------------------------- | | $path | List \| String | | Path segments, or a single value normalised to a list | | $is-id-error | Bool | false | Replaces the last segment with <id> when true | | $separator | String | $PATH_SEPARATOR | Separator placed between path segments |

Returns String — path string prefixed with $PATH_PREFIX, or '' if path is empty.

e.path(('settings', 'tier'))           // → ' @ settings > tier'
e.path(('values', 'core', ''), true)   // → ' @ values > core > <id>'
e.path(())                             // → ''

e.received($value, $quote-empty)

Renders a received value as a string for use in error messages.

| Parameter | Type | Default | Description | | -------------- | ------ | ------- | ----------------------------------------------------------------- | | $value | * | | Value to render | | $quote-empty | Bool | false | Wraps empty or whitespace-only strings in double quotes when true |

Returns String — strings returned as-is, non-empty lists wrapped in parens, all others inspected.

e.received('hello')      // → 'hello'
e.received(42)           // → '42'
e.received((a, b, c))    // → '(a, b, c)'
e.received('', true)     // → '""'

e.expected($items, $extra, $limit, $separator)

Formats a list of expected values into a readable string for error messages.

| Parameter | Type | Default | Description | | ------------ | --------------------------------------------------- | --------------------- | -------------------------------------------------------- | | $items | List \| String | | Expected values; normalised to a list if a single value | | $extra | String \| Number \| Bool \| Color \| List \| Null | null | Additional value(s) appended after the main list | | $limit | Number \| Null | $EXPECTED_LIMIT | Max items shown before truncating with a remaining count | | $separator | String | $EXPECTED_SEPARATOR | Separator placed between values |

Returns String — joined expected string, truncated to $limit items if the count is exceeded.

e.expected(('foo', 'bar', 'baz'))                       // → 'foo | bar | baz'
e.expected(('a', 'b', 'c', 'd', 'e', 'f'), $limit: 3)   // → 'a | b | c | ... 3 more'
e.expected(('foo', 'bar'), $extra: 'baz')               // → 'foo | bar | baz'

Migration

v1 → v2

  • print() renamed to received()
  • options() renamed to expected()
  • $ERROR_LABEL_ENTRY, $ERROR_LABEL_FIELD, $ERROR_ENTRY_LABELS removed — moved to sass-valid

Back to top