0.0.16 • Published 4 years ago

css-profiler v0.0.16

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

CSS-Profiler

CSS-Profiler is a PostCSS Cli tool to analysis CSS code quality, find its problems, and generate a report to guide developers write more clean, maintainable CSS code.

Features

  • 找出样式名(即选择器)完全相同的样式
  • 找到具有完全相同的内容的所有样式
  • 找出样式内容相似度在 70% 及以上的样式规则
  • 找出前 20 个名字最长的选择器
  • 支持 sourceMap 分析

使用

命令行用法

目前只支持分析单个 CSS 文件。

# install
$ npm i -g css-profiler

# analysis one or more css files
$ css-profile style.css
# result will display below.

Node.js API

TODO

const cssProfiler = require('css-profiler');

const cssContent = `
input {
  display: inline-block;
}
input {
  border: 1px solid #eee;
  padding: .2rem;
  box-sizing: border-box;
  width: 100%;
  display: block;
}
button {
  background: aquamarine;
  border: none;
  margin-top: .2rem;
  display: block;
  width: 100%;
  box-sizing: border-box;
}`;

let result = cssProfiler(cssContent);

原理

可能造成代码重复的原因有:

  • 写代码的时候发懒,复制了已有代码
  • scoped 机制的使用不恰当
  • 构建过程出现了问题
  • 使用预/后处理器时,重复引入某个 css 源文件

Author

zilong-thu

0.0.16

4 years ago

0.0.16-beta

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

10 years ago