Build the rule with the builder API
SpreadsheetApp.newConditionalFormatRule() returns a ConditionalFormatRuleBuilder. You chain condition methods onto it — whenNumberLessThan, whenTextContains, whenFormulaSatisfied, and about a dozen others — then setBackground or setFontColor for the visual output, then setRanges with an array of Range objects, then build() to produce the immutable rule.
The condition and the style are completely separate concerns on the builder. You can call setBackground without setFontColor, or both, or neither if you only want a custom text style. The one thing you cannot omit is setRanges — a rule with no ranges attached will throw when you try to commit it.
For formula-based rules, use whenFormulaSatisfied and pass a string starting with '='. The formula is evaluated relative to the top-left cell of each range, exactly the same way the Sheets UI works. I keep a comment in the script noting which cell the formula anchors to, because it will confuse you six months later.