GithubHelp home page GithubHelp logo

imchaoyu / luoshen Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.71 MB

a perfect front-end style rules like the Luo Shen of China

License: MIT License

JavaScript 4.59% Less 0.34% TypeScript 88.51% HTML 1.20% Vue 5.24% CSS 0.11%

luoshen's Introduction

luoshen

GitHub last commit GitHub all releases

洛神,**古代神话中的人物,其形象十分美丽,“翩若惊鸿、婉若游龙、云髻峨峨、皓齿内鲜”。

以“洛神”命名,希望在繁琐复杂的前端样式规范配置中,减轻工作量,让前端格式化更简单更优美。

包含 Prettier,ESLint,Stylelint, TypeScript 的配置文件合集,并使用 husky 对 git 提交信息进行校验。

功能

  • React
  • TypeScript
  • nodejs
  • husky commit-msg
  • Vue

根据不同项目加载不同配置项,减少多余配置

使用

安装本包和 Prettier,ESLint,Stylelint,如果项目使用 TypeScript,则再安装 TypeScript,洛神会自动支持 TypeScript 的格式化.

npm install -D luoshen prettier eslint stylelint
  • 配置 .eslintrc.js

    module.exports = {
      extends: [require.resolve('luoshen/dist/eslint')],
      // vue 项目使用以下配置项
      // extends: [require.resolve('luoshen/dist/eslint-vue')],
      rules: {
        // your rules
      },
    };
  • 配置 .prettierrc.js

const luoshen = require('luoshen');

module.exports = {
  ...luoshen.prettier,
};
  • 配置 .stylelintrc.js
module.exports = {
  extends: [require.resolve('luoshen/dist/stylelint')],
  rules: {
    // your rules
  },
};
  • 配置 husky

    1. 安装husky
    npm install -D husky
    1. package.json 增加prepare命令
    "script":{
      "prepare": "husky install"
    }

    然后运行npm run prepare 或者直接运行以下命令:

    npm pkg set scripts.prepare="husky install"
    npm run prepare
    1. 添加commit-msg执行脚本
    npx husky add .husky/commit-msg 'npx luoshen verify-commit "$1"'

编辑器设置

项目文件配置好后,设置编辑器,便可以在每次保存时自动格式化

VS Code

  • 安装ESLint、Prettier和StyleLint插件
  • formatOnSave 关闭
  • editor.codeActionsOnSave 修改
"editor.codeActionsOnSave": {
  "source.fixAll.eslint": true,
  "source.fixAll.stylelint": true
},
  • stylelint.validate内增加 vue支持
"stylelint.validate": [
  "css",
  "less",
  "postcss",
  "vue"
],

luoshen's People

Contributors

ichaoyu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.