Giter Site home page Giter Site logo

worststyleguideever.js's Introduction

worstStyleGuideEver.js

  1. Always indent with 2 full tabs.

  2. Actually ... use 16 spaces so tricksters cannot get around it with fancy tabstop settings (attempt to make your documents as wide as possible).

  3. Always start curly braces on their own line, especially after 'return'.

  4. Never use semicolons, JavaScript inserts them for you.

  5. Alternate between }()) and })() with IIFE's.

  6. Use 2 spaces between every character.

  7. Leave several spaces at the end of most lines.

  8. Always use == and !=, and never the 3 character versions, because type-coercion is your friend.

  9. Divide all arithmetical operations by 10 until they occur at the decimal level.

  10. Favor for loops over .forEach() and .map().

  11. Favor .innerHTML over .textContent.

  12. Query the dom as much as possible, it's fast.

  13. Never use var, just repeat any reusable code.

  14. Put all function declarations at the bottom of the file and rely on hoisting.

  15. If you absolutely must use var, make sure all your variables are global.

  16. Never throw errors, this keeps other JavaScripters from learning how to fix code.

  17. Put all functions within a loop.

  18. Declare all var's inside of for loops whose outer scope is global.

  19. Use intentional fall throughs in all switch statements.

  20. Use eval whenever possible.

  21. Repeat yourself often.

  22. Sometimes forget to indent, other times indent twice for no apparent reason.

  23. Write no comments, they clutter the code.

  24. If you do use comments, open with /* but never close it.

  25. Never use alphabetical characters, instead rely on ASCII codes and charCodeAt.

  26. Never set this equal to a var.

  27. Never version your code. If you do, make breaking changes often, but increment the version number the least amount possible.

  28. Name variables starting alphabetically a, b, c, d .... This will make it easy to know how many variables you have.

  29. Use short variable names in different contexts.

  30. Always use different selectors to query the same element.

  31. Keep your commit comments as short as possible. "Update" is ideal.

worststyleguideever.js's People

Stargazers

Roman avatar Farrukh Subhani avatar Gleb avatar  avatar Joerg Boeselt avatar Lucas Gabriel Sánchez avatar

Watchers

Ryan McQuen avatar James Cloos avatar  avatar

Forkers

farrukhcw mfsbo

worststyleguideever.js's Issues

More Style guide rules needed

Cant believe I have to come back to this in 2022. But its worth mentioning that some rules I have found in wild are way important to miss

  • When creating server side variables its best to use a variation of nearest found variable with maybe adding 1 at the end of it or changing case of one the letters in middle.
  • For html custom attributes (common in Angular,Vue,Web Component world) use the number based naming for example att1,att2,att2 instead of gallery-width, gallery-height, has-thumbnails etc. This saves a lot of time and easy to iterate in JS.
  • Services, Components and Modules are all just folders in JS worlds. You can easily put all their code in one file and it will run the same. Avoid extra folders where possible.
  • Promises and Fetch must not have any catch statements. The more errors you try to catch the busier the code gets so keep it free for other important things.
  • When performing an async operation never tell the user about loading. They already know about their slow internet problems, showing them a loader shows negativity in your app. They will randomly wait and click around. Instead try to handle click event on overlay and show a message that "your internet is slow my code is ok on localhost"
  • When showing a calendar try to show start date as 1/1/1970 as this is default date of most databases. There are more chances of user selecting correct date if you show them this.
  • Add complete libraries to the project instead of adding the component you need. This keeps it secret as to what is being used from that library. By exposing what module is being loaded you are telling others too much about your project. import * is your friend here.
  • import library and expose it to window object for global access instead of modules. This lets everyone use it. Sharing is caring.
  • When using local storage try to find an existing key and add a | your new variable at the end of it. This reduced number of variables in local storage. Read the single variable and split by | to create your data. This is way faster than json stringify and parse.

I have some more come across in last year or so but if someone can rewrite these in while I look at what other things I have seen in PHP,C# and JS world.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.