npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lemonj

v0.2.0

Published

CSS/LESS/CSS Auto Refactor

Downloads

5

Readme

🍋 lemonj

CSS/LESS/SCSS 自动重构、坏味道检查工具。

💡 Features:

  • 重构
    • CSS 颜色自动抽离重构变量
  • 坏味道
    • 字体
    • 奇数宽度
    • importants
    • position: absolute
    • mediaQueries

📦 Install

npm install lemonj -g

或者

yarn global add lemonj

🌰 Demo

CSS 颜色自动抽离变量

我们要重构 \_fixtures 文件夹下 less 样式文件:

  1. 分析文件
lemonj analysis _fixtures

输出代码坏味道:

Code Smell:  {
  colors: 24,
  importants: 4,
  issues: 8,
  mediaQueries: 1,
  absolute: 0,
  oddWidth: 1
}
  1. 每种颜色都重构为一个变量在 mappings.less 中,你可以修改对应的颜色:
// _fixtures/less/color/border.less
@color1: #ddd;
// _fixtures/less/color/border.less
@color2: green;
// _fixtures/less/color/rgba.less
@color3: rgba(255, 0, 0, 0.3);
// _fixtures/less/color/sample.less
@color4: #ff7f50;
// _fixtures/less/color/sample.less
// _fixtures/less/color/sample2.less
@color5: #800080;
// _fixtures/less/color/sample.less
@color6: red;
// _fixtures/less/color/sample.less
// _fixtures/less/color/sample.less
@color7: #428bca;
// _fixtures/less/color/sample.less
@color8: #fff;
// _fixtures/less/color/sample2.less
@color9: #000000;
  1. 运行重构命令:
lemonj refactor _fixtures

此时每个写死的颜色,都抽离到变量中。

🛣️ RoadMap:

  • [x] Color refactor
    • [x] analysis colors
    • [x] auto-refactor colors
  • [ ] 3+ level class nested Refactor
    • [ ] analysis 3+ level nested
    • [ ] process 3+ level nested
  • [ ] selector auto folding. .level1.level2{} to .level1{.level2}}
    • [ ] analysis need to merge selector
    • [ ] refactor selector
  • [ ] sort colors.less by colors
  • [ ] Summary
    • [x] fontFamily
    • [x] colors
    • [x] importants
    • [x] mediaQueries
    • [x] is-odd-width
    • [x] absolute
  • [ ] command split
    • [ ] Split color refactor as subcommand
  • [ ] migration to TypeScript
    • [ ] split ast packages
    • [ ] use lerna
    • [x] use esbuild