Subject: bug#41676: 27.0.91; js-beginning-of-defun doesn't handle ES2015 class and arrow functions

From: Brian Leung <[email-masked]>
Date: Tue, 2 Jun 2020 15:05:52 -0700

In the following ES2015 file:

import * as React from "react";
import { render } from "react-dom";
import SearchParams from "./SearchParams";

class Abc extends React.Component {}

const App = () => {
  return (
    <div>
      <h1 id="5">Hi</h1>
    </div>
  );
};

function abc(x) {
  return 42;
}

const def = () => {
  return 1;
};

render(<App />, document.getElementById("root"));

If you start at the end and use M-: js-beginning-of-defun repeatedly
(necessary since in bug #41469 it's clear that
beginning-of-defun-function is c-beginning-of-defun), point stops at the
ES5 function declaration of abc and then at the imports section,
skipping the arrow functions and the class declaration.

In GNU Emacs 27.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20)
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: NixOS 20.09 (Nightingale)