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

@youngk/stylelint-config

v1.0.0

Published

瑞可科技-前端scss代码规范

Downloads

1

Readme

代码规范

使用ESLint

    安装
    yarn  add eslint -D
    初始化配置
    ./node_modules/.bin/eslint --init
    选择配置 主流都使用standard规范(Airbnb更严格繁琐,如要代码尾部加; 对象末尾属值性要加,)
    ✔ How would you like to use ESLint? · style
    ✔ What type of modules does your project use? · esm
    ✔ Which framework does your project use? · vue
    ✔ Does your project use TypeScript? · No / Yes
    ✔ Where does your code run? · browser
    ✔ How would you like to define a style for your project? · guide
    ✔ Which style guide do you want to follow? · standard
    ✔ What format do you want your config file to be in? · JavaScript

集成Prettier

ESLint 主要解决了两类问题,但其实 ESLint 主要解决的是代码质量问题。另外一类代码风格问题其实并没有完全做完。 代码质量规则

  • (code-quality rules)
  • no-unused-vars
  • no-extra-bind
  • no-implicit-globals
  • prefer-promise-reject-errors

代码风格规则

  • (code-formatting rules)
  • max-len
  • no-mixed-spaces-and-tabs
  • keyword-spacing
  • ...

代码质量出问题意味着程序有潜在Bug,而风格问题决定是否利于阅读。

Prettier主要解决的就是代码风格问题

  • 依赖安装
    yarn add prettier -D

    yarn add eslint-plugin-prettier -D //集成eslint的插件

    yarn add eslint-config-prettier -D //用于关闭所有不必要的规则,或可能与Prettier冲突的规则

eslint-config-prettier覆盖集成时与eslint冲突的规则

{
  "extends": [
    "some-other-config-you-use",
    "prettier"//必须最后,做覆盖操作
  ]
}

plugins中引入eslint-plugin-prettier的配置

{
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": "error" //开启报错提示
  }
}

使用StyleLint

安装标准配置

安装命令

    yarn add stylelint -D

    yarn add stylelint-config-standard -D

.stylelintrc对应配置

{
  'extends': "stylelint-config-standard"
}

安装属性顺序检查插件

安装命令

    yarn add stylelint-order -D

    yarn add stylelint-config-rational-order -D

.stylelintrc对应配置

{ 
  "extends":[ 
    “ stylelint-config-rational-order” 
  ],
  "plugins": [
    "stylelint-order",
    "stylelint-config-rational-order/plugin"
  ],
  "rules": {
    //默认配置
    "order/properties-order": [],
    "plugin/rational-order": [
      true,
      {
        "border-in-box-model": false,
        "empty-line-between-groups": true
      }
    ],
    // 解决与plugin/rational-order中"empty-line-between-groups": true与基础配置的冲突
    "declaration-empty-line-before": [
      "never",
      {
        ignore:["after-declaration"]
      }
    ],
  }
}

stylelint集成scss

安装命令

    yarn add stylelint-scss -D
    yarn add stylelint-config-sass-guidelines -D

.stylelintrc对应配置

  {
    "extends":[ 
      "stylelint-config-sass-guidelines"
    ],
    "plugins": [
      "stylelint-scss"
    ],
    rules: [
      // 解决stylelint-order插件与stylelint-config-sass-guidelines冲突
      "order/properties-alphabetical-order":null
    ]
  }

更多插件