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

@emmetio/config

v0.4.0

Published

Emmet config resolver

Downloads

997

Readme

Emmet config resolver

This module provides resolver for config that can be passed to Emmet abbreviation expander as options argument. The config may contain global, syntax- and project-specific preferences like output format or snippets and config resolver creates final options payload with proper preferences overrides.

Config format

Config is a JSON file that contains global, syntax- and projects specific preferences. Currently, Emmet distinct two types of abbreviations: markup (for languages like HTML, XML, Slim etc.) and stylesheet (CSS, SASS, Less etc.), each of them has different settings and usage semantics. In order to globally configure all markup and/or stylesheet abbreviations, use globals key with markup and stylesheet subkeys accordingly:

{
	"globals": {
		"markup": {
			"profile": {
				// Output all tags in uppercase
				"tagCase": "upper"
			},

			// Add custom snippets to all markup-based syntaxes
			"snippets": {
				"site-nav": "nav>ul.nav>li.nav-item"
			}
		},
		"stylesheet": {
			// Add custom snippets to all stylesheet-based syntaxes
			"snippets": {
				"black": "color: black"
			}
		}
	}
}

For available options, see types.d.ts file.

Sometimes you may want to add syntax-specific preferences. For example, you may want to customize SASS syntax with new snippets but don’t want to use them in CSS. In this case, you should use syntax key and a syntax name as a subkey:

{
	"syntax": {
		"sass": {
			// In syntax-specific config, `type` must be either "markup" or "stylesheet"
			"type": "stylesheet",
			"snippets": {
				"inc": "@include"
			}
		}
	}
}

Contents of syntax-specific config is the same as global config.

You may also want to configure Emmet specifically for a project. Use "project" top-level key with project ID as a subkey:

{
	"project": {
		"my-project1": {
			// Use `globals` and `syntax` sections as described above
			"globals": { ... },
			"syntax": { ... }
		}
	}
}

Resolver API

Config resolver is a function that takes JSON config and params that identify current context: abbreviation type, syntax and project.

import { expand } from '@emmetio/expand-abbreviation';
import resolveConfig from '@emmetio/config';

// Obtain config JSON somehow
const config = readFile('emmet-config.json');

// Identify current context
const params = {
	type: 'markup',
	syntax: 'html',
	project: 'my-project1'
};

const result = expand('ul>li', resolveConfig(config, params));

console.log(result);

Available context options:

  • type: type of abbreviation, either markup or stylesheet.
  • syntax: syntax name, a subkey of syntax section.
  • project: ID of project, a subkey of project section.

Config resolver will create a final options payload for abbreviation expander, depending on context params.