2 Star 9 Fork 2

Thoughtworks / lemonj

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

🍋 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:

  • Color refactor
    • analysis colors
    • 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
    • fontFamily
    • colors
    • importants
    • mediaQueries
    • is-odd-width
    • absolute
  • command split
    • Split color refactor as subcommand
  • migration to TypeScript
    • split ast packages
    • use lerna
    • use esbuild
MIT License Copyright (c) 2020 TW FED Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个面向 CSS/LESS/SCSS 的分析、坏味道检查和自动化重构工具。 展开 收起
TypeScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/thoughtworks/lemonj.git
git@gitee.com:thoughtworks/lemonj.git
thoughtworks
lemonj
lemonj
main

搜索帮助