• Stars
    star
    118
  • Rank 299,923 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dead CSS detection

Mort

Detects dead CSS.

Build Status

A demonstration of Mort

Installing

You can use the binaries on the releases page for versions 1.5 and above.

Or if you like, use npm.

npm i mort-css

Or globally with

npm i -g mort-css

You should then be able to run mort.

Usage

cd to the root of the project you're interested in and run mort to scan that css file against your codebase.

Normal use

mort -f your-css-file.css

Verbose output

mort -f your-css-file.css -v

Forcing use of git grep

mort -f your-css-file.css -p gitgrep

Stdin

If no arguments are supplied, mort reads from stdin.

i.e.

cat my-css-file.css | mort

or

echo "#my-selector-to-hunt-for" | mort

Multiple CSS files

It's possible to scan multiple CSS files with mort.

ls assets/css/*.css | xargs -L1 mort -v -f 

Ignoring some files with find

find -iname *.scss -not -path "./node_modules/*" | xargs -L1 mort -vf

Options

  Usage: mort [options]

  Options:

    -V, --version               output the version number
    -u, --usage-count <number>  Show warnings for any css selector <= usage-count. (default: 0)
    -v, --verbose               Detailed information about the matches will be displayed.
    -f, --file <path>           The css file to run mort against.
    -p, --program <program>     Force mort to use a grep program of your choice. Supported ones are 'ripgrep', 'gitgrep', and 'grep'.
    -h, --help                  output usage information

-u --usage-count

This will show all selectors that are <= to the specified count.

i.e.

mort -f your-css-file.css -u 3

Will display all selectors that are used 3 times or less. This is particularly useful to find selectors that can be combined into classes etc...

-v --verbose

This toggles verbosity. There are currently 3 levels of verbosity.

Level 1

mort -f somefile.css -v

Level 1 displays what file it is scanning and the line count for that selector.

Level 2

mort -f somefile.css -vv

Level 2 displays level 1 + The command used to find the selector

Level 3

mort -f somefile.css -vvv

Level 3 displays level 1 + level 2 and shows all selectors it is searching through (regardless of whether they are used or not).

-f --file

The file to run mort against. If unspecified, mort will read from stdin.

-p --program

Which grep program to use. The default is ripgrep as it's the quickest. Supported grep programs are ripgrep, gitgrep, and grep.

Note that grep is incredibly slow so is not recommended

Using the default (ripgrep)

mort -f somefile.css

Using git grep

mort -f somefile.css -p gitgrep

Using grep

mort -f somefile.css -p grep

Requirements

  • One of either:
    • ripgrep
    • git grep
    • grep (Not recommended, very slow with mort)

Note that this tool can't detect all use cases. For example, string-concatting a selector in JS will probably bypass the tool.

More Repositories

1

what-to-code

Ideas for things to program
1,363
star
2

sql-lint

An SQL linter
TypeScript
435
star
3

SQHell.vim

An SQL wrapper for vim
Vim Script
132
star
4

fanbox

A HTML + CSS + JS desktop dashboard!
HTML
94
star
5

place.vim

Enter pieces of text without moving
Vim Script
43
star
6

reap-get

A package manager for VST plugins!
Python
36
star
7

cmaj

Music theory from the command line
Python
36
star
8

Image-to-Ascii

An image to Ascii converter written in Python
23
star
9

AsciiThis-Bot

The code for the AsciiThis bot on Reddit
C#
17
star
10

exoskeleton.vim

Skeleton vim improved
Vim Script
17
star
11

haxe-heaps-examples

Simple demonstrations of doing things with Heaps
Haxe
16
star
12

configs

My dotfiles and configs
Shell
15
star
13

gtags-scope

An up-to-date version of gtags-cscope.vim from GNU global
Vim Script
15
star
14

life

A dump of my docs
Shell
13
star
15

metronome

The metronome on
JavaScript
12
star
16

deoplete-minisnip

Deoplete source for vim-minisnip
Python
12
star
17

entree

A wrapper for entr that allows you to version control your watchers
Shell
10
star
18

silver-doodle

A linter for the Scheme programming language
Python
9
star
19

gq.vim

formatprgs for many filetypes
Vim Script
6
star
20

vim-c-manual

Vim :help for the C11 standard
Python
6
star
21

pcre-vim

Convert PCREs to vim expressions
Lua
4
star
22

css-refactoring-patterns

Refactoring patterns for CSS
HTML
4
star
23

salutem

Health checking for frugal server administrators
Python
4
star
24

what

Get help for cli flags instantly
Lua
2
star
25

joereynolds.github.io

The source for
Ruby
1
star
26

programming-dump

A dump of programming stuff. Challenges, algorithms, data structures etc...
C
1
star
27

mr-grabby

Read websites from the command line
Shell
1
star
28

mrfigsgame.com

The Website for Mr Figs
HTML
1
star
29

all-skate-decks

A website commemorating all skateboard decks from the past (and present)
JavaScript
1
star
30

this-isnt-tennis

A top down action game
Lua
1
star