All Projects → atfzl → Eslint Plugin Css Modules

atfzl / Eslint Plugin Css Modules

Project status: NOT MAINTAINED; Checks that you are using the existent css/scss classes, no more no less

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Eslint Plugin Css Modules

React Redux Saga Starter
Basic, Opinionated starter kit for React+Redux+Redux Saga with support for SCSS CSS Modules, Storybook, JEST testing, and ESLint
Stars: ✭ 12 (-89.57%)
Mutual labels:  eslint, scss, css-modules
Eslint Plugin Vue I18n
🌐 ESLint plugin for Vue I18n
Stars: ✭ 50 (-56.52%)
Mutual labels:  eslint, eslint-plugin
Html Sass Babel Webpack Boilerplate
Webpack 4 + Babel + ES6 + SASS + HTML Modules + Livereload
Stars: ✭ 35 (-69.57%)
Mutual labels:  eslint, scss
Eslint Plugin Monorepo
ESLint Plugin for monorepos
Stars: ✭ 56 (-51.3%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Node
Additional ESLint's rules for Node.js
Stars: ✭ 740 (+543.48%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin
ESLint configurations and additional rules for me
Stars: ✭ 19 (-83.48%)
Mutual labels:  eslint, eslint-plugin
Generator Dhboilerplate
Boilerplate made by David Hellmann
Stars: ✭ 54 (-53.04%)
Mutual labels:  eslint, scss
React Typescript Web Extension Starter
🖥 A Web Extension starter kit built with React, TypeScript, SCSS, Storybook, Jest, EsLint, Prettier, Webpack and Bootstrap. Supports Google Chrome + Mozilla Firefox + Brave Browser 🔥
Stars: ✭ 510 (+343.48%)
Mutual labels:  eslint, scss
Sowing Machine
🌱A React UI toolchain & JSX alternative
Stars: ✭ 64 (-44.35%)
Mutual labels:  eslint, eslint-plugin
Pwa Boilerplate
✨ PWA Boilerplate is highly scalable and is designed to help you kick-start your next project 🔭.
Stars: ✭ 82 (-28.7%)
Mutual labels:  scss, css-modules
Eslint Mdx
ESLint Parser/Plugin for MDX
Stars: ✭ 89 (-22.61%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Jest
ESLint plugin for Jest
Stars: ✭ 699 (+507.83%)
Mutual labels:  eslint, eslint-plugin
React Ssr Setup
React Starter Project with Webpack 4, Babel 7, TypeScript, CSS Modules, Server Side Rendering, i18n and some more niceties
Stars: ✭ 678 (+489.57%)
Mutual labels:  eslint, css-modules
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (-12.17%)
Mutual labels:  eslint, eslint-plugin
Xo
❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaults
Stars: ✭ 6,277 (+5358.26%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Lwc
Official ESLint rules for LWC
Stars: ✭ 51 (-55.65%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Sonarjs
SonarJS rules for ESLint
Stars: ✭ 458 (+298.26%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Simple Import Sort
Easy autofixable import sorting.
Stars: ✭ 493 (+328.7%)
Mutual labels:  eslint, eslint-plugin
Next React Graphql Apollo boostrap
React + GraphQL + Next.js project architecture that I play with right now
Stars: ✭ 59 (-48.7%)
Mutual labels:  eslint, scss
Typescript Eslint
✨ Monorepo for all the tooling which enables ESLint to support TypeScript
Stars: ✭ 10,831 (+9318.26%)
Mutual labels:  eslint, eslint-plugin

status: NOT MAINTAINED

I have moved on to using css-in-js libraries like styled-components and emotion. So, not working on this project.

eslint-plugin-css-modules

Build Status

This plugin intends to help you in tracking down problems when you are using css-modules. It tells if you are using a non-existent css/scss/less class in js or if you forgot to use some classes which you declared in css/scss/less.

Rules

  • css-modules/no-unused-class: You must use all the classes defined in css/scss/less file.

If you still want to mark a class as used, then use this comment on top of your file

/* eslint css-modules/no-unused-class: [2, { markAsUsed: ['container'] }] */

where container is the css class that you want to mark as used. Add all such classes in the array.

If you use the camelCase option of css-loader, you must also enabled it for this plugin

/* eslint css-modules/no-unused-class: [2, { camelCase: true }] */
  • css-modules/no-undef-class: You must not use a non existing class, or a property that hasn't been exported using the :export keyword.

If you use the camelCase option of css-loader, you must also enabled it for this plugin

/* eslint css-modules/no-undef-class: [2, { camelCase: true }] */

Installation

npm i --save-dev eslint-plugin-css-modules

Usage:

.eslintrc

{
  "plugins": [
    "css-modules"
  ],
  "extends": [
    "plugin:css-modules/recommended"
  ]
}

You may also tweak the rules individually. For instance, if you use the camelCase option of webpack's css-loader:

{
  "plugins": [
    "css-modules"
  ],
  "extends": [
    "plugin:css-modules/recommended"
  ],
  "rules": {
    "css-modules/no-unused-class": [2, { "camelCase": true }],
    "css-modules/no-undef-class": [2, { "camelCase": true }]
  }
}

The camelCase option has 4 possible values, see css-loader#camelCase for description:

true | "dashes" | "only" | "dashes-only"

Specifying base path

You can specify path for the base directory via plugin settings in .eslintrc. This is used by the plugin to resolve absolute (S)CSS paths:

{
  "settings": {
    "css-modules": {
      "basePath": "app/scripts/..."
    }
  }
}

Screen Shot

ScreenShot

   1:8   error  Unused classes found: container  css-modules/no-unused-class
   5:17  error  Class 'containr' not found       css-modules/no-undef-class
  10:26  error  Class 'foo' not found            css-modules/no-undef-class

scss:

/* .head is global, will not be used in js */
:global(.head) {
  color: green;
}

.container {
  width: 116px;

  i {
    font-size: 2.2rem;
  }

  .button {
    padding: 7px 0 0 5px;
  }
}

.footer {
  color: cyan;
}
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].