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

@diesdasdigital/csslint

v5.0.1

Published

Linter for our CSS architecture

Downloads

11

Readme

csslint npm badge

Linter for diesdas’ CSS architecture.

Why this architecture/a linter?

Most CSS bugs are caused by classes unintentionally overriding other classes. When building websites/interfaces with components this can happen for example if component styles are overwritten by a parent component. The component looks different because of where it’s placed (its context).

In any software system relying on context creates complexity. If one needs to know what the context of a specific piece of code is, one also has to understand all of that context.

CSS in JS tools solve that problem by using inline styles and/or generating class names automatically during a build step. This way developers cannot unintentionally override other components classes, because they don’t even know what the class name will be.

The downsides of CSS in JS solutions are:

  • one needs a build step to generate CSS
  • some tools require writing CSS in a non-standard way (as objects for example)
  • while debugging class names have no meaningful names anymore

Therefore we came up with a CSS architecture which has one major and a few minor rules to get the same benefit of local reasoning for components without the drawbacks of CSS in JS tools.

Rules it checks:

  • [x] every class name is prefixed by the component/file name
  • [x] also animation names should start with the component name, eg @keyframes component__my-animation
  • [x] no multiple nesting in class names, eg .component__one__two is ill-formed
  • [x] no type selectors
  • [x] no id selectors

Advantages

1️⃣ Generic knowledge

CSS syntax is a standard. Learn it once.

2️⃣ Meaningful class names

Even in production we have meaningful class names which helps when we need to debug.

3️⃣ No build step

Every browser knows how to load CSS.

Screenshot of error messages

Installation

To add it to your project use npm or yarn:

yarn add @diesdasdigital/csslint --dev
npm install @diesdasdigital/csslint --save-dev

Then you can use the linter via npx or in package.json scripts:

{
  "scripts": {
    "lint": "csslint 'src/**/*.css' --all"
  }
}

Flags

--all

doesn’t stop on the first invalid file and shows a summary of how many errors it found

--verbose

also logs all valid files it has checked

Ignoring errors

In your projects root folder, create .csslintignore file, which includes new line separate file paths which should be ignored.

Alternatively you can ignore a single line inside of a file by writing the following comment in the previous line:

/* csslint-disable-next-line */

Collaboration

If you want to create PR, we test and develop this tool using these as a baseline:

License

MIT


Created by diesdas.digital