Skip to content

Commit 81397e0

Browse files
authored
feat: generate .editorconfig (#500)
1 parent aae2304 commit 81397e0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/init.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,19 @@ async function generatePrettierConfig(options: Options): Promise<void> {
251251
return generateConfigFile(options, './.prettierrc.js', style);
252252
}
253253

254+
async function generateEditorConfig(options: Options): Promise<void> {
255+
const config = `root = true
256+
257+
[*]
258+
indent_style = space
259+
indent_size = 2
260+
end_of_line = lf
261+
charset = utf-8
262+
insert_final_newline = true
263+
`;
264+
return generateConfigFile(options, './.editorconfig', config);
265+
}
266+
254267
export async function installDefaultTemplate(
255268
options: Options
256269
): Promise<boolean> {
@@ -320,6 +333,7 @@ export async function init(options: Options): Promise<boolean> {
320333
await generateESLintConfig(options);
321334
await generateESLintIgnore(options);
322335
await generatePrettierConfig(options);
336+
await generateEditorConfig(options);
323337
await installDefaultTemplate(options);
324338

325339
// Run `npm install` after initial setup so `npm run lint` works right away.

test/kitchen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ describe('🚰 kitchen sink', () => {
6161
fs.accessSync(path.join(kitchenPath, '.eslintrc.json'));
6262
fs.accessSync(path.join(kitchenPath, '.eslintignore'));
6363
fs.accessSync(path.join(kitchenPath, '.prettierrc.js'));
64+
fs.accessSync(path.join(kitchenPath, '.editorconfig'));
6465

6566
// Compilation shouldn't have happened. Hence no `build` directory.
6667
const dirContents = fs.readdirSync(kitchenPath);

0 commit comments

Comments
 (0)