TylerBrock / mongo-hacker

MongoDB Shell Enhancements for Hackers
tylerbrock.github.io/mongo-hacker
MIT License
1.79k stars 235 forks source link

Jshint #124

Closed gianpaj closed 9 years ago

gianpaj commented 9 years ago

Using an inspired version of Airbnb's javacript style guide:

{
  // inspired by airbnb style

  /*
   * ENVIRONMENTS
   * =================
   */

  // Define globals exposed by modern browsers.
  "browser": true,

  // Define globals exposed by jQuery.
  "jquery": true,

  // Define globals exposed by Node.js.
  "node": true,

  /*
   * ENFORCING OPTIONS
   * =================
   */

  // Force all variable names to use either camelCase style or UPPER_CASE
  // with underscores.
  "camelcase": false,

  // Prohibit use of == and != in favor of === and !==.
  "eqeqeq": true,

  // Enforce tab width of 2 spaces.
  "indent": 2,

  // Prohibit use of a variable before it is defined.
  "latedef": true,

  // Enforce line length to 80 characters
  "maxlen": 100,

  // Require capitalized names for constructor functions.
  "newcap": true,

  // Enforce use of single quotation marks for strings.
  "quotmark": "double",

  // Enforce placing 'use strict' at the top function scope
  "strict": false,

  // Prohibit use of explicitly undeclared variables.
  "undef": false,

  // Warn when variables are defined but never used.
  "unused": true,

  /*
   * RELAXING OPTIONS
   * =================
   */

  // Suppress warnings about == null comparisons.
  "eqnull": true
}
stennie commented 9 years ago

@gianpaj Aside from pedantic syntax tweaks, what does this improve?

gianpaj commented 9 years ago

It's about making the code more consistent, easy to read and maintainable.

I'm not intending to impose my style preferences on other people's code or projects; perhaps this should raise a conversation a common style guide. Should this have one? If so it should be respected.

TylerBrock commented 9 years ago

I like the idea of enforcing a style generally although in changing it we will differ from the style of the internal shell code (which i don't believe has consistency or style guidelines)

TylerBrock commented 9 years ago

Shouldn't the .jshintrc be included in this pull request?

TylerBrock commented 9 years ago

Bump

TylerBrock commented 9 years ago

@gianpaj I like this but we need some different defaults. These are clearly not appropriate:

  // Define globals exposed by modern browsers.
  "browser": true,

  // Define globals exposed by jQuery.
  "jquery": true,

  // Define globals exposed by Node.js.
  "node": true,
gianpaj commented 9 years ago

sorry for the delay. I've added the .jshintrc file and fixed those settings.

The master branch has changed since I did this pull request, should I pull the changes in my branch and fix the merge conflicts or a make a new pull request?

gianpaj commented 9 years ago

closing as I believe it's not an important issue