(point))))
(defvar js--treesit-indent-rules
- `((javascript
- (no-node (js--treesit-backward-up-list) ,js-indent-level)
- ((node-is "}") parent-bol 0)
- ((node-is ")") parent-bol 0)
- ((node-is "]") parent-bol 0)
- ((node-is ">") parent-bol 0)
- ((node-is "\\.") parent-bol ,js-indent-level)
- ((parent-is "named_imports") parent-bol ,js-indent-level)
- ((parent-is "statement_block") parent-bol ,js-indent-level)
- ((parent-is "variable_declarator") parent-bol ,js-indent-level)
- ((parent-is "arguments") parent-bol ,js-indent-level)
- ((parent-is "array") parent-bol ,js-indent-level)
- ((parent-is "formal_parameters") parent-bol ,js-indent-level)
- ((parent-is "template_substitution") parent-bol ,js-indent-level)
- ((parent-is "object_pattern") parent-bol ,js-indent-level)
- ((parent-is "object") parent-bol ,js-indent-level)
- ((parent-is "arrow_function") parent-bol ,js-indent-level)
- ((parent-is "parenthesized_expression") parent-bol ,js-indent-level)
-
- ;; JSX
- ((parent-is "jsx_opening_element") parent ,js-indent-level)
- ((node-is "jsx_closing_element") parent 0)
- ((node-is "jsx_text") parent ,js-indent-level)
- ((parent-is "jsx_element") parent ,js-indent-level)
- ((node-is "/") parent 0)
- ((parent-is "jsx_self_closing_element") parent ,js-indent-level))))
+ (let ((switch-case (rx "switch_" (or "case" "default"))))
+ `((javascript
+ (no-node (js--treesit-backward-up-list) ,js-indent-level)
+ ((node-is "}") parent-bol 0)
+ ((node-is ")") parent-bol 0)
+ ((node-is "]") parent-bol 0)
+ ((node-is ">") parent-bol 0)
+ ((node-is "\\.") parent-bol ,js-indent-level)
+ ((node-is ,switch-case) parent-bol 0)
+ ;; "{" on the newline.
+ ((node-is "statement_block") parent-bol ,js-indent-level)
+ ((parent-is "named_imports") parent-bol ,js-indent-level)
+ ((parent-is "statement_block") parent-bol ,js-indent-level)
+ ((parent-is "variable_declarator") parent-bol ,js-indent-level)
+ ((parent-is "arguments") parent-bol ,js-indent-level)
+ ((parent-is "array") parent-bol ,js-indent-level)
+ ((parent-is "formal_parameters") parent-bol ,js-indent-level)
+ ((parent-is "template_substitution") parent-bol ,js-indent-level)
+ ((parent-is "object_pattern") parent-bol ,js-indent-level)
+ ((parent-is "object") parent-bol ,js-indent-level)
+ ((parent-is "pair") parent-bol ,js-indent-level)
+ ((parent-is "arrow_function") parent-bol ,js-indent-level)
+ ((parent-is "parenthesized_expression") parent-bol ,js-indent-level)
+ ((parent-is "class_body") parent-bol ,js-indent-level)
+ ((parent-is ,switch-case) parent-bol ,js-indent-level)
+
+ ;; JSX
+ ((parent-is "jsx_opening_element") parent ,js-indent-level)
+ ((node-is "jsx_closing_element") parent 0)
+ ((node-is "jsx_text") parent ,js-indent-level)
+ ((parent-is "jsx_element") parent ,js-indent-level)
+ ((node-is "/") parent 0)
+ ((parent-is "jsx_self_closing_element") parent ,js-indent-level)))))
(defvar js--treesit-keywords
'("as" "async" "await" "break" "case" "catch" "class" "const" "continue"