2 * @fileoverview Common utils for AST.
4 * This file contains only shared items for core and rules.
5 * If you make a utility for rules, please see `../rules/utils/ast-utils.js`.
7 * @author Toru Nagashima <https://github.com/mysticatea>
11 const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u;
12 const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
13 const shebangPattern = /^#!([^\r\n]+)/u;
16 * Creates a version of the `lineBreakPattern` regex with the global flag.
17 * Global regexes are mutable, so this needs to be a function instead of a constant.
18 * @returns {RegExp} A global regular expression that matches line terminators
20 function createGlobalLinebreakMatcher() {
21 return new RegExp(lineBreakPattern.source, "gu");
27 createGlobalLinebreakMatcher,