Skip to content

Commit 1cf8192

Browse files
committed
feat: uses single quotes for enum values, which is far more common for lint settings
1 parent f12270b commit 1cf8192

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

app-config-generate/src/index.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,37 @@ describe('TypeScript File Generation', () => {
161161
);
162162
});
163163

164+
it('uses single quotes in enum values', async () => {
165+
await withTempFiles(
166+
{
167+
'.app-config.meta.json5': `{
168+
generate: [{ file: "generated.d.ts" }]
169+
}`,
170+
'.app-config.schema.yaml': `
171+
type: object
172+
additionalProperties: false
173+
174+
properties:
175+
commit:
176+
type: string
177+
enum:
178+
- foo
179+
- foo-bar
180+
`,
181+
},
182+
async (dir) => {
183+
const output = await generateTypeFiles({ directory: dir('.') });
184+
185+
expect(output.length).toBe(1);
186+
187+
const config = await readFile(dir('generated.d.ts')).then((v) => v.toString());
188+
189+
expect(config).toMatch(`Foo = 'foo'`);
190+
expect(config).toMatch(`FooBar = 'foo-bar'`);
191+
},
192+
);
193+
});
194+
164195
it('creates an empty interface for config', async () => {
165196
await withTempFiles(
166197
{

app-config-generate/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export async function generateQuicktype(
137137
// this is a fix for quicktype, which adds an Object postfix, sometimes
138138
.map((line) => line.replace(`interface ${name}Object`, `interface ${name}`))
139139
.map((line) => line.replace(/: +Date/g, `: string`))
140+
.map((line) => line.replace(/= "([\w-]+)"/g, `= '$1'`))
140141
.map((line) => line.replace(/: +(\w)/g, ': $1'))
141142
);
142143
}

0 commit comments

Comments
 (0)