Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 979F417F1F for ; Sun, 12 Oct 2014 09:20:06 +0000 (UTC) Received: (qmail 28010 invoked by uid 500); 12 Oct 2014 09:20:06 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 27935 invoked by uid 500); 12 Oct 2014 09:20:06 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 27924 invoked by uid 99); 12 Oct 2014 09:20:05 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Oct 2014 09:20:05 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 91A7789C58C; Sun, 12 Oct 2014 09:20:05 +0000 (UTC) From: daleharvey To: dev@couchdb.apache.org Reply-To: dev@couchdb.apache.org References: In-Reply-To: Subject: [GitHub] couchdb-fauxton pull request: Added js style guide Content-Type: text/plain Message-Id: <20141012092005.91A7789C58C@tyr.zones.apache.org> Date: Sun, 12 Oct 2014 09:20:05 +0000 (UTC) Github user daleharvey commented on a diff in the pull request: https://github.com/apache/couchdb-fauxton/pull/91#discussion_r18746635 --- Diff: styleguide.md --- @@ -0,0 +1,192 @@ +# JavaScript Style Guide + +This document attempts to codify the JavaScript code style rules for Fauxton. This has been patched together from +a few sources, including [Pootle's style guide](http://pootle.readthedocs.org/en/latest/developers/styleguide.html#javascript), +[Google JS style guide](https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml), and from +reverse-engineering our own codebase. + +This is intended to be a living document: any disagreements about style should be brought to the community via IRC, +discussed, agreed upon and documented here. + +Note: We have JSHint running as a grunt task which will catch the more egregious errors (missing `vars`, missing +semicolons etc). See the `Gruntfile.js` for the settings being used. + + +## Programming Style + +#### Strings +Use `'` single quote character for strings, because HTML markup uses `"`. Eg. `var greeting = 'Hello World!'`; + +#### Numbers +When using `parseInt` always explicitly include the second radix argument (usually 10). + +#### Indentation +- 2-space indentation. Don't use tabs. JSHint will whine if you have mixed tabs and spaces. --- End diff -- 2 space tabs is almost ubiqutious in javascript world, in PouchDB we also use an 80 char limit, we actually just link to http://nodeguide.com/style.html for our style guide, (https://github.com/pouchdb/pouchdb/blob/master/CONTRIBUTING.md#guide-to-contributions) most of it we enforce with jshint --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---