百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

folderslint

> 开发工具
开源

用于前端项目的目录结构检查工具

195 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

用于前端项目的目录结构检查工具

FoldersLint

Directory structure linter for Front-End projects

✅   Easily configured with simple rules in a single file

✅   Incredibly fast

✅   Support for Windows, MacOS and Linux

✅   Can be used with lint-staged

Why

Make you project sctructure pretty by linting it

Directory structure rules are important part of any project. These rules help to raise clarity of the project and reduce its complexity. Having a clearly defined structure make developers always know where to put files and where to find them. If the project is big enough, it is necessary to avoid chaos in it.

folderslint let you configure directory structure rules and check if existed or new files fit these rules.

Quick Overview

Install folderslint globally:

bash
npm install -g folderslint

Setup a config file .folderslintrc in the root of the project.

Run folderslint to check the whole project or a directory (i.e. /components):

bash
folderslint components

Configuration

folderslint needs configuration file named .folderslintrc in the root of the project.

The example of the config:

javascript
{
  "root": "src", // optional
  "rules": [
    "components/*",
    "pages/components/*/utils",
    "hooks",
    "legacy/**"
   ]
}

root is the directory the structure of which should be checked.

rules is an array of rules which define permitted directory paths.

Root directory

You have to specify root if you want to check structure in a specific directory. Directories which are out of the root will not be checked. If you want all the directories of the project to be checked, you don't need to specify root.

Rules syntax

There are 3 ways to specify a rule:

  • the exact path of a directory,
  • * instead of a directory name if any directory accepted on that level,
  • ** at the end of a rule instead of a directory name if any directory accepted on any lower level.

⚠️ ** can be used only at the end of a rule because it doesn't make sense to use it at the middle of a rule. It would make any number of nested directories in the middle of a path accepted which gives too much flexibility for the idea of clearly defined directory structure rules.

For example:

Rule Meaning
hooks ✅  The directory hooks (and files in it) is accepted.
❌  Any nested directory is not accepted.
components/* ✅  The directory components is accepted.
✅  Any first level nested directory is accepted.
❌  Any second level nested directory is not accepted.
components/*/utils ✅  The directory components is accepted.
✅  Any first level nested directory is accepted.
✅  The second level nested directory utils is accepted.
❌  Any other second level nested directory is not accepted.
legacy/** ✅  The directory legacy is accepted.
✅  Any nested directory on any level is accepted.
components/*/legacy/** ✅  The directory components is accepted.
✅  Any first level nested directory is accepted.
✅  The second level nested directory legacy is accepted.
❌  Any other second level nested directory is not accepted.
✅  Any nested directory on any level inside of legacy directory is accepted.

⚠️ A rule like components/*/utils automatically make the components and components/* rules work. So, no need to specify a rule for every level directory. You need to specify the deepest path.

⚠️ It's not recommended to overuse ** pattern. It lets absence of structure to sprout in your project. Still it could be useful for some directories which have messy structure by its nature - i.e. node_modules, not maintained legacy directories.

Usage with lint-staged

It is handy to use folderslint together with lint-staged. In this case folderslint checks only the files which were modified for a commit.

For that, add folderslint to the lint-staged section of your package.json.

For example, this is how package.json can look like if you want to run folderslint as a pre-commit hook via husky tool:

json
"husky": {
  "hooks": {
    "pre-commit": "lint-staged",
  }
},
"lint-staged": {
  "*.{js,ts,tsx}": [
    "folderslint"
  ]
}

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptdirectory-treefolder-structurejavascriptlint

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具