Skip to main content

prefer-file-extension

Rule catalog ID: R020

Targeted pattern scopeโ€‹

GitHub Actions workflow YAML files under .github/workflows/.

What this rule reportsโ€‹

This rule reports workflow files whose extension does not match the configured preference.

Why this rule existsโ€‹

Using one workflow file extension consistently keeps repositories easier to scan, search, and script against. It also avoids needless churn from mixed .yml and .yaml naming styles.

โŒ Incorrectโ€‹

# .github/workflows/release.yaml
name: Release
on:
workflow_dispatch:

โœ… Correctโ€‹

# .github/workflows/release.yml
name: Release
on:
workflow_dispatch:

Behavior and migration notesโ€‹

Default behaviorโ€‹

With the default configuration, this rule expects workflow files to use the .yml extension.

{ "extension": "yaml" }โ€‹

Use this option to enforce .yaml instead.

{ "caseSensitive": false }โ€‹

Use this option when you want extension matching to ignore case differences in repository paths.

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-file-extension": "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.

Further readingโ€‹