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

eslint-plugin-dir-structure

v0.1.6

Published

检测目录结构是否符合规范

Downloads

194

Readme

eslint-plugin-dir-structure

检测目录结构,变量命名是否符合规范

目前主要用于vue+vue-router技术栈的相关项目

Installation

首先你应该下载eslint ESLint:

npm i eslint --save-dev

第二步下载 eslint-plugin-dir-structure:

npm install eslint-plugin-dir-structure --save-dev

使用

Add dir-structure to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix: 将dir-structure添加到.eslintrc配置文件的plugins部分。你可以省略eslint-plugin-前缀:

{
    "plugins": [
        "dir-structure"
    ]
}

然后在规则部分配置您想要使用的规则。

{
    "rules": {
      "dir-structure/router-path": [2, "always", {
        "includeFile": ["*configManage"],//根据下方设置的目录及后缀划定检测范围,为空全检测
        "excludeFile": [],// 设置无需检测的文件
        "dirTypeOptions" : { //检测以下文件夹的命名是否和router的path一致
          "port-service":".js" //可根据自己项目的实际名称进行变更
        }
      }],
      "dir-structure/name-defined": [2, "always", {
        "includeFile": ["*configManage/dash","*demo"], //根据下方设置的目录及后缀划定检测范围,为空全检测
        "excludeFile": [],// 设置无需检测的文件
        "dirTypeOptions" : { // 检测当前service options 等js文件的export default 变量命名与路径是否一一对应
          "options":".js",
          "service":".js"
        },
        "nameType":{
          "variableName":"camelCase", //  camelCase 驼峰  Snake 下划线
          "fileName":"kebab-case" //  camelCase 驼峰   kebab-case 短横杠
        }
      }]
    }
}
includeFile 代表需要检测router下的指定路径文件,类型为数组

[]空代表router文件夹下需要全检测 示例如下,支持开头使用通配符的形式,变量后自动支持通配符, 注意:通配符只能存在一个,并且在开头

| Wildcard | Matching | |:------------|:----------------------------------------------------------| | *stable | productionstable, stagingstable ,stagingstable/demo | | stable/dem | stable/dem/aa, stable/demfff |

nameType 选择命名类型

| 属性 | 说明 | |:-------------|:--------------------------------------------------------------------| | variableName | export default变量命名规则,主要有俩种 camelCase代表小驼峰的形式命名 Snake 代表下划线的形式命名 | | fileName | 文件、文件夹命名类型模式,主要有俩种 camelCase代表小驼峰的形式命名 kebab-case 代表短横行的形式命名 |

规则

| Name | Description | |:-------------------------------------------|:--------------------------| | router-path | 检测目录结构是否符合规范 | | name-defined | 检测文件export default的对应变量命名 |

更多检测规则持续补充中