Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate .editorconfig #500

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,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 @@ -309,6 +322,7 @@ export async function init(options: Options): Promise<boolean> {
await generateTsConfig(options);
await generateESLintConfig(options);
await generatePrettierConfig(options);
await generateEditorConfig(options);
await installDefaultTemplate(options);

// Run `npm install` after initial setup so `npm run check` 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, 'tsconfig.json'));
fs.accessSync(path.join(kitchenPath, '.eslintrc.json'));
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