This Bash script scans .scss
and .css
files within a given directory for occurrences of pixel (px
) values. It helps enforce the use of relative units (e.g., em
, rem
, vw
, vh
, or %
) instead of fixed pixel values to improve responsiveness. The script allows developers to ignore specific lines using a special comment.
- Recursively searches
.scss
and.css
files in a directory. - Lists lines containing pixel values.
- Skips lines marked with
// ignore-px-checker
. - Exits with a non-zero status if pixel values are found.
No installation required. Ensure you have bash
and grep
installed on your system.
Run the script with the target directory as an argument:
./pixel_checker.sh /path/to/your/css/files
Found pixel values in styles/main.scss:
line 15: font-size:14px;
line 42: margin:10px;
To ignore a specific line from the check, add the comment // ignore-px-checker
above it:
/* ignore-px-checker */
font-size: 14px;
0
- No pixel values found.1
- Pixel values found.
This project is open-source and available under the MIT License.