Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2347,6 +2347,11 @@ if (Right.is(tok::l_paren) && Line.MustBeDeclaration && Left.Tok.getIdentifierInfo()) return false; + // Valid JS method names can include keywords, e.g. `foo.delete()` or + // `bar.instanceof()`. + if (Right.is(tok::l_paren) && Left.Tok.getIdentifierInfo() && + Left.Previous && Left.Previous->is(tok::period)) + return false; if ((Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in, tok::kw_const) || // "of" is only a keyword if it appears after another identifier Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -232,6 +232,7 @@ verifyFormat("x.var() = 1;"); verifyFormat("x.for() = 1;"); verifyFormat("x.as() = 1;"); + verifyFormat("x.instanceof() = 1;"); verifyFormat("x = {\n" " a: 12,\n" " interface: 1,\n"