From 2338421c6ddf8c520f2ebbb5b3c040aebc1ad197 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 12 Jul 2016 19:22:21 -0700 Subject: [PATCH] lint: Add documentation lint check for JavaScript spelling. --- docs/changelog.md | 2 +- docs/code-style.md | 12 ++++++------ docs/directory-structure.md | 8 ++++---- docs/roadmap.md | 4 ++-- tools/lint-all | 6 +++++- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9e5bad7d5f..5b508b9b03 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -39,7 +39,7 @@ All notable changes to the Zulip server are documented in this file. - Migrated development environment setup scripts to tools/setup/. - Expanded test coverage for several areas of the product. - Simplified the API for writing new webhook integrations. -- Removed most of the remaining javascript global variables. +- Removed most of the remaining JavaScript global variables. ### 1.3.12 - 2016-05-10 - CVE-2016-4426: Bot API keys were accessible to other users in the same realm. diff --git a/docs/code-style.md b/docs/code-style.md index f8bfc1b738..b1f43499c6 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -23,7 +23,7 @@ The Vagrant setup process runs this for you. `lint-all` runs many lint checks in parallel, including -- Javascript ([JSLint](http://www.jslint.com/)) +- JavaScript ([JSLint](http://www.jslint.com/)) > `tools/jslint/check-all.js` contains a pretty fine-grained set of > JSLint options, rule exceptions, and allowed global variables. If @@ -119,9 +119,9 @@ string, use the `id` function, as it will simplify future code changes. In most contexts in JavaScript where a string is needed, you can pass a number without any explicit conversion. -### Javascript var +### JavaScript var -Always declare Javascript variables using `var`: +Always declare JavaScript variables using `var`: var x = ...; @@ -129,12 +129,12 @@ In a function, `var` is necessary or else `x` will be a global variable. For variables declared at global scope, this has no effect, but we do it for consistency. -Javascript has function scope only, not block scope. This means that a +JavaScript has function scope only, not block scope. This means that a `var` declaration inside a `for` or `if` acts the same as a `var` declaration at the beginning of the surrounding `function`. To avoid confusion, declare all variables at the top of a function. -### Javascript `for (i in myArray)` +### JavaScript `for (i in myArray)` Don't use it: [[1]](http://stackoverflow.com/questions/500504/javascript-for-in-with-arrays), @@ -229,7 +229,7 @@ Whitespace guidelines: used for inline dictionaries, put no space before it and at least one space after. Only use more than one space for alignment. -### Javascript +### JavaScript Don't use `==` and `!=` because these operators perform type coercions, which can mask bugs. Always use `===` and `!==`. diff --git a/docs/directory-structure.md b/docs/directory-structure.md index 2e4e36945a..73ab487827 100644 --- a/docs/directory-structure.md +++ b/docs/directory-structure.md @@ -46,17 +46,17 @@ templating systems. ---------------------------------------- -### Javascript and other static assets +### JavaScript and other static assets -* `static/js/` Zulip's own javascript. +* `static/js/` Zulip's own JavaScript. * `static/styles/` Zulip's own CSS. * `static/images/` Zulip's images. -* `static/third/` Third-party javascript and CSS that has been vendored. +* `static/third/` Third-party JavaScript and CSS that has been vendored. -* `node_modules/` Third-party javascript installed via `npm`. +* `node_modules/` Third-party JavaScript installed via `npm`. * `assets/` For assets not to be served to the web (e.g. the system to generate our favicons). diff --git a/docs/roadmap.md b/docs/roadmap.md index 40aa43b2e1..7aa380188f 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -150,7 +150,7 @@ While the Zulip server has a great codebase compared to most projects of its size, it takes work to keep it that way. * [Migrate most web routes to REST API](https://github.com/zulip/zulip/issues/611) -* [Finish purging global variables from the Zulip javascript](https://github.com/zulip/zulip/issues/610) +* [Finish purging global variables from the Zulip JavaScript](https://github.com/zulip/zulip/issues/610) * [Finish deprecating and remove the pre-REST Zulip /send_message API](https://github.com/zulip/zulip/issues/730) * [Split Tornado subsystem into a separate Django app](https://github.com/zulip/zulip/issues/729) * [Clean up clutter in the root of the zulip.git repository](https://github.com/zulip/zulip/issues/707) @@ -186,7 +186,7 @@ of its size, it takes work to keep it that way. * [Overhaul new contributor documentation](https://github.com/zulip/zulip/issues/677) * [Replace closure-compiler with a faster minifier toolchain](https://github.com/zulip/zulip/issues/693) * [Add support for building frontend features in React](https://github.com/zulip/zulip/issues/694) -* [Use a javascript bundler like webpack](https://github.com/zulip/zulip/issues/695) +* [Use a JavaScript bundler like webpack](https://github.com/zulip/zulip/issues/695) ## Documentation diff --git a/tools/lint-all b/tools/lint-all index f46ad87fd9..618ca329c0 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -294,7 +294,11 @@ html_rules = whitespace_rules + [ 'description': "`placeholder` value should be translatable."}, ] json_rules = [] # just fix newlines at ends of files -markdown_rules = markdown_whitespace_rules +markdown_rules = markdown_whitespace_rules + [ + {'pattern': ' [jJ]avascript', + 'exclude': set(['README.dev.md']), # temporary exclusion to avoid merge conflicts + 'description': "javascript should be spelled JavaScript"}, +] txt_rules = whitespace_rules def check_custom_checks_py():