承接 moxio/captainhook-eslint 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moxio/captainhook-eslint

最新稳定版本:v1.0.1

Composer 安装命令:

composer require moxio/captainhook-eslint

包简介

Captain Hook Plugin to validate files using ESLint

README 文档

README

CI Latest Stable Version

moxio/captainhook-eslint

This project is a plugin for CaptainHook to check JavaScript files using ESLint in a git pre-commit hook. By default all *.js and *.mjs files are checked, and the commit is blocked when one or more errors are found. Warnings produced by ESLint are ignored.

Installation

Install as a development dependency using composer:

$ composer require --dev moxio/captainhook-eslint

Usage

Add ESLint validation as a pre-commit to your captainhook.json configuration file:

{
    "pre-commit": {
        "enabled": true,
        "actions": [
            {
                "action": "\\Moxio\\CaptainHook\\ESLint\\ESLintAction"
            }
        ]
    }
}

The action expects ESLint to be installed as a local NPM package (i.e. available at node_modules/.bin/eslint). It should be configured in a way that automatically finds the appropriate configuration, e.g. as an .eslintrc.* file or with the eslintConfig field in package.json.

Conditional usage

If you want to perform ESLint validation only when ESLint is installed (i.e. available at node_modules/.bin/eslint), you can add a corresponding condition to the action:

{
    "pre-commit": {
        "enabled": true,
        "actions": [
            {
                "action": "\\Moxio\\CaptainHook\\ESLint\\ESLintAction",
                "conditions": [
                    {
                        "exec": "\\Moxio\\CaptainHook\\ESLint\\Condition\\ESLintInstalled"
                    }
                ]
            }
        ]
    }
}

This may be useful in scenarios where you have a shared CaptainHook configuration file that is included both in projects that use ESLint and projects that don't. If ESLint is installed, the action is run. In projects without ESLint, the validation is skipped.

Configuring checked file extensions

By default, committed files with a .js or .mjs extension will be checked. If you want to customize this, e.g. to also validate TypeScript files, you can do so with the extensions option, which accepts an array with extensions of files to lint:

{
    "pre-commit": {
        "enabled": true,
        "actions": [
            {
                "action": "\\Moxio\\CaptainHook\\ESLint\\ESLintAction",
                "options": {
                    "extensions": [ "js", "mjs", "ts", "tsx" ]
                }
            }
        ]
    }
}

Versioning

This project adheres to Semantic Versioning.

License

This project is released under the MIT license.

统计信息

  • 总下载量: 44.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 11
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知