@exlint.io/inflint

中文文档
2.1.1发布于 2023/11/27MITTypeScriptES Module近 30 天下载 2176

Inflint is a tool which scans and verifies file name conventions.

原始使用文档
文档目录17 节
  1. Inflint
  2. Demo
  3. Installation
  4. Usage
  5. ESM support
  6. Configuration
  7. Rules format
  8. Rule option
  9. File names conventions
  10. CLI Rules
  11. Aliases
  12. CLI Aliases
  13. Examples
  14. Support
  15. Contributing
  16. Authors
  17. License

CI status npm downloads npm license version

 

Inflint

Inflint is a tool which scans and verifies files and folders name conventions.

Inflint allows you to easily set file names convention in your repository.

Demo

Inflint

Installation

Globally

npm install --global @exlint.io/inflint

Locally

npm install --save-dev @exlint.io/inflint

Usage

$ inflint [options] [files]

ESM support

Inflint now supports only ESM modules, from version >1.2.10. For any issue regarding this, please visit this link https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Configuration

You can specify the configuration of Inflint through various options. Configuration can be set in the following files:

  • a package.json property: "inflint": {...}
  • a .inflintrc file in JSON or YAML format
  • a .inflintrc.json, .inflintrc.yaml, .inflintrc.yml, .inflintrc.js, .inflintrc.ts, or .inflintrc.cjs file
  • a inflint.config.ts, inflint.config.js, or inflint.config.cjs CommonJS module exporting an object

Rules format

When applying rules either via the CLI or other configuration, you must follow the rules format. "1" and "warn" are warnings rules, "2" and "error" are errors rules. Each rule has key and value. The key represents the glob pattern. When a file matches the pattern, it will be enforced by the rule. The rule value represents the rule enforcement.

Rules enforcement format:

  • Set rules of files-existence: 1 | 2 | 'warn' | 'error' | [1] | [2] | ['warn'] | ['error']

    Example: { './src/**/*': 2 } → Inflint emits an error if there are any files/folders inside "src" folder

  • Set rules to match file names conventions: [1, <convention>] | [2, <convention>] | ['warn', <convention>]| ['error', <convention>]

    Example: { './src/**/*': [1, 'kebab-case'] } → Inflint emits an error if there are any files/folder which do not match the "kebab-case" convention name inside "src" folder.

  • Set rules options: [1, <convention>(optional), <options>] | [2, <convention>(optional), <options>] | ['warn', <convention>(optional), <options>] | ['error', <convention>(optional), <options>]

    Example1: { './src/**/*': [1, { onlyFiles: true }] } → Inflint emits an error if there are any files inside "src" folder (and allows folders to exist)

    Example2: { './src/**/*': [1, 'point.case', { onlyFiles: true }] } → Inflint emits an error if there are any files which do not match the "point-case" convention name inside "src" folder (and allows folders inside "src" folder not to match the "point.case" pattern)

If you provide unknown convention which isn't known one or a configured alias, Inflint considers the "convention" as regex.

Rule option

You can set options for any rule, in order to get some customization.

  • onlyDirectories: Boolean (default: false)

    Inflint checks the rule with directories only, skips files.

  • onlyFiles: Boolean (default: false)

    Inflint checks the rule with files only, skips directories.

  • dot: Boolean (default: true)

    Allow Inflint to match files and directories starting with a period (.).

  • caseSensitiveMatch: Boolean (default: true)

    Enables a case-sensitive mode for matching files and folders.

File names conventions

You can set file names conventions rules using known ones. Inflint allows you to set the following: | Convention | Alias | Description | | :------------------------- | :--------------------------- | :------------------------------------------------------------------------------------------------ | | lowercase | lowercase | Every letter must be lowercase. Ignores non-letters | | camelcase | camelCase | Must be in "camelCase" format. Only letters and digits are allowed | | camelcase-point | camelCase.point | Must be in "camelCase" format. Only letters, digits and . are allowed | | pascalcase | PascalCase | Must be in "PascalCase" format. Only letters and digits are allowed | | pascalcase-point | PascalCase.Point | Must be in "PascalCase" format. Only letters, digits and . are allowed | | snakecase | snake_case | Must be in "snake_case" format. Only lowercase letters, digits and _ are allowed | | snakecase-point | snake_case.point | Must be in "snake_case" format. Only lowercase letters, digits, _ and . are allowed | | screamingsnakecase | SCREAMING_SNAKE_CASE | Must be in "SCREAMING_SNAKE_CASE" format. Only uppercase letters, digits and _ are allowed | | screamingsnakecase-point | SCREAMING_SNAKE_CASE.POINT | Must be in "SCREAMING_SNAKE_CASE" format. Only uppercase letters, digits, _ and . are allowed | | kebabcase | kebab-case | Must be in "kebab-case" format. Only lowercase letters, digits and - are allowed | | kebabcase-point | kebab-case.point | Must be in "kebab-case" format. Only lowercase letters, digits, - and . are allowed | | pointcase | point.case | Must be in "point.case" format. Only lowercase letters, digits and . are allowed |

CLI Rules

When adding rules via the CLI, you need to provide a valid JSON for the --rule argument. You can provide multiple rules. The JSON should follow the rules format described above.

Example: inflint --rule "{ \"src/**/*\": [1] }"

Aliases

You can use the known conventions, or you can add your own by applying aliases, via the CLI or other configuration. To use the aliases, simply use the alias name as you would use a known convention. Aliases should be applied with the following format:

  • <alias_name>: <regex> Inflint will apply the alias name to match the provided regex.

    Example: Applying the alias { myAlias: '^.*$' } and the rule { 'src/**/*': [2, 'myAlias'] } → Inflint checks any file/folder in "src" folder to match the alias regex.

  • <alias_name>: [<regex>, <regex_flags>] Inflint applies the alias name to match the provided regex with given regex flags.

    Example: { myAlias: ['^.*$', 'i'] } → Any rule applied with myAlias alias tries to match files/folders names by the provided regex and the i regex flag.

CLI Aliases

When adding aliases via the CLI, you need to provide a valid JSON for the --alias argument. You can provide multiple aliases. The JSON should follow the aliases format described above.

Example: inflint --alias "{ \"myAlias\": \"^\\.\" }"

You can escape aliases regex with in the CLI if you prefix character with \\. "^\\." will match any string begins with dot (.)

CLIConfiguration keyTypedefaultDescription
-extendsString-A path to configuration file to extend configurations from
--no-inflintrc-BooleanfalseWhether Inflint ignores any configuration file
-c, --config-String-The path to a configuration file which will be used by Inflint
--rulerulesAbove-Inflint rules to use against files
--aliasaliasesAbove-Inflint aliases to use together with rules
--ignore-pathignorePathString.inflintignoreIgnore file path Inflint will use to ignore patterns
--no-ignoreignoreBooleanfalseDisable use of ignore files and patterns
--ignore-patternignorePatternsString[][]Patterns of files to ignore (in addition to those in .inflintignore)
--quietquietBooleanfalseWhether to report errors only
--max-warningsmaxWarningsNumber0Number of warnings to trigger non-zero exit code
--bailbailBoolean or Number0Number of failures (errors) to make Inflint to exit. Setting "bail" to true is the same as setting "1"
-o, --output-fileoutputFileString-Specify file to write report to
--color, --no-color-BooleantrueForce enabling/disabling of color
-h, --help-BooleanfalseShow help
-v, --version-BooleanfalseOutput the version number
--env-info-BooleanfalseOutput the environment version

Examples

Support

For support, email [email protected] or open an issue at inflint issues.

Contributing

Contributions are always welcome!

See CONTRIBUTING.md for ways to get started.

Please adhere to this project's CODE_OF_CONDUCT.md.

Authors

License

MIT

版本与发布记录

@exlint.io/inflint 共发布 11 个版本,首次发布于 2022/06/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.1latest2023/11/272 年前
2.1.02023/11/093 年前
2.0.22023/11/093 年前
2.0.12023/11/083 年前
2.0.02023/04/143 年前
1.2.112023/04/143 年前

关于 @exlint.io/inflint 的常见问题

@exlint.io/inflint 是什么?

Inflint is a tool which scans and verifies file name conventions.

如何安装 @exlint.io/inflint?

在项目目录运行 npm install @exlint.io/inflint,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 inflint,可以用 npx inflint 直接运行。

@exlint.io/inflint 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@exlint.io/inflint 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exlint.io/inflint 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14.16。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@exlint.io/inflint 可以商用吗?

@exlint.io/inflint 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exlint.io/inflint 的下载量有多少?

根据 npm 官方下载统计,@exlint.io/inflint 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,176 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@exlint.io/inflint 还在维护吗?

最新版本 2.1.1 发布于 2023/11/27(2 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/06/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。