prefer-inputs-context
Rule catalog ID: R033
Targeted pattern scopeโ
GitHub Actions workflow YAML files that define workflow_dispatch and reference github.event.inputs in expressions.
What this rule reportsโ
This rule reports github.event.inputs.* references in workflow_dispatch workflows and prefers the shorter inputs.* context instead.
Why this rule existsโ
GitHub documents that inputs and github.event.inputs expose the same manual-dispatch values, but inputs preserves Boolean values as Booleans instead of converting them to strings. Using inputs also makes workflow expressions shorter and easier to read.
โ Incorrectโ
on:
workflow_dispatch:
inputs:
dry_run:
description: Run validation only
required: true
type: boolean
jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.dry_run }}
steps:
- run: echo release
โ Correctโ
on:
workflow_dispatch:
inputs:
dry_run:
description: Run validation only
required: true
type: boolean
jobs:
release:
runs-on: ubuntu-latest
if: ${{ inputs.dry_run }}
steps:
- run: echo release
Behavior and migration notesโ
The autofixer rewrites github.event.inputs. references to inputs. within the same scalar value. It only runs in workflows that actually declare workflow_dispatch, so unrelated files are left unchanged.
Additional examplesโ
For larger repositories, this rule is often enabled together with one of the published presets so violations are caught in pull requests before workflow changes are merged.
ESLint flat config exampleโ
import githubActions from "eslint-plugin-github-actions-2";
export default [
{
files: ["**/*.{yml,yaml}"],
plugins: {
"github-actions": githubActions,
},
rules: {
"github-actions/prefer-inputs-context": "error",
},
},
];
When not to use itโ
You can disable this rule when its policy does not match your repository standards, or when equivalent enforcement is already handled by another policy tool.