Skip to content

Commit 4578e35

Browse files
committed
Update eslint and add padding lines
1 parent b76f9c7 commit 4578e35

File tree

15 files changed

+397
-342
lines changed

15 files changed

+397
-342
lines changed

src/modules/globalifySelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function globalifySelector(selector: string) {
1717
if (selectorPart.startsWith(':local')) {
1818
return selectorPart.replace(/:local\((.+?)\)/g, '$1');
1919
}
20+
2021
if (selectorPart.startsWith(':global')) {
2122
return selectorPart;
2223
}

src/modules/language.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,21 @@ export const getLanguage = (
2626
if (typeof attributes.lang !== 'string') {
2727
throw new Error('lang attribute must be string');
2828
}
29+
2930
lang = attributes.lang;
3031
} else if (attributes.type) {
3132
// istanbul ignore if
3233
if (typeof attributes.type !== 'string') {
3334
throw new Error('type attribute must be string');
3435
}
36+
3537
lang = attributes.type.replace(/^(text|application)\/(.*)$/, '$2');
3638
} else if (attributes.src) {
3739
// istanbul ignore if
3840
if (typeof attributes.src !== 'string') {
3941
throw new Error('src attribute must be string');
4042
}
43+
4144
const parts = basename(attributes.src).split('.');
4245

4346
lang = parts.length > 1 ? parts.pop() : defaultLang;

src/modules/parseFile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const parseFile = async (
3333
if (typeof attributes.src !== 'string') {
3434
throw new Error('src attribute must be string');
3535
}
36+
3637
let path = attributes.src;
3738

3839
/** Only try to get local files (path starts with ./ or ../) */

src/transformers/typescript.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ function createImportTransformerFromProgram(program: ts.Program) {
165165
continue;
166166
}
167167
}
168+
168169
newElements.push(spec);
169170
}
170171

@@ -302,6 +303,7 @@ const transformer: Transformer<Options.Typescript> = ({
302303
if (options.tsconfigFile !== false || options.tsconfigDirectory) {
303304
const fileDirectory = (options.tsconfigDirectory ||
304305
dirname(filename)) as string;
306+
305307
const tsconfigFile =
306308
options.tsconfigFile ||
307309
ts.findConfigFile(fileDirectory, ts.sys.fileExists);
@@ -373,6 +375,7 @@ const transformer: Transformer<Options.Typescript> = ({
373375
const hasError = diagnostics.some(
374376
(d) => d.category === ts.DiagnosticCategory.Error,
375377
);
378+
376379
const formattedDiagnostics = formatDiagnostics(diagnostics, basePath);
377380

378381
console.log(formattedDiagnostics);

test/autoProcess/autoProcess.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ describe('options', () => {
3737
const input = `<template lang="customTransformer">${getFixtureContent(
3838
'template.custom',
3939
)}</template>`;
40+
4041
const opts = getAutoPreprocess({
4142
customTransformer({ content }) {
4243
content = content.replace('foo', 'bar').toString().trim();
4344

4445
return { code: content, map: null };
4546
},
4647
});
48+
4749
const preprocessed = await preprocess(input, opts);
4850

4951
expect(preprocessed.toString()).toBe('bar');
@@ -71,6 +73,7 @@ describe('options', () => {
7173
return content.toLowerCase();
7274
},
7375
});
76+
7477
const preprocessed = await preprocess(input, opts);
7578

7679
expect(preprocessed.toString()).toBe(input.toLowerCase());
@@ -126,6 +129,7 @@ describe('options', () => {
126129
return { code: '', map: '' };
127130
},
128131
});
132+
129133
const preprocessed = await preprocess(input, opts);
130134

131135
expect(preprocessed.toString()).toContain(
@@ -154,6 +158,7 @@ describe('options', () => {
154158
mock: () => ({ code: 'mock' }),
155159
},
156160
});
161+
157162
const preprocessed = await preprocess(input, opts);
158163

159164
expect(preprocessed.toString()).toBe(`<script lang="mock">mock</script>`);

test/autoProcess/script.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const SCRIPT_LANGS: Array<[string, string, object?]> = [
99
{ tsconfigFile: false, compilerOptions: { module: 'es2015' } },
1010
],
1111
];
12+
1213
const EXPECTED_SCRIPT = getFixtureContent('script.js');
1314

1415
SCRIPT_LANGS.forEach(([lang, ext, langOptions]) => {
@@ -22,6 +23,7 @@ SCRIPT_LANGS.forEach(([lang, ext, langOptions]) => {
2223
<div></div>
2324
<script src="./fixtures/script.${ext}"></script>
2425
`;
26+
2527
const opts = getAutoPreprocess({
2628
[lang]: false,
2729
});
@@ -33,6 +35,7 @@ SCRIPT_LANGS.forEach(([lang, ext, langOptions]) => {
3335
const opts = getAutoPreprocess({
3436
[lang]: langOptions,
3537
});
38+
3639
const preprocessed = await preprocess(template, opts);
3740

3841
expect(preprocessed.toString()).toContain(EXPECTED_SCRIPT);

test/autoProcess/style.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ STYLE_LANGS.forEach(([lang, ext]) => {
5757
it(`should return empty if content is empty`, async () => {
5858
const templateExternal = `<div></div><style src="./potato/style.${ext}"></style>`;
5959
const opts = getAutoPreprocess({
60-
[lang]: { sourceMap: false, sourcemap: false, map: false },
60+
[lang]: {
61+
sourceMap: false,
62+
sourcemap: false,
63+
map: false,
64+
},
6165
});
66+
6267
const preprocessed = await preprocess(templateExternal, opts);
6368

6469
expect(preprocessed.toString()).toMatch(templateExternal);

test/transformers/babel.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ describe('transformer - babel', () => {
2222
let foo = {}
2323
$: bar = foo?.b ?? 120
2424
</script>`;
25+
2526
const opts = getAutoPreprocess({
2627
babel: BABEL_CONFIG,
2728
});
29+
2830
const preprocessed = await preprocess(template, opts);
2931

3032
expect(preprocessed.code).toMatchInlineSnapshot(`

test/transformers/globalStyle.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ describe('transformer - globalStyle', () => {
1111
sourceMap: true,
1212
},
1313
});
14+
1415
const preprocessed = await preprocess(template, opts);
1516

1617
expect(preprocessed.toString()).toContain(`sourceMappingURL`);
@@ -40,6 +41,7 @@ describe('transformer - globalStyle', () => {
4041
const template = `<style global>
4142
@keyframes a {from{} to{}}@keyframes -global-b {from{} to{}}
4243
</style>`;
44+
4345
const opts = autoProcess();
4446
const preprocessed = await preprocess(template, opts);
4547

@@ -84,6 +86,7 @@ describe('transformer - globalStyle', () => {
8486
sourceMap: true,
8587
},
8688
});
89+
8790
const preprocessed = await preprocess(template, opts);
8891

8992
expect(preprocessed.toString()).toContain(`sourceMappingURL`);
@@ -176,6 +179,7 @@ describe('transformer - globalStyle', () => {
176179
it('removes rules with only :global as its selector', async () => {
177180
const template =
178181
'<style>:global{/*comment*/}:global,div{/*comment*/}</style>';
182+
179183
const opts = autoProcess();
180184
const preprocessed = await preprocess(template, opts);
181185

test/transformers/postcss.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('transformer - postcss', () => {
3737
],
3838
},
3939
});
40+
4041
const preprocessed = await preprocess(template, optsWithoutConfigFile);
4142

4243
expect(preprocessed.toString()).toMatch(/-webkit-/);
@@ -53,6 +54,7 @@ describe('transformer - postcss', () => {
5354
],
5455
},
5556
});
57+
5658
const preprocessed = await preprocess(templateSass, optsWithoutConfigFile);
5759

5860
expect(preprocessed.toString()).toMatch(/-webkit-/);
@@ -79,6 +81,7 @@ describe('transformer - postcss', () => {
7981
plugins: [require('postcss-easy-import')],
8082
},
8183
});
84+
8285
const preprocessed = await preprocess(template, opts);
8386

8487
expect(preprocessed.dependencies).toContain(
@@ -91,12 +94,14 @@ describe('transformer - postcss', () => {
9194
div
9295
color: red
9396
</style>`;
97+
9498
const opts = getAutoPreprocess({
9599
postcss: {
96100
parser: require('sugarss'),
97101
plugins: [require('postcss-easy-import')],
98102
},
99103
});
104+
100105
const preprocessed = await preprocess(template, opts);
101106

102107
expect(preprocessed.toString()).toContain(`div {

test/transformers/pug.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('transformer - pug', () => {
99
main
1010
header
1111
h1</template>`;
12+
1213
const opts = getAutoPreprocess();
1314
const preprocessed = await preprocess(template, opts);
1415

@@ -20,6 +21,7 @@ main
2021
main
2122
\theader
2223
\t\th1</template>`;
24+
2325
const opts = getAutoPreprocess();
2426
const preprocessed = await preprocess(template, opts);
2527

test/transformers/replace.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('transformer - regex', () => {
4949
@endawait`
5050
.trim()
5151
.repeat(2);
52+
5253
const opts = autoProcess({ replace: options });
5354
const preprocessed = await preprocess(template, opts);
5455

test/transformers/scss.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('transformer - scss', () => {
3737
data: '$color:red;div{color:$color}',
3838
},
3939
});
40+
4041
const preprocessed = await preprocess(template, opts);
4142

4243
expect(preprocessed.toString()).toContain('red');
@@ -59,6 +60,7 @@ describe('transformer - scss', () => {
5960
implementation,
6061
},
6162
});
63+
6264
const preprocessed = await preprocess(template, opts);
6365

6466
expect(preprocessed.toString()).toContain('div#red{color:red}');
@@ -72,6 +74,7 @@ describe('transformer - scss', () => {
7274
renderSync: true,
7375
},
7476
});
77+
7578
const preprocessed = await preprocess(template, opts);
7679

7780
expect(preprocessed.toString()).toContain('blue');
@@ -84,6 +87,7 @@ describe('transformer - scss', () => {
8487
renderSync: true,
8588
},
8689
});
90+
8791
const preprocessed = await preprocess(template, opts);
8892

8993
expect(preprocessed.dependencies).toContain(
@@ -99,6 +103,7 @@ describe('transformer - scss', () => {
99103
renderSync: true,
100104
},
101105
});
106+
102107
const preprocessed = await preprocess(template, opts);
103108

104109
expect(preprocessed.toString()).toContain('div#green{color:green}');

test/transformers/typescript.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe('transformer - typescript', () => {
7878
tsconfigDirectory: './test/fixtures',
7979
},
8080
});
81+
8182
const preprocessed = await preprocess(template, opts);
8283

8384
expect(preprocessed.toString()).toContain(EXPECTED_SCRIPT);
@@ -89,6 +90,7 @@ describe('transformer - typescript', () => {
8990
tsconfigFile: './test/fixtures/tsconfig.json',
9091
},
9192
});
93+
9294
const preprocessed = await preprocess(template, opts);
9395

9496
expect(preprocessed.toString()).toContain(EXPECTED_SCRIPT);
@@ -124,6 +126,7 @@ describe('transformer - typescript', () => {
124126
},
125127
},
126128
});
129+
127130
const { code } = await preprocess(template, opts);
128131

129132
return expect(code).toContain(getFixtureContent('script.js'));

0 commit comments

Comments
 (0)