Skip to content

Commit ccbfd69

Browse files
committed
style: after prettier
1 parent 47dceb6 commit ccbfd69

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

src/location-tracker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Position} from '../types/index.d';
1+
import { Position } from '../types/index.d';
22

33
export class LocationTracker {
44
private readonly source: string;

test/test-core.spec.ts

+24-23
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ test('should be parse comment', t => {
1414
});
1515

1616
test('should be parse CDATA', t => {
17-
const tree = parser('<script><![CDATA[console.log(1);]]></script>', {xmlMode: true});
18-
const expected = [{tag: 'script', content: ['console.log(1);']}];
17+
const tree = parser('<script><![CDATA[console.log(1);]]></script>', { xmlMode: true });
18+
const expected = [{ tag: 'script', content: ['console.log(1);'] }];
1919
t.deepEqual(tree, expected);
2020
});
2121

@@ -52,7 +52,7 @@ test.skip('should be parse tag with object in attribute data witchout escape', t
5252
});
5353

5454
test.skip('should be parse tag with object in attribute data escape', t => {
55-
const json = JSON.stringify({button: {checkedView: 'extra'}});
55+
const json = JSON.stringify({ button: { checkedView: 'extra' } });
5656
const html = '<button data-bem="' + json + '"' +
5757
' type="submit"></button>';
5858
const tree = parser(html);
@@ -70,25 +70,25 @@ test.skip('should be parse tag with object in attribute data escape', t => {
7070

7171
test('should be parse isolated comment', t => {
7272
const tree = parser('<div><!--comment--></div>');
73-
const expected = [{tag: 'div', content: ['<!--comment-->']}];
73+
const expected = [{ tag: 'div', content: ['<!--comment-->'] }];
7474
t.deepEqual(tree, expected);
7575
});
7676

7777
test('should be parse comment before text content', t => {
7878
const tree = parser('<div><!--comment-->Text after comment</div>');
79-
const expected = [{tag: 'div', content: ['<!--comment-->', 'Text after comment']}];
79+
const expected = [{ tag: 'div', content: ['<!--comment-->', 'Text after comment'] }];
8080
t.deepEqual(tree, expected);
8181
});
8282

8383
test('should be parse comment after text content', t => {
8484
const tree = parser('<div>Text before comment.<!--comment--></div>');
85-
const expected = [{tag: 'div', content: ['Text before comment.', '<!--comment-->']}];
85+
const expected = [{ tag: 'div', content: ['Text before comment.', '<!--comment-->'] }];
8686
t.deepEqual(tree, expected);
8787
});
8888

8989
test('should be parse comment in the middle of text content', t => {
9090
const tree = parser('<div>Text surrounding <!--comment--> a comment.</div>');
91-
const expected = [{tag: 'div', content: ['Text surrounding ', '<!--comment-->', ' a comment.']}];
91+
const expected = [{ tag: 'div', content: ['Text surrounding ', '<!--comment-->', ' a comment.'] }];
9292
t.deepEqual(tree, expected);
9393
});
9494

@@ -101,7 +101,7 @@ test('should be parse doctype', t => {
101101
test('should be parse directive', t => {
102102
const options = {
103103
directives: [
104-
{name: '?php', start: '<', end: '>'}
104+
{ name: '?php', start: '<', end: '>' }
105105
]
106106
};
107107
const tree = parser('<?php echo "Hello word"; ?>', options);
@@ -112,7 +112,7 @@ test('should be parse directive', t => {
112112
test('should be parse regular expression directive', t => {
113113
const options = {
114114
directives: [
115-
{name: /\?(php|=).*/, start: '<', end: '>'}
115+
{ name: /\?(php|=).*/, start: '<', end: '>' }
116116
]
117117
};
118118
const tree1 = parser('<?php echo "Hello word"; ?>', options);
@@ -127,8 +127,8 @@ test('should be parse regular expression directive', t => {
127127
test('should be parse directives and tag', t => {
128128
const options = {
129129
directives: [
130-
{name: '!doctype', start: '<', end: '>'},
131-
{name: '?php', start: '<', end: '>'}
130+
{ name: '!doctype', start: '<', end: '>' },
131+
{ name: '?php', start: '<', end: '>' }
132132
]
133133
};
134134
const html = '<!doctype html><header><?php echo "Hello word"; ?></header><body>{{%njk test %}}</body>';
@@ -149,20 +149,20 @@ test('should be parse directives and tag', t => {
149149

150150
test('should be parse tag', t => {
151151
const tree = parser('<html></html>');
152-
const expected = [{tag: 'html'}];
152+
const expected = [{ tag: 'html' }];
153153
t.deepEqual(tree, expected);
154154
});
155155

156156
test('should be parse doctype and tag', t => {
157157
const tree = parser('<!doctype html><html></html>');
158-
const expected = ['<!doctype html>', {tag: 'html'}];
158+
const expected = ['<!doctype html>', { tag: 'html' }];
159159
t.deepEqual(tree, expected);
160160
});
161161

162162
test('should be parse tag attrs', t => {
163163
const tree = parser('<div id="id" class="class"></div>');
164164
const expected = [{
165-
tag: 'div', attrs: {id: 'id', class: 'class'}
165+
tag: 'div', attrs: { id: 'id', class: 'class' }
166166
}];
167167
t.deepEqual(tree, expected);
168168
});
@@ -175,30 +175,30 @@ test('should be parse text', t => {
175175

176176
test('should be parse text in content', t => {
177177
const tree = parser('<div>Text</div>');
178-
const expected = [{tag: 'div', content: ['Text']}];
178+
const expected = [{ tag: 'div', content: ['Text'] }];
179179
t.deepEqual(tree, expected);
180180
});
181181

182182
test('should be parse not a single node in tree', t => {
183183
const tree = parser('<span>Text1</span><span>Text2</span>Text3');
184184
const expected = [
185-
{tag: 'span', content: ['Text1']}, {tag: 'span', content: ['Text2']}, 'Text3'
185+
{ tag: 'span', content: ['Text1'] }, { tag: 'span', content: ['Text2'] }, 'Text3'
186186
];
187187
t.deepEqual(tree, expected);
188188
});
189189

190190
test('should be parse not a single node in parent content', t => {
191191
const tree = parser('<div><span>Text1</span><span>Text2</span>Text3</div>');
192192
const expected = [
193-
{tag: 'div', content: [{tag: 'span', content: ['Text1']}, {tag: 'span', content: ['Text2']}, 'Text3']}
193+
{ tag: 'div', content: [{ tag: 'span', content: ['Text1'] }, { tag: 'span', content: ['Text2'] }, 'Text3'] }
194194
];
195195
t.deepEqual(tree, expected);
196196
});
197197

198198
test('should be parse camelCase tag name', t => {
199199
const tree = parser('<mySuperTag></mySuperTag>');
200200
const expected = [
201-
{tag: 'mySuperTag'}
201+
{ tag: 'mySuperTag' }
202202
];
203203
t.deepEqual(tree, expected);
204204
});
@@ -207,7 +207,7 @@ test('should be parse simple contents are split with "<" in comment', t => {
207207
const html = '<a> /* width < 800px */ <hr /> test</a>';
208208
const tree = parser(html);
209209
const expected = [
210-
{tag: 'a', content: [' /* width < 800px */ ', {tag: 'hr'}, ' test']}
210+
{ tag: 'a', content: [' /* width < 800px */ ', { tag: 'hr' }, ' test'] }
211211
];
212212
t.deepEqual(tree, expected);
213213
});
@@ -216,7 +216,7 @@ test('should be parse style contents are split with "<" in comment', t => {
216216
const html = '<style> /* width < 800px */ @media (max-width: 800px) { /* selectors */} </style>';
217217
const tree = parser(html);
218218
const expected = [
219-
{tag: 'style', content: [' /* width < 800px */ @media (max-width: 800px) { /* selectors */} ']}
219+
{ tag: 'style', content: [' /* width < 800px */ @media (max-width: 800px) { /* selectors */} '] }
220220
];
221221
t.deepEqual(tree, expected);
222222
});
@@ -229,7 +229,8 @@ test('should be parse script contents are split with "<" in comment', t => {
229229
tag: 'script',
230230
content: [
231231
' var str = \'hey <form\'; if (!str.match(new RegExp(\'<(form|iframe)\', \'g\'))) { /* ... */ }'
232-
]}
232+
]
233+
}
233234
];
234235
t.deepEqual(tree, expected);
235236
});
@@ -243,7 +244,7 @@ test('should be not converting html entity name', t => {
243244

244245
test('should parse with source locations', t => {
245246
const html = '<h1>Test</h1>\n<p><b>Foo</b></p>';
246-
const tree = parser(html, {sourceLocations: true});
247+
const tree = parser(html, { sourceLocations: true });
247248
const expected = [
248249
{
249250
tag: 'h1',
@@ -312,6 +313,6 @@ test.only('should parse with input in button', t => {
312313
]
313314
}
314315
];
315-
console.log({tree});
316+
console.log({ tree });
316317
t.deepEqual(tree, expected);
317318
});

types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ParserOptions} from 'htmlparser2';
1+
import { ParserOptions } from 'htmlparser2';
22

33
declare const parser: (html: string, options?: Options) => Node[];
44

xo.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ module.exports = {
44
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
55
'ava/no-skip-test': 'off',
66
'ava/no-only-test': 'off',
7-
'object-curly-spacing': ['error','always']
7+
'object-curly-spacing': ['error', 'always']
88
}
99
};

0 commit comments

Comments
 (0)