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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sass-render-errors

v2.0.3

Published

Get Sass render errors and deprecations.

Downloads

4,676

Readme

sass-render-errors

Build Status

Get Sass render errors and deprecations.

Currently there’s no Sass API which reports errors and deprecations in machine readable format (e.g. JSON-like data). This module parses Sass render output and provides render information for easier usage in linters and similar tools.

Undefined functions

Sass currently doesn’t check for undefined functions. This module has additional renderer which tries to guess which functions are undefined by comparing list of known CSS functions with functions defined in file.

This renderer is available as named export undefinedFunctions.

Install

npm install sass-render-errors --save

Usage

import createRenderer from 'sass-render-errors';
import sass from 'sass';

(async () => {
	const renderer = createRenderer(sass);
	const result = await renderer.compile('./index.scss');
	console.log(result);
	/* [
		{
			type: 'deprecation',
			file: '<absolute path>/index.scss',
			message: 'Passing a number (1) to color.invert() is deprecated. Recommendation: invert(1).',
			stack: [
				'at root stylesheet (index.scss:4:24)'
			],
			source: {
				start: {
					column: 9,
					line: 4
				},
				end: {
					column: 24,
					line: 4
				},
				pattern: 'color.invert(1)'
			}
		}
	] */
})();

index.scss

@use 'sass:color';

.becky {
	color: color.invert(1);
}

API

sassRenderErrors(sass[, options])

Creates Sass renderer. All methods return Promise, but internally use original Sass compile methods.

sass

Sass module reference. Only Dart Sass is supported.

Sass is injected as dependancy because each version has different set of errors and deprecations and you should get results for Sass version your application uses.

options

Type: object

For undefined functions:

| Property | Type | Description | | ----------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------- | | disallowedKnownCssFunctions | string[] | List of disallowed known CSS functions. | | additionalKnownCssFunctions | string[] | List of additional known CSS functions (e.g. v-bind for Vue SFC). |

renderer[compile|compileAsync|compileString|compileStringAsync]([options])

Returns: Promise<SassRenderError[]>

Promise with array of errors and deprecations.

If input contains multiple errors, only first one is shown. If you’re using undefined function renderer, all errors are always visible.

All deprecations are always visible.

Each array entry is object which contains following properties:

| Property | Type | Description | | --------------------- | ---------- | ----------------------------------------------------------- | | file | string | Absolute path to file or stdin with error or deprecation. | | message | string | Error or deprecation message. | | stack | string[] | Stack trace of error or deprecation. | | source.start.column | number | Pattern start column. | | source.start.line | number | Pattern start line. | | source.end.column | number | Pattern end column. | | source.end.line | number | Pattern end line. | | source.pattern | string | Error or deprecation code or pattern of code. | | type | string | Can be either error or deprecation. |

options

Type: sass.Options|sass.StringOptions

compile and compileAsync methods take sass.Options.
compileString and compileStringAsync methods take sass.StringOptions.

License

MIT © Ivan Nikolić