require-gitlab-ci-rules-over-only-except
Require GitLab CI jobs to use rules instead of legacy only / except filters.
Targeted pattern scopeâ
This rule checks .gitlab-ci.yml (or .gitlab-ci.yaml) and reports lines using only: or except: keys.
What this rule reportsâ
This rule reports legacy only / except usage so teams can standardize on rules.
Why this rule existsâ
GitLab recommends rules for modern pipeline behavior and warns against mixing patterns that can create duplicate or confusing pipeline triggers.
â Incorrectâ
test:
script:
- npm test
only:
- branches
â Correctâ
test:
script:
- npm test
rules:
- if: $CI_COMMIT_BRANCH
ESLint flat config exampleâ
import repoPlugin from "eslint-plugin-repo";
export default [
repoPlugin.configs.gitlab,
{
plugins: { "repo-compliance": repoPlugin },
rules: {
"repo-compliance/require-gitlab-ci-rules-over-only-except": "warn",
},
},
];
When not to use itâ
Disable this rule only if you intentionally maintain legacy only / except syntax and accept the associated maintenance tradeoffs.
Rule catalog ID: R033