Skip to content

Commit

Permalink
feat: generate .editorconfig (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukyth authored Jun 7, 2022
1 parent aae2304 commit 81397e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@ async function generatePrettierConfig(options: Options): Promise<void> {
return generateConfigFile(options, './.prettierrc.js', style);
}

async function generateEditorConfig(options: Options): Promise<void> {
const config = `root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true
`;
return generateConfigFile(options, './.editorconfig', config);
}

export async function installDefaultTemplate(
options: Options
): Promise<boolean> {
Expand Down Expand Up @@ -320,6 +333,7 @@ export async function init(options: Options): Promise<boolean> {
await generateESLintConfig(options);
await generateESLintIgnore(options);
await generatePrettierConfig(options);
await generateEditorConfig(options);
await installDefaultTemplate(options);

// Run `npm install` after initial setup so `npm run lint` works right away.
Expand Down
1 change: 1 addition & 0 deletions test/kitchen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('🚰 kitchen sink', () => {
fs.accessSync(path.join(kitchenPath, '.eslintrc.json'));
fs.accessSync(path.join(kitchenPath, '.eslintignore'));
fs.accessSync(path.join(kitchenPath, '.prettierrc.js'));
fs.accessSync(path.join(kitchenPath, '.editorconfig'));

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

0 comments on commit 81397e0

Please sign in to comment.