Gathering detailed insights and metrics for eslint-plugin-css-modules
Gathering detailed insights and metrics for eslint-plugin-css-modules
Gathering detailed insights and metrics for eslint-plugin-css-modules
Gathering detailed insights and metrics for eslint-plugin-css-modules
Project status: NOT MAINTAINED; Checks that you are using the existent css/scss classes, no more no less
npm install eslint-plugin-css-modules
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
152 Stars
150 Commits
34 Forks
7 Watching
8 Branches
9 Contributors
Updated on 14 Oct 2024
JavaScript (95.71%)
SCSS (4.1%)
Less (0.19%)
Cumulative downloads
Total Downloads
Last day
-37.3%
17,371
Compared to previous day
Last week
-13.8%
109,173
Compared to previous week
Last month
16.5%
522,598
Compared to previous month
Last year
33.7%
5,315,858
Compared to previous year
2
1
18
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.
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
1/* 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 ofcss-loader
, you must also enabled it for this plugin
1/* 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 ofcss-loader
, you must also enabled it for this plugin
1/* eslint css-modules/no-undef-class: [2, { camelCase: true }] */
npm i --save-dev eslint-plugin-css-modules
.eslintrc
1{ 2 "plugins": [ 3 "css-modules" 4 ], 5 "extends": [ 6 "plugin:css-modules/recommended" 7 ] 8}
You may also tweak the rules individually. For instance, if you use the camelCase option of webpack's css-loader:
1{ 2 "plugins": [ 3 "css-modules" 4 ], 5 "extends": [ 6 "plugin:css-modules/recommended" 7 ], 8 "rules": { 9 "css-modules/no-unused-class": [2, { "camelCase": true }], 10 "css-modules/no-undef-class": [2, { "camelCase": true }] 11 } 12}
The camelCase option has 4 possible values, see css-loader#camelCase for description:
1true | "dashes" | "only" | "dashes-only"
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:
1{ 2 "settings": { 3 "css-modules": { 4 "basePath": "app/scripts/..." 5 } 6 } 7}
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:
1/* .head is global, will not be used in js */ 2:global(.head) { 3 color: green; 4} 5 6.container { 7 width: 116px; 8 9 i { 10 font-size: 2.2rem; 11 } 12 13 .button { 14 padding: 7px 0 0 5px; 15 } 16} 17 18.footer { 19 color: cyan; 20}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 3/9 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
18 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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 More