Installations
npm install eslint-plugin-postcss-modules
Developer Guide
Typescript
Yes
Module System
CommonJS
Score
64.4
Supply Chain
93
Quality
73.4
Maintenance
100
Vulnerability
98.9
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (96.5%)
JavaScript (2.81%)
CSS (0.69%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
bmatcuk
Download Statistics
Total Downloads
1,271,497
Last Day
322
Last Week
25,705
Last Month
84,207
Last Year
411,247
GitHub Statistics
MIT License
21 Stars
22 Commits
7 Forks
2 Watchers
15 Branches
3 Contributors
Updated on Feb 14, 2024
Package Meta Information
Latest Version
2.0.0
Package Id
eslint-plugin-postcss-modules@2.0.0
Unpacked Size
38.18 kB
Size
10.08 kB
File Count
34
Total Downloads
Cumulative downloads
Total Downloads
1,271,497
Last Day
34.7%
322
Compared to previous day
Last Week
69.2%
25,705
Compared to previous week
Last Month
167.1%
84,207
Compared to previous month
Last Year
53.6%
411,247
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
10
Peer Dependencies
1
Dev Dependencies
27
eslint-plugin-postcss-modules
Like eslint-plugin-css-modules, this plugin helps you lint your css modules. It adds a new eslint rule that detects if you are trying to use a class that is not exported by your css module.
The major difference between this plugin and the aforementioned plugin is that this plugin uses postcss to parse the css files and determine what classes are exported. There are a couple of benefits to this:
- Under the hood, css-loader is also using postcss with a few plugins to determine which classes are exported. This plugin uses the same group of plugins to guarantee that the classes that are linted are the same as the classes css-loader exports.
- Through plugins, postcss can handle a variety of complex input css files. While eslint-plugin-css-modules has excellent support for most major css grammars (such as sass), it does not support all of the inputs that postcss can handle and probably never will. If you are using postcss for your project, chances are good that eslint-plugin-css-modules will choke on your files.
The downside is that, while postcss is very battle-tested and fast for building css, it may be slower than eslint-plugin-css-modules for linting purposes. I don't have benchmarks, but welcome them.
Installation
1yarn add -D eslint-plugin-postcss-modules 2npm install -D eslint-plugin-postcss-modules
Usage
In your eslint config:
1{ 2 "extends": [ 3 "plugin:postcss-modules/recommended" 4 ], 5}
The recommended configuration will set no-undef-class
to errors and
no-unused-class
to warnings. The recommended configuration is equivalent to:
1{ 2 "plugins": ["postcss-modules"], 3 "rules": { 4 "postcss-modules/no-undef-class": "error", 5 "postcss-modules/no-unused-class": "warn" 6 } 7}
Settings
There are a couple settings you can tweak in your eslint config. Below are examples of the options and their default values:
1{ 2 "settings": { 3 "postcss-modules": { 4 "postcssConfigDir": "cwd", 5 "baseDir": "cwd", 6 "camelCase": false, 7 "defaultScope": "local", 8 "include": "**/*.css", 9 "exclude": "**/node_modules/**/*" 10 } 11 } 12}
-
postcssConfigDir (default: cwd)
postcssConfigDir sets the starting point to search for the postcss config file, as determined by postcss-load-config. Searching will start with this directory and work its way up recursively until it finds a config file or hits your home directory. See cosmiconfig for more info.
I recommend that you create a pared down version of your postcss config that only includes plugins that could affect the structure of the file and the class names that might be exported in order to reduce the amount of time linting takes. For example, postcss-preset-env is really a collection of plugins under the hood. The only plugins that affect the structure and classes that would be exported are probably postcss-custom-selectors and postcss-nesting.
-
baseDir (default: cwd)
baseDir is used to resolve imports to your css files. If the import is relative (ie, starts with
./
), the path of the current file will be used to resolve the import. However, if the import is not relative, this baseDir will be used to resolve the path. -
camelCase (default:
false
)The camelCase option should match the camelCase option or localsConvention option that you have set for css-loader, depending on which version you are using. Here's a description of the options and what they do:
option description false
or"asIs"
Do not camelCase exported classes true
or"camelCase"
Export both the original class name and the camelCased version "camelCaseOnly"
or"only"
Export only the camelCased class names "dashes"
Convert dashed-names to camelCase and export both "dashesOnly"
Convert dashed-names to camelCase and only export the camelCased version -
defaultScope (default:
"local"
)The defaultScope option determines scope (global or local) of any css classes which are not explicitly declared as being global or local using
:global
or:local
. The default is"local"
. -
include (default:
"**/*.css"
)An anymatch matcher to determine what files should be parsed for css-module exports. Any file which matches include but does not match exclude will be parsed. Note that due to the way eslint combines settings, you cannot use a regex here.
-
exclude (default:
"**/node_modules/**/*"
)An anymatch matcher to determine what files should not be parsed for css-module exports. Any file which matches include but does not match exclude will be parsed. Note that due to the way eslint combines settings, you cannot use a regex here.

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 2/20 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 4 are checked with a SAST tool
Reason
34 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
1.9
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to eslint-plugin-postcss-modules
@taktikorg/unde-animi-omnis
<p align="center"> <a href="https://www.npmjs.com/package/@taktikorg/unde-animi-omnis"><img src="https://img.shields.io/npm/v/@taktikorg/unde-animi-omnis"></a> <a href=""><img src="https://img.shields.io/github/actions/workflow/status/RemiMyrset/@taktikor
@teamteanpm2024/pariatur-fugit-atque
<img align="right" width="135" height="95" src="http://postcss.github.io/postcss/logo-leftp.png" title="Philosopher’s stone, logo of PostCSS">
@diotoborg/ad-tenetur-eveniet
* Convert a tilde path to an absolute path: `~/dev` → `/Users/john/dev` * Inspired by [untilify](https://github.com/sindresorhus/untildify) by [Sindre Sorhus](https://github.com/sindresorhus) * Since untildify uses ES6 syntax, I created this package to fo
@teamteanpm2024/vitae-suscipit-quidem
<h1 align="center">typescript-eslint</h1>