{"id":15011180,"url":"https://github.com/modernizing/lemonj","last_synced_at":"2025-04-09T19:04:27.191Z","repository":{"id":126981683,"uuid":"313818147","full_name":"modernizing/lemonj","owner":"modernizing","description":"A CSS/LESS/SCSS analysis, bad smell check and auto-refactor tools. 一个面向 CSS/LESS/SCSS 的分析、坏味道检查和自动化重构工具。","archived":false,"fork":false,"pushed_at":"2022-01-25T05:57:34.000Z","size":226,"stargazers_count":139,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-20T03:21:06.114Z","etag":null,"topics":["css","less","refactoring","scss"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modernizing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-11-18T03:59:43.000Z","updated_at":"2024-02-21T17:43:24.000Z","dependencies_parsed_at":"2023-06-19T14:02:51.204Z","dependency_job_id":null,"html_url":"https://github.com/modernizing/lemonj","commit_stats":null,"previous_names":["twfe/lemonj"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernizing%2Flemonj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernizing%2Flemonj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernizing%2Flemonj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernizing%2Flemonj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modernizing","download_url":"https://codeload.github.com/modernizing/lemonj/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248095028,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","less","refactoring","scss"],"created_at":"2024-09-24T19:39:29.777Z","updated_at":"2025-04-09T19:04:27.149Z","avatar_url":"https://github.com/modernizing.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍋 lemonj\n\nCSS/LESS/SCSS 自动重构、坏味道检查工具。\n\n## 💡 Features:\n\n- 重构\n  - CSS 颜色自动抽离重构变量\n- 坏味道\n  - 字体\n  - 奇数宽度\n  - `importants`\n  - `position: absolute`\n  - `mediaQueries`\n\n## 📦 Install\n\n```\nnpm install lemonj -g\n```\n\n或者\n\n```\nyarn global add lemonj\n```\n\n## 🌰 Demo\n\n### CSS 颜色自动抽离变量\n\n我们要重构 `\\_fixtures` 文件夹下 `less` 样式文件：\n\n1. 分析文件\n\n```\nlemonj analysis _fixtures\n```\n\n输出代码坏味道：\n\n```\nCode Smell:  {\n  colors: 24,\n  importants: 4,\n  issues: 8,\n  mediaQueries: 1,\n  absolute: 0,\n  oddWidth: 1\n}\n```\n\n2. 每种颜色都重构为一个变量在 `mappings.less` 中，你可以修改对应的颜色：\n\n```less\n// _fixtures/less/color/border.less\n@color1: #ddd;\n// _fixtures/less/color/border.less\n@color2: green;\n// _fixtures/less/color/rgba.less\n@color3: rgba(255, 0, 0, 0.3);\n// _fixtures/less/color/sample.less\n@color4: #ff7f50;\n// _fixtures/less/color/sample.less\n// _fixtures/less/color/sample2.less\n@color5: #800080;\n// _fixtures/less/color/sample.less\n@color6: red;\n// _fixtures/less/color/sample.less\n// _fixtures/less/color/sample.less\n@color7: #428bca;\n// _fixtures/less/color/sample.less\n@color8: #fff;\n// _fixtures/less/color/sample2.less\n@color9: #000000;\n```\n\n3. 运行重构命令：\n\n```\nlemonj refactor _fixtures\n```\n\n此时每个写死的颜色，都抽离到变量中。\n\n## 🛣️ RoadMap:\n\n- [x] Color refactor\n  - [x] analysis colors\n  - [x] auto-refactor colors\n- [ ] 3+ level class nested Refactor\n  - [ ] analysis 3+ level nested\n  - [ ] process 3+ level nested\n- [ ] selector auto folding. `.level1.level2{}` to `.level1{.level2}}`\n  - [ ] analysis need to merge selector\n  - [ ] refactor selector\n- [ ] sort `colors.less` by colors\n- [ ] Summary\n  - [x] fontFamily\n  - [x] colors\n  - [x] importants\n  - [x] mediaQueries\n  - [x] is-odd-width\n  - [x] absolute\n- [ ] command split\n  - [ ] Split `color` refactor as subcommand\n- [ ] migration to TypeScript\n  - [ ] split ast packages\n  - [x] use esbuild\n\nLicense\n---\n\nThis code is distributed under the MPL license. See `LICENSE` in this directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernizing%2Flemonj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodernizing%2Flemonj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernizing%2Flemonj/lists"}