botpress / v12

Botpress OSS – v12
https://v12.botpress.com
GNU Affero General Public License v3.0
68 stars 83 forks source link

[FEATURE] Cleaner Code Style / Disable Auto-Formatting #1195

Open JustusNBB opened 3 years ago

JustusNBB commented 3 years ago

Is your feature request related to a problem? Please describe. Botpress has evolved its own tslint rule set instead of sticking to recommendations. When using the builtin Code Editor this style is enforced by auto-formatting.

Describe the solution you'd like Way less custom rules. Take the recommended preset and add as few additional custom rules as possible to match the current set. Obviously changing everything is a terrible idea (like e.g. quotes), but some rule overrides can be removed with low impact on the code I hope.

    "triple-equals": [true, "allow-null-check", "allow-undefined-check"],

For example this is particulary bad, why?

  1. use just one nully value, not both null or undefined
  2. check undefined with typeof myVar === "undefined" instead of relaxing this rule or fail cross-window!

I am also a fan of the trailing-comma, that should also be at least optional!

Describe alternatives you've considered Nowadays ESLint is standard for linting and it can also lint TypeScript. Prettier is great for autoformatting. Allow optional semicolons for custom code, at least that is what a dev not coming from python would expect? Single Quotes must die - would Crockford say, well at least we don't need three kinds of quotes (including es6 template strings)...

Additional context Im building an API with NestJS for my Botpress project, I am trying to align codestyles from NestJS, Botpress, my employer and myself. It would be great to use a single combined ruleset for API (backend) & Botpress (frontend). For now I have added a .prettierrc for the Botpress part with { singleQuote: true, semi: false } to not conflict between VSCode and Botpress Code Editor formatting.

JustusNBB commented 3 years ago

Sorry the base for this is quite opinionated, I hope it can be standardized a bit more, or some rules relaxed (e.g. allowing semicolons and trailing comma), else maybe a solution could be an option to disable autoformatting, locally or globally in case of running into conflicts.