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

gulp-stylelint-esm

v3.0.0

Published

Gulp plugin for stylelint with ES module support.

Downloads

918

Readme

Gulp Stylelint

NPM version GitHub package.json version license Depfu Status Renovate enabled GitHub Workflow Status

This package is pure ESM. Please read this.

A Gulp plugin that runs stylelint results through a list of reporters with ESM support.

Installation

[!NOTE] REQUIREMENTS: Supports gulp v4 and v5, stylelint > 16 and node >= 18.12.0.

# YARN
yarn add stylelint gulp-stylelint-esm -D
# NPM
npm install stylelint gulp-stylelint-esm --save-dev

Quick start

Once you have configured stylelint, start with the following code. You will find additional configuration options below.

import { src } from 'gulp';
import gStylelintEsm from 'gulp-stylelint-esm';

function lintCssTask() {
  return src('src/**/*.css')
    .pipe(gStylelintEsm());
}

Formatters

Below is the list of currently available stylelint formatters. Some of them are bundled with stylelint by default and exposed on gStylelintEsm.formatters object. Others need to be installed. You can write a custom formatter to tailor the reporting to your needs.

Formatters bundled with stylelint: "compact", "github", "json", "string", "tap", "unix", "verbose".

The plugin comes with a built-in formatter called "stylish", which is set as the default.

Options

gulp-stylelint-esm supports all stylelint and Node.js API options except:

  • files, code will be provided by gulp instead
  • formatter, formatters are defined in the reporters option
  • cache, gulp caching should be used instead

and accepts a custom set of options listed below:

import { src } from 'gulp';
import gStylelintEsm from 'gulp-stylelint-esm';
import { myStylelintFormatter } from 'my-stylelint-formatter';

function lintCssTask() {
  return src('src/**/*.css')
    .pipe(gStylelintEsm({
      failAfterError: true, // true (default) | false
      fix: false,           // false (default) | true
      reporters: [
        { formatter: 'stylish', console: true }, // default
        { formatter: 'json', save: 'report.json' },
        { formatter: myStylelintFormatter, save: 'my-custom-report.txt' }
      ],
      debug: false          // false (default) | true
    }));
}

failAfterError

When set to true, the process will end with non-zero error code if any error-level warnings were raised. Files are pushed back to the their pipes only if there are no errors. Defaults to true.

fix

The fix: true (autofix) option instructs stylelint to try to fix as many issues as possible. Defaults to false.

NOTE:

  • fixed files will automatically overwrite the original files; proceed with caution.
  • the fixes are applied to the gulp stream only if there are no errors, to allow usage of other plugins.
  • not all stylelint rules can be automatically fixed, so it's advisable to manually resolve errors.
import { src, dest } from 'gulp';
import gStylelintEsm from 'gulp-stylelint-esm';

function fixCssTask() {
  return src('src/**/*.css')
    .pipe(gStylelintEsm({
      fix: true
    }))
    .pipe(dest('src'));
}

reporters

List of reporter configuration objects (see below). Defaults to:

reporters: [
  { formatter: 'stylish', console: true }
]
{
  // stylelint results formatter (required):
  // - pass a built-in formatter
  // - pass a function for imported, custom or exposed formatters
  // - pass a string for formatters bundled with stylelint
  //   "stylish (default)", "string", "compact", "github", "json", "tap", "unix", "verbose"
  formatter: stylish,

  // log the formatted result to console (optional):
  console: true

  // save the formatted result to a file (optional):
  save: 'text-report.txt',
}

debug

When set to true, the error handler will print an error stack trace. Defaults to false.

License

See the LICENSE file for license rights and limitations (MIT).