Adding a TODO comment that will be addressed in the future should have a corresponding ticket (AKA issue) in the project backlog, so the team doesn't lose track of pending work.
Type: RegExp | string
This option is required, and controls what the ticket pattern is to match against. Expects a regex string.
For example, let's say you're using Jira and your ticket IDs are prefixed with PROJ followed by a number (e.g PROJ-123), you would configure this rule like:
{
"rules": {
"todo-plz/ticket-ref": ["error", { "pattern": "PROJ-[0-9]+" }]
}
}Examples of incorrect code for this rule when using the above options:
// TODO: Connect to the API
// TODO (ABC-123): Connect to the API
// TODO (ABC): Connect to the APIExamples of correct code for this rule when using the above options:
// TODO (PROJ-123): Connect to the APIType: Array<string>
Optional. Change what terms to require the ticket reference on. Defaults to: ["TODO"]
{
"rules": {
"todo-plz/ticket-ref": [
"error",
{ "pattern": "PROJ-[0-9]+", "terms": ["FIXME", "TODO"] }
]
}
}Examples of incorrect code for this rule when using the above options:
// TODO: Connect to the API
// FIXME: Connect to the APIExamples of correct code for this rule when using the above options:
// TODO (PROJ-123): Connect to the API
// FIXME (PROJ-123): Connect to the API
// HELLO: This isn't a term targeted by the lint ruleType: RegExp | string
Optional. Override the overall comment pattern that matches both term and ticket. When used, term and pattern options are ignored. Expects a regex, or a string that can be passed to new RegExp.
For example, let's say you expect a different comment pattern such as TODO: [PROJ-123], you would configure this rule like this:
export default [
{
rules: {
"todo-plz/ticket-ref": [
"error",
{ commentPattern: /TODO:\s\[(PROJ-[0-9]+[,\s]*)+\]/ },
],
},
},
];If you use a legacy JSON config, you would configure it like this:
{
"rules": {
"todo-plz/ticket-ref": [
"error",
{ "commentPattern": /TODO:\s\[(PROJ-[0-9]+[,\s]*)+\]/ }
]
}
}Examples of incorrect code for this rule when using the above options:
// TODO (PROJ-456): Connect to the API
// TODO [PROJ-456]: Connect to the APIExamples of correct code for this rule when using the above options:
// TODO: [PROJ-456] Connect to the APIType: string
Optional. Override the error message portion that provides guidance on the expected ticket pattern. Defaults to: Ticket pattern: <pattern>
{
"rules": {
"todo-plz/ticket-ref": [
"error",
{
"pattern": "PROJ-[0-9]+",
"description": "For example: `TODO (PROJ-123):`"
}
]
}
}