diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/docs/site/Application-generator.md b/docs/site/Application-generator.md index 5bfea27106e0..bec91601e095 100644 --- a/docs/site/Application-generator.md +++ b/docs/site/Application-generator.md @@ -31,6 +31,9 @@ lb4 [app] [options] [] `--loopbackBuild` : Add @loopback/build module's script set to LoopBack4 application project. +`--editorconfig` : Add EditorConfig config files to the LoopBack4 application +project. + `--vscode`: Add VSCode config files to LoopBack4 application project `--docker`: Generate Dockerfile and add npm scripts to build/run the project in @@ -70,6 +73,7 @@ The tool will prompt you for: - [`prettier`](https://www.npmjs.com/package/prettier) - [`mocha`](https://www.npmjs.com/package/mocha) - [`@loopback/build`](https://www.npmjs.com/package/@loopback/build) + - [`editorconfig`](https://editorconfig.org/) - [`vscode`](https://code.visualstudio.com/) ### Output diff --git a/docs/site/Getting-started.md b/docs/site/Getting-started.md index 26a7e226ad4d..43b4a9fd88c5 100644 --- a/docs/site/Getting-started.md +++ b/docs/site/Getting-started.md @@ -49,6 +49,7 @@ Answer the prompts as follows: ◉ Enable prettier: install prettier to format code conforming to rules ◉ Enable mocha: install mocha to run tests ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint) + ◉ Enable editorconfig: add EditorConfig files ◉ Enable vscode: add VSCode config files ◉ Enable docker: include Dockerfile and .dockerignore ◉ Enable repositories: include repository imports and RepositoryMixin diff --git a/docs/site/deployment/Deploying_to_ibm_cloud_kubernetes.md b/docs/site/deployment/Deploying_to_ibm_cloud_kubernetes.md index c7de65b6b9e4..797f6f131223 100644 --- a/docs/site/deployment/Deploying_to_ibm_cloud_kubernetes.md +++ b/docs/site/deployment/Deploying_to_ibm_cloud_kubernetes.md @@ -50,6 +50,7 @@ $ lb4 app ◉ Enable prettier: install prettier to format code conforming to rules ◉ Enable mocha: install mocha to run tests ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint) + ◉ Enable editorconfig: add EditorConfig files ◉ Enable vscode: add VSCode config files ◉ Enable docker: include Dockerfile and .dockerignore ◉ Enable repositories: include repository imports and RepositoryMixin diff --git a/docs/site/tutorials/connectors/Mysql-tutorial.md b/docs/site/tutorials/connectors/Mysql-tutorial.md index e48f9eb65e18..a12559431a13 100644 --- a/docs/site/tutorials/connectors/Mysql-tutorial.md +++ b/docs/site/tutorials/connectors/Mysql-tutorial.md @@ -41,6 +41,7 @@ le all, to invert selection) ◉ Enable prettier: install prettier to format code conforming to rules ◉ Enable mocha: install mocha to run tests ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint) + ◉ Enable editorconfig: add EditorConfig files ◉ Enable vscode: add VSCode config files ◉ Enable docker: include Dockerfile and .dockerignore ◉ Enable repositories: include repository imports and RepositoryMixin diff --git a/docs/site/tutorials/connectors/Postgresql-tutorial.md b/docs/site/tutorials/connectors/Postgresql-tutorial.md index b0579be30af7..bbe0a6a33500 100644 --- a/docs/site/tutorials/connectors/Postgresql-tutorial.md +++ b/docs/site/tutorials/connectors/Postgresql-tutorial.md @@ -41,6 +41,7 @@ le all, to invert selection) ◉ Enable prettier: install prettier to format code conforming to rules ◉ Enable mocha: install mocha to run tests ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint) + ◉ Enable editorconfig: add EditorConfig files ◉ Enable vscode: add VSCode config files ◉ Enable docker: include Dockerfile and .dockerignore ◉ Enable repositories: include repository imports and RepositoryMixin diff --git a/docs/site/tutorials/soap-calculator/soap-calculator-tutorial-scaffolding.md b/docs/site/tutorials/soap-calculator/soap-calculator-tutorial-scaffolding.md index 198f4804baa3..db5ea6fc033d 100644 --- a/docs/site/tutorials/soap-calculator/soap-calculator-tutorial-scaffolding.md +++ b/docs/site/tutorials/soap-calculator/soap-calculator-tutorial-scaffolding.md @@ -48,6 +48,7 @@ Enable all options besides `docker`, unless you know what you are doing, see ◉ Enable prettier: install prettier to format code conforming to rules ◉ Enable mocha: install mocha to run tests ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint) + ◉ Enable editorconfig: add EditorConfig files ◉ Enable vscode: add VSCode config files ❯◯ Enable docker: include Dockerfile and .dockerignore ◉ Enable repositories: include repository imports and RepositoryMixin diff --git a/docs/site/tutorials/todo/todo-tutorial-scaffolding.md b/docs/site/tutorials/todo/todo-tutorial-scaffolding.md index ff51fdaca594..3a574114b7e1 100644 --- a/docs/site/tutorials/todo/todo-tutorial-scaffolding.md +++ b/docs/site/tutorials/todo/todo-tutorial-scaffolding.md @@ -27,6 +27,7 @@ $ lb4 app ◉ Enable prettier: install prettier to format code conforming to rules ◉ Enable mocha: install mocha to run tests ◉ Enable loopbackBuild: use @loopback/build helpers (e.g. lb-eslint) + ◉ Enable editorconfig: add EditorConfig files ◉ Enable vscode: add VSCode config files ◉ Enable docker: include Dockerfile and .dockerignore ◉ Enable repositories: include repository imports and RepositoryMixin diff --git a/examples/access-control-migration/.editorconfig b/examples/access-control-migration/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/access-control-migration/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/binding-resolution/.editorconfig b/examples/binding-resolution/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/binding-resolution/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/context/.editorconfig b/examples/context/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/context/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/express-composition/.editorconfig b/examples/express-composition/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/express-composition/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/file-transfer/.editorconfig b/examples/file-transfer/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/file-transfer/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/graphql/.editorconfig b/examples/graphql/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/graphql/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/greeter-extension/.editorconfig b/examples/greeter-extension/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/greeter-extension/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/greeting-app/.editorconfig b/examples/greeting-app/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/greeting-app/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/hello-world/.editorconfig b/examples/hello-world/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/hello-world/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/lb3-application/.editorconfig b/examples/lb3-application/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/lb3-application/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/log-extension/.editorconfig b/examples/log-extension/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/log-extension/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/metrics-prometheus/.editorconfig b/examples/metrics-prometheus/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/metrics-prometheus/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/multi-tenancy/.editorconfig b/examples/multi-tenancy/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/multi-tenancy/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/passport-login/.editorconfig b/examples/passport-login/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/passport-login/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/references-many/.editorconfig b/examples/references-many/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/references-many/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/rest-crud/.editorconfig b/examples/rest-crud/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/rest-crud/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/rpc-server/.editorconfig b/examples/rpc-server/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/rpc-server/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/soap-calculator/.editorconfig b/examples/soap-calculator/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/soap-calculator/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/socketio/.editorconfig b/examples/socketio/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/socketio/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/todo-jwt/.editorconfig b/examples/todo-jwt/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/todo-jwt/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/todo-list/.editorconfig b/examples/todo-list/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/todo-list/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/todo/.editorconfig b/examples/todo/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/todo/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/validation-app/.editorconfig b/examples/validation-app/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/validation-app/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/examples/webpack/.editorconfig b/examples/webpack/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/examples/webpack/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/packages/cli/generators/project/templates/.editorconfig b/packages/cli/generators/project/templates/.editorconfig new file mode 100644 index 000000000000..0f112c3f9b09 --- /dev/null +++ b/packages/cli/generators/project/templates/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = space +indent_size = 2 +max_line_length = 80 diff --git a/packages/cli/lib/project-generator.js b/packages/cli/lib/project-generator.js index d827d9264427..6757b805a451 100644 --- a/packages/cli/lib/project-generator.js +++ b/packages/cli/lib/project-generator.js @@ -36,7 +36,14 @@ module.exports = class ProjectGenerator extends BaseGenerator { name: 'loopbackBuild', description: g.f('use @loopback/build helpers (e.g. lb-eslint)'), }, - {name: 'vscode', description: g.f('add VSCode config files')}, + { + name: 'editorconfig', + description: g.f('add EditorConfig files'), + }, + { + name: 'vscode', + description: g.f('add VSCode config files'), + }, ]; } @@ -77,6 +84,11 @@ module.exports = class ProjectGenerator extends BaseGenerator { description: g.f('Use @loopback/build'), }); + this.option('editorconfig', { + type: Boolean, + description: g.f('Use preconfigured EditorConfig settings'), + }); + this.option('vscode', { type: Boolean, description: g.f('Use preconfigured VSCode settings'), @@ -301,6 +313,10 @@ module.exports = class ProjectGenerator extends BaseGenerator { this.fs.delete(this.destinationPath('.mocharc.json')); } + if (!this.projectInfo.editorconfig) { + this.fs.delete(this.destinationPath('.editorconfig')); + } + if (!this.projectInfo.vscode) { this.fs.delete(this.destinationPath('.vscode')); }