Skip to content

An ESLint rule which enforces ordering of object keys based on T-shirt sizes.

Notifications You must be signed in to change notification settings

Naoto-Ida/eslint-plugin-tshirt-sizes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-tshirt-sizes

An ESLint rule which enforces ordering of object keys based on T-shirt sizes. Useful for T-shirt size-based values for design systems, etc.

Supported keys

  • Keys which follow what I call "base sizes", meaning S, M, L.
  • Keys which prefix these base sizes with the character x.

Installation

yarn add -D eslint-plugin-tshirt-sizes

Usage

Add tshirt-sizes to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["tshirt-sizes"]
}

Since this plugin is intended for very specific use cases, it is best to set the rule via configuration comments for blocks where you define an object containing T-shirt sizes as keys.

/* eslint tshirt-sizes/tshirt-sizes: "error" */
const softDrinkSizes = {
  s: 1,
  l: 3, // ERR: Expected object keys to be in ascending T-shirt size order. 'l' should be before 'm'.
  m: 2,
};

Rule configuration

Order

asc (default)

/* eslint sort-keys: ["error"] */

desc

/ *eslint sort-keys: ["error", "desc"] */

Roadmap

  • Add support for numerical prefixes like 2xl, 3xs

About

An ESLint rule which enforces ordering of object keys based on T-shirt sizes.

Resources

Stars

Watchers

Forks

Packages

No packages published