A Node.js CLI tool to detect and list Tailwind CSS border-width related classes in your project files with their exact locations.
- π Detects all border-width related Tailwind CSS classes
- π Shows exact file paths and line numbers
- π― Supports multiple file formats (HTML, JSX, Vue, PHP, etc.)
- β‘ Fast scanning with built-in file filtering
- π Provides summary statistics
- π οΈ Configurable file extensions and ignore patterns
The tool detects the following Tailwind CSS border-width classes, including those with variants:
border- Sets border-width to 1pxborder-0- Sets border-width to 0border-2- Sets border-width to 2pxborder-4- Sets border-width to 4pxborder-8- Sets border-width to 8px
border-x,border-x-0,border-x-2,border-x-4,border-x-8- Horizontal bordersborder-y,border-y-0,border-y-2,border-y-4,border-y-8- Vertical bordersborder-t,border-t-0,border-t-2,border-t-4,border-t-8- Top borderborder-r,border-r-0,border-r-2,border-r-4,border-r-8- Right borderborder-b,border-b-0,border-b-2,border-b-4,border-b-8- Bottom borderborder-l,border-l-0,border-l-2,border-l-4,border-l-8- Left border
border-[3px],border-t-[1rem],border-x-[2.5px]- Custom border-width values
The tool also detects all border-width classes when used with Tailwind variants:
sm:border-2,md:border-4,lg:border-8,xl:border-0,2xl:border-t-4
hover:border-2,focus:border-4,active:border-0hover:border-t-8,focus:border-x-[3px]
dark:border-0,dark:border-[2px],dark:hover:border-4
lg:hover:border-2xl:focus:border-t-82xl:hover:focus:border-[3px]dark:md:hover:border-b-4
The detector recognizes any combination of variants with border-width classes.
No installation required. Just download the script and run it with Node.js.
# Navigate to the tool directory
cd tools/border-width-detector
# Make executable
chmod +x border-width-detector.js
# Run directly
node border-width-detector.js# Scan current directory (from project root)
node tools/border-width-detector/border-width-detector.js
# Or from within the tool directory
cd tools/border-width-detector
node border-width-detector.js ../../
# Scan specific directory
node border-width-detector.js ../../src
# Show help
node border-width-detector.js --help# Scan only specific file types
node border-width-detector.js ../../src --ext js,jsx,ts,tsx
# Custom ignore patterns
node border-width-detector.js ../../ --ignore node_modules/**,dist/**,coverage/**
# Combined options
node border-width-detector.js ../../app --ext html,js,vue --ignore tests/**,*.test.js| Option | Description | Default |
|---|---|---|
--help, -h |
Show help message | - |
--ext <extensions> |
File extensions to scan (comma-separated) | html,htm,js,jsx,ts,tsx,vue,svelte,php,erb,haml,slim,pug,twig,razor,blade.php |
--ignore <patterns> |
Ignore patterns (comma-separated) | node_modules/**,dist/**,build/**,.git/** |
π Scanning for border-width classes in: /path/to/project
π File extensions: html, js, jsx, ts, tsx
π« Ignore patterns: node_modules/**, dist/**, build/**, .git/**
Found 8 border-width class usage(s):
π src/components/Button.jsx
12:border-2 - <button className="px-4 py-2 border-2 border-blue-500">
24:hover:border-0 - <button className="hover:border-0 bg-transparent">
π src/pages/Home.tsx
45:md:border-t-4 - <div className="md:border-t-4 border-gray-200">
67:lg:hover:border-x-[3px] - <section className="lg:hover:border-x-[3px] border-red-500">
π public/index.html
89:border - <div class="border rounded-lg p-4">
102:dark:border-2 - <div class="dark:border-2 bg-gray-800">
115:xl:focus:border-b-8 - <input class="xl:focus:border-b-8">
π src/utils/styles.js
23:2xl:hover:border-[5px] - const dynamicClass = "2xl:hover:border-[5px]";
π Summary by class:
2xl:hover:border-[5px]: 1 usage(s)
border: 1 usage(s)
border-2: 1 usage(s)
dark:border-2: 1 usage(s)
hover:border-0: 1 usage(s)
lg:hover:border-x-[3px]: 1 usage(s)
md:border-t-4: 1 usage(s)
xl:focus:border-b-8: 1 usage(s)
The tool uses the extraction patterns inspired by Tailwind CSS's oxide engine:
- Class Extraction: Scans files for class attributes, className props, template literals, and arrays
- Pattern Matching: Uses precise regular expressions to identify only border-width classes
- Line Detection: Finds exact line numbers where classes are used
- Result Formatting: Groups results by file and provides summary statistics
- HTML:
.html,.htm - JavaScript:
.js,.jsx - TypeScript:
.ts,.tsx - Vue:
.vue - Svelte:
.svelte - PHP:
.php,.blade.php - Ruby:
.erb,.haml,.slim - Template Engines:
.pug,.twig - ASP.NET:
.razor
Run the included test suite:
node test-border-detector.jsThe tests verify:
- Pattern matching accuracy
- Class extraction from various syntaxes
- File scanning functionality
- Line number detection
You can also use the detector programmatically:
const { BorderWidthDetector } = require('./border-width-detector');
const detector = new BorderWidthDetector({
extensions: ['js', 'jsx', 'ts', 'tsx'],
ignorePatterns: ['node_modules/**', 'dist/**']
});
// Scan a directory
const results = detector.scanDirectory('./src');
// Scan a single file
const fileResults = detector.scanFile('./src/component.jsx');
// Format results
console.log(detector.formatResults(results));MIT