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

stylelint-custom-processor-loader-with-warnings

v0.3.1

Published

A Webpack loader for stylelint used with custom processors

Downloads

5

Readme

stylelint-custom-processor-loader

A Webpack loader for stylelint used with custom processors

npm-version CircleCI Greenkeeper

Video of loader in use

Motivation

I wrote this Webpack loader when I first encountered Styled Components and wanted to integrate my Styled Components Stylelint linting (using the stylelint-processor-styled-components processor) into my Webpack setup so I could have it show up in my Hot Reloading (as shown in the gif above) etc. The loader I found was stylelint-loader though, and it had been deprecated and was referring to postcss-loader and another loader that both didn't work for javascript, but only css files, and therefore not Styled Components. Actually the deprecated loader itself supports custom processors for Stylelint, but due to it no longer being under development, and also the fact that when I looked at the code I disagreed with quite a few of the choices, I decided to write my own webpack loader for this use case.

When should I use this loader?

If you just want to use normal Stylelint I would definitely suggest using the postcss-loader instead of this package. This package was mainly written for Styled Components but also aims to support any other custom processor of Stylelint such as stylelint-processor-markdown and stylelint-processor-html.

Installation

First install the loader with your favourite package manager

yarn add -D stylelint-custom-processor-loader

Or with npm

npm i -D stylelint-custom-processor-loader

Stylelint Config

Stylelint config can be added as a file in the default way as seen in Stylelint's documentation. The recommended way is creating a .stylelintrc file in the root of your project, but if you want to use a custom file path you can also use the configPath option.

Webpack Config

This package currently only aims at supporting Webpack 2+.

If you are for example using Styled Components you could simply add the following to your webpack config:

modules: {
  rules: [
    {
      test: /\.jsx?/,
      loader: 'stylelint-custom-processor-loader',
      exclude: /node_modules/,
    },
  ],
}

And you should now have linting your Styled Components css integrated with Webpack!

NOTE: You would of course have to install and use stylelint-processor-styled-components as your custom processor in this example.

Webpack Babel Example

modules: {
  rules: [
    {
      test: /\.jsx?/,
      use: [
        'babel-loader',
        'stylelint-custom-processor-loader',
      ],
      exclude: /node_modules/,
    },
  ],
}

NOTE: As always with Webpack loaders order can be very important, in general this loader should always be the first one loaded (which means the last one in the list) as seen above in the babel-loader example.

Options

configPath

Give the path to a non-default named Stylelint config. The recommended way to specify it is in your Webpack config as follows:

modules: {
  rules: [
    {
      test: /\.jsx?/,
      use: [
        'babel-loader',
        {
          loader: 'stylelint-custom-processor-loader',
          options: {
            configPath: './path/to/stylelint/config',
          },
        },
      ],
      exclude: /node_modules/,
    },
  ],
}

License

Licensed under the MIT License, Copyright © 2017 Emil Goldsmith Olesen. See LICENSE for more information.

Thank you to MoOx for his eslint-loader which was often referenced and used for inspiration during development of this project.