source: imaps-frontend/node_modules/eslint/lib/shared/ast-utils.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 910 bytes
Line 
1/**
2 * @fileoverview Common utils for AST.
3 *
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`.
6 *
7 * @author Toru Nagashima <https://github.com/mysticatea>
8 */
9"use strict";
10
11const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u;
12const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
13const shebangPattern = /^#!([^\r\n]+)/u;
14
15/**
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
19 */
20function createGlobalLinebreakMatcher() {
21 return new RegExp(lineBreakPattern.source, "gu");
22}
23
24module.exports = {
25 breakableTypePattern,
26 lineBreakPattern,
27 createGlobalLinebreakMatcher,
28 shebangPattern
29};
Note: See TracBrowser for help on using the repository browser.