conditional

Learn about the conditional extension point.

Name
Type
Description

ignorecase

bool

Makes all matches case-insensitive.

first

string

The antecedent of the statement.

second

string

The consequent of the statement.

vocab

bool

If false, disables all active vocabularies for this rule (default: true).

exceptions

array

An array of strings to be ignored.

extends: conditional
message: "'%s' has no definition"
level: error
scope: text
ignorecase: false
# Ensures that the existence of 'first'
# implies the existence of 'second'.
first: '\b([A-Z]{3,5})\b'
second: '(?:\b[A-Z][a-z]+ )+\(([A-Z]{3,5})\)'
# ... with the exception of these:
exceptions:
  - ABC
  - ADD

For example, consider the following text:

According to Wikipedia, the World Health Organization (WHO) is a specialized agency of the United Nations that is concerned with international public health. We can now use WHO because it has been defined, but we can’t use DAFB because people may not know what it represents. We can use DAFB when it’s presented as code, though.

Using the above text with our example rule yields the following:

conditional also takes an optional exceptions list. Any token listed as an exception won’t be flagged.

Regular expression lookarounds can be used to restrict the capture of the rule, allowing for more complex conditional statements. For example, the following rule will flag any MDX-style import that is not used:

See the regex guide for more information.

consistency capitalization