0.1.6 • Published 7 months ago

eslint-plugin-dir-structure v0.1.6

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

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文件夹下需要全检测 示例如下,支持开头使用通配符的形式,变量后自动支持通配符, 注意:通配符只能存在一个,并且在开头

WildcardMatching
*stableproductionstable, stagingstable ,stagingstable/demo
stable/demstable/dem/aa, stable/demfff
nameType 选择命名类型
属性说明
variableNameexport default变量命名规则,主要有俩种 camelCase代表小驼峰的形式命名 Snake 代表下划线的形式命名
fileName文件、文件夹命名类型模式,主要有俩种 camelCase代表小驼峰的形式命名 kebab-case 代表短横行的形式命名

规则

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

更多检测规则持续补充中

0.1.6

7 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago

0.0.0

8 months ago