All Projects → subsetcss → Linter

subsetcss / Linter

Linting your CSS to limit yourself to a defined subset of values.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Linter

Typescript Guidelines
The TypeScript Guidebook
Stars: ✭ 104 (+4%)
Mutual labels:  lint, styleguide
Ue4 Style Guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,656 (+2556%)
Mutual labels:  lint, styleguide
ue5-style-guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,892 (+2792%)
Mutual labels:  lint, styleguide
Elemental components
Simple view components for Rails 5.1+
Stars: ✭ 68 (-32%)
Mutual labels:  styleguide
Swift
Airbnb's Swift Style Guide.
Stars: ✭ 1,165 (+1065%)
Mutual labels:  styleguide
Node Developer Boilerplate
🍭 Boilerplate for ES6+ Node.js and npm Developer
Stars: ✭ 82 (-18%)
Mutual labels:  lint
Ruby Saddler
Stars: ✭ 93 (-7%)
Mutual labels:  lint
Snacks
The Instacart Component Library
Stars: ✭ 65 (-35%)
Mutual labels:  styleguide
Pulse Boilerplate
React based boilerplate for creating scalable and well documented Design Systems. Live demo https://pulse.heartbeat.ua
Stars: ✭ 92 (-8%)
Mutual labels:  styleguide
Pytorch Project Template
Deep Learning project template for PyTorch (Distributed Learning is supported)
Stars: ✭ 76 (-24%)
Mutual labels:  lint
Mutest
fork of mutant with inline disable comments and a few different mutations.
Stars: ✭ 75 (-25%)
Mutual labels:  lint
Ocaml Style
A style guide for OCaml
Stars: ✭ 70 (-30%)
Mutual labels:  styleguide
Commit Message Lint
Github app to validate commit message on a pull request
Stars: ✭ 87 (-13%)
Mutual labels:  lint
Awesome Design Language System
list of awesome resources about digital design system.
Stars: ✭ 69 (-31%)
Mutual labels:  styleguide
Lint Diff
💅 Run eslint only in the changed parts of the code
Stars: ✭ 92 (-8%)
Mutual labels:  lint
Version Checker Gradle Lint
Warning on new versions available even when using Kotlin-DSL plugin.
Stars: ✭ 68 (-32%)
Mutual labels:  lint
Official Bash Logo
Everything you need to start using the official GNU Bash logo
Stars: ✭ 89 (-11%)
Mutual labels:  styleguide
Stylelint
A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
Stars: ✭ 9,350 (+9250%)
Mutual labels:  lint
Frontnote
Node.jsを使ったスタイルガイドジェネレーター
Stars: ✭ 73 (-27%)
Mutual labels:  styleguide
Kit
Tools for developing, documenting, and testing React component libraries
Stars: ✭ 1,201 (+1101%)
Mutual labels:  styleguide

subsetcss

Linting your CSS to limit yourself to a defined subset of values.

CSS can get unweildy sometimes, as new features are added and new people join the team. It's hard to be consistent, and that's why utility/functional CSS libraries like Tailwind are growing in popularity. SubsetCSS helps aleviate this problem by enforcing your CSS to a predefined amount of values, keeping everyone on the same page as a project evolves.

Note: in development

Example Output

Install

yarn add -D subsetcss stylelint

Setup

Add a stylelint.config.js file with the following config:

let config = require('./.subsetcss');

module.exports = {
  plugins: ['subsetcss'],
  rules: {
    'subsetcss/config': [true, config],
  },
};

Create a .subsetcss.js file with content like:

module.exports = {
  subsets: {
    'font-size': [
      '.75rem', // 12px
      '.875rem', // 14px
      '1rem', // 16px
      '1.125rem', // 18px
      '1.25rem', // 20px
      '1.5rem', // 24px
      '1.875rem', // 30px
      '2.25rem', // 36px
      '3rem', // 48px
    ],
    'border-width': (key, value) => ['0', '1px', '2px', '3px'],
    'border-color': [
      'transparent',
      '#22292f',
      '#3d4852',
      '#606f7b',
      '#8795a1',
      '#b8c2cc',
    ],
    'border-style': ['solid'],
  },
  '@media': [
    {
      // optional
      type: 'print',
      // optional
      params: {
        'max-width': ['400px', '768px'],
      },
      subsets: {
        'font-size': [
          '1rem', // 16px
          '1.125rem', // 18px
          '1.25rem', // 20px
          '1.5rem', // 24px
          '1.875rem', // 30px
        ],
      },
    },
  ],
};

Here's an example config based on TailwindCSS styles https://gist.github.com/knownasilya/0ceb5fe6c02d558f2e908516dc1551bd

Run

You can run with yarn stylelint "src/styles/*.css". Feel free to add to your npm scripts or setup with any intermediate tools.

Tips

Using variables in your subsets

  • css variables: 'font-color': ['var(--text-color, black)']
  • sass variables: 'font-color': ['$text-color']
  • less variables: 'font-color': ['@text-color']

Generate a modular scale

Use https://polished.js.org/docs/#modularscale or something similar.

'font-size': Array.from({ length: 5 }, (_v, index) => polished.modularScale(index)),

First value is the step, second the starting value (defaults to '1em') and third is the modular scale, which can be one of the values defined here: https://polished.js.org/docs/#modularscaleratio

You can preview modular scales here: https://www.modularscale.com/

Generate custom color combinations

Use https://github.com/TypeCtrl/tinycolor#color-combinations or something similar.

const colors = new TinyColor('#f00').polyad(4);
// later
'color': colors.map(t => t.toHexString())

Helper Functions

Have a look at https://github.com/subsetcss/config-helpers for official helper functions to help build out your config.

Contributing

See the Contributing guide.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].