Skip to content

Commit 7d186bf

Browse files
committed
refactor: Created printers.ts (1)
1 parent f04e498 commit 7d186bf

6 files changed

Lines changed: 12 additions & 21 deletions

File tree

src/main.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import type { Plugin, Printer } from 'prettier';
1+
import type { Plugin } from 'prettier';
22

33
import { languages } from './languages.js';
44
import { options } from './options.js';
55
import { parsers } from './parsers.js';
6-
import { printer } from './print/index.js';
7-
import { type NodeType, PRINTER_NAME } from './utils/index.js';
8-
9-
const printers: Record<string, Printer<NodeType>> = {
10-
[PRINTER_NAME]: printer,
11-
};
6+
import { printers } from './printers.js';
7+
import type { NodeType } from './utils/index.js';
128

139
const plugin: Plugin<NodeType> = {
1410
languages,

src/options.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ const templateExportDefault: BooleanSupportOption = {
1818
type: 'boolean',
1919
};
2020

21-
/**
22-
* Extracts a valid `templateSingleQuote` option out of the provided options. If
23-
* `templateSingleQuote` is defined, it will be used, otherwise the value for
24-
* `singleQuote` will be inherited.
25-
*/
26-
export function getTemplateSingleQuote(options: PluginOptions): boolean {
27-
const { singleQuote, templateSingleQuote } = options;
28-
return typeof templateSingleQuote === 'boolean'
29-
? templateSingleQuote
30-
: singleQuote;
31-
}
32-
3321
const templateSingleQuote: BooleanSupportOption = {
3422
category: 'Format',
3523
description:

src/printers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { Printer } from 'prettier';
2+
3+
import { printer } from './printers/index.js';
4+
import { type NodeType, PRINTER_NAME } from './utils/index.js';
5+
6+
export const printers: Record<string, Printer<NodeType>> = {
7+
[PRINTER_NAME]: printer,
8+
};
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Options as PrettierOptions } from 'prettier';
22
import { doc } from 'prettier';
33

44
import type { PluginOptions } from '../options.js';
5-
import { getTemplateSingleQuote } from '../options.js';
65
import { flattenDoc } from '../utils/doc.js';
76
import { TEMPLATE_TAG_CLOSE, TEMPLATE_TAG_OPEN } from '../utils/index.js';
87

@@ -30,7 +29,7 @@ export async function printTemplateContent(
3029
return await textToDoc(text.trim(), {
3130
...options,
3231
parser: 'glimmer',
33-
singleQuote: getTemplateSingleQuote(options),
32+
singleQuote: options.templateSingleQuote ?? options.singleQuote,
3433
});
3534
}
3635

0 commit comments

Comments
 (0)