no-post-if-without-post
Rule catalog ID: R046
Targeted pattern scopeโ
Action metadata runs.post-if declarations.
What this rule reportsโ
Reports runs.post-if when runs.post is missing.
Why this rule existsโ
post-if has no effect without a matching post hook.
โ Incorrectโ
runs:
using: node20
main: dist/index.js
post-if: runner.os == 'Linux'
โ Correctโ
runs:
using: node20
main: dist/index.js
post: dist/cleanup.js
post-if: runner.os == 'Linux'
Behavior and migration notesโ
The autofixer removes the orphaned runs.post-if line because that key has no effect without runs.post. If you intended a guarded cleanup hook, add runs.post manually instead of relying on the fix alone.
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/no-post-if-without-post": "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.