Fix linting

This commit is contained in:
Sindre Sorhus 2018-02-15 00:41:45 +07:00
parent 576d8d2171
commit 12d1276b36
2 changed files with 4 additions and 3 deletions

View file

@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-unsafe-regex */
'use strict'; 'use strict';
const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;

View file

@ -126,14 +126,14 @@ test('correctly parse escape in parameters (bug #177 comment 318622809)', t => {
test('correctly parses unicode/hex escapes', t => { test('correctly parses unicode/hex escapes', t => {
const ctx = m.constructor({level: 0}); const ctx = m.constructor({level: 0});
t.is(ctx`\u0078ylophones are fo\x78y! {magenta.inverse \u0078ylophones are fo\x78y!}`, t.is(ctx`\u0078ylophones are fo\u0078y! {magenta.inverse \u0078ylophones are fo\u0078y!}`,
'xylophones are foxy! xylophones are foxy!'); 'xylophones are foxy! xylophones are foxy!');
}); });
test('correctly parses string arguments', t => { test('correctly parses string arguments', t => {
const ctx = m.constructor({level: 3}); const ctx = m.constructor({level: 3});
t.is(ctx`{keyword('black').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); t.is(ctx`{keyword('black').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m');
t.is(ctx`{keyword('blac\x6B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); t.is(ctx`{keyword('blac\u006B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m');
t.is(ctx`{keyword('blac\u006B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); t.is(ctx`{keyword('blac\u006B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m');
}); });
@ -159,7 +159,7 @@ test('throws if an extra unescaped } is found', t => {
test('should not parse upper-case escapes', t => { test('should not parse upper-case escapes', t => {
const ctx = m.constructor({level: 0}); const ctx = m.constructor({level: 0});
t.is(ctx`\N\n\T\t\X07\x07\U000A\u000A\U000a\u000a`, 'N\nT\tX07\x07U000A\u000AU000a\u000A'); t.is(ctx`\N\n\T\t\X07\u0007\U000A\u000A\U000a\u000a`, 'N\nT\tX07\u0007U000A\u000AU000a\u000A');
}); });
test('should properly handle undefined template interpolated values', t => { test('should properly handle undefined template interpolated values', t => {