Skip to content

Commit c796b87

Browse files
committed
refactor: Created utils/index.ts
1 parent d4bf8cf commit c796b87

7 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/config.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import type { Node } from '@babel/types';
21
import type { Parser, Plugin, Printer, SupportLanguage } from 'prettier';
32

4-
import { PARSER_NAME, PRINTER_NAME } from './config.js';
53
import { options } from './options.js';
64
import { parser } from './parse/index.js';
75
import { printer } from './print/index.js';
6+
import { type NodeType, PARSER_NAME, PRINTER_NAME } from './utils/index.js';
87

98
const languages: SupportLanguage[] = [
109
{
@@ -25,15 +24,15 @@ const languages: SupportLanguage[] = [
2524
},
2625
];
2726

28-
const parsers: Record<string, Parser<Node | undefined>> = {
27+
const parsers: Record<string, Parser<NodeType>> = {
2928
[PARSER_NAME]: parser,
3029
};
3130

32-
const printers: Record<string, Printer<Node | undefined>> = {
31+
const printers: Record<string, Printer<NodeType>> = {
3332
[PRINTER_NAME]: printer,
3433
};
3534

36-
const plugin: Plugin<Node | undefined> = {
35+
const plugin: Plugin<NodeType> = {
3736
languages,
3837
parsers,
3938
printers,

src/parse/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import type {
99
import type { Parser } from 'prettier';
1010
import { parsers as babelParsers } from 'prettier/plugins/babel.js';
1111

12-
import { PRINTER_NAME } from '../config.js';
1312
import type { Options } from '../options.js';
1413
import { assert } from '../utils/assert.js';
14+
import { PRINTER_NAME } from '../utils/index.js';
1515
import { preprocess, type Template } from './preprocess.js';
1616

1717
const typescript = babelParsers['babel-ts'] as Parser<Node | undefined>;

src/print/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import type {
77
} from 'prettier';
88
import { printers as estreePrinters } from 'prettier/plugins/estree.js';
99

10-
import { TEMPLATE_TAG_CLOSE, TEMPLATE_TAG_OPEN } from '../config.js';
1110
import type { Options } from '../options.js';
1211
import {
1312
isGlimmerTemplate,
1413
isGlimmerTemplateParent,
1514
} from '../types/glimmer.js';
1615
import { assert } from '../utils/assert.js';
16+
import { TEMPLATE_TAG_CLOSE, TEMPLATE_TAG_OPEN } from '../utils/index.js';
1717
import {
1818
fixPreviousPrint,
1919
saveCurrentPrintOnSiblingNode,

src/print/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { Options as PrettierOptions } from 'prettier';
22
import { doc } from 'prettier';
33

4-
import { TEMPLATE_TAG_CLOSE, TEMPLATE_TAG_OPEN } from '../config.js';
54
import type { Options } from '../options.js';
65
import { getTemplateSingleQuote } from '../options.js';
76
import { flattenDoc } from '../utils/doc.js';
7+
import { TEMPLATE_TAG_CLOSE, TEMPLATE_TAG_OPEN } from '../utils/index.js';
88

99
const {
1010
builders: { group, hardline, indent, softline },

src/utils/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Node } from '@babel/types';
2+
3+
export type NodeType = Node | undefined;
4+
5+
export const PARSER_NAME = 'ember-template-tag';
6+
export const PRINTER_NAME = 'ember-template-tag-estree';
7+
8+
export const TEMPLATE_TAG_OPEN = '<template>';
9+
export const TEMPLATE_TAG_CLOSE = '</template>';

tests/helpers/format.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { Plugin } from 'prettier';
22
import { format as prettierFormat } from 'prettier';
33

4-
import { PARSER_NAME } from '../../src/config.js';
54
import plugin from '../../src/main.js';
65
import type { Options } from '../../src/options.js';
76

87
const DEFAULT_OPTIONS: Partial<Options> = {
9-
parser: PARSER_NAME,
8+
parser: 'ember-template-tag',
109
plugins: [plugin as Plugin],
1110
};
1211

0 commit comments

Comments
 (0)