Total Complexity | 4 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | export default class SmileyConf { |
||
2 | static getSmileys() { |
||
3 | return JSINFO.SMILEY_CONF; |
||
|
|||
4 | } |
||
5 | |||
6 | /** |
||
7 | * Regex escape as recommended by MDN |
||
8 | * |
||
9 | * @param {string} string |
||
10 | * @returns {string} |
||
11 | */ |
||
12 | static escapeRegExp(string) { |
||
13 | return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string |
||
14 | } |
||
15 | |||
16 | /** |
||
17 | * Regex from conf |
||
18 | * |
||
19 | * @returns {RegExp} |
||
20 | */ |
||
21 | static getRegex() { |
||
22 | const smileyGroups = this.getSmileys().map(smiley => `(${SmileyConf.escapeRegExp(smiley.syntax)})`); |
||
23 | const regexstring = smileyGroups.join('|'); |
||
24 | return new RegExp(`${regexstring}`); |
||
25 | } |
||
26 | } |
||
27 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.