From 058da8b226256e468c79d6be431bea1494637261 Mon Sep 17 00:00:00 2001 From: Anton Kovalyov Date: Tue, 9 Oct 2012 15:50:11 -0700 Subject: [PATCH] Added LICENSE and CONTRIBUTING. Updated README --- CONTRIBUTING.md | 100 +++++++++++++++++++++++++++++++++++++++++++ LICENSE | 20 +++++++++ README.md | 84 ++++++++++++------------------------ src/stable/jshint.js | 2 - 4 files changed, 147 insertions(+), 59 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..98f450555 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,100 @@ +How to contribute +================= + +The best way to make sure your issue is addressed is to submit a patch. We accept +patches through all mediums: pull requests, email, issue comment, tweet with a link +to a snippet, graffiti outside of Anton's apartment, etc. + +However, before sending a patch, please make sure that the following applies: + +* There is a corresponding issue. If there is no issue yet, create one before + working on your patch. Patches that come out of nowhere usually end up in + the end of our queue. +* Your commit message links to that issue. +* Your commit message is very descriptive ([example](https://github.com/jshint/jshint/commit/5751c5ed249b7a035758a3ae876cfa1a360fd144)). +* Your patch doesn't have useless merge commits. +* Your coding style is similar to ours (see below). +* Your patch is 100% tested. We don't accept any test regressions. +* All tests and lint checks pass (`node make.js test` and `node make.js lint`). +* You understand that we're super grateful for your patch. + +Coding Style +------------ + +This section describes our coding style guide. You might not agree with it and that's +fine but if you're going to send us patches treat this guide as a law. + +### Our main rule is simple: + +> All code in any code-base should look like a single person typed it, no matter how +many people contributed. —[idiomatic.js](https://github.com/rwldrn/idiomatic.js/) + +### Whitespace: + +* We use hard tabs everywhere except for `src/stable/jshint.js`. It's annoying, we know. +* [Smart tabs](http://www.emacswiki.org/SmartTabs) are okay. +* Use one space after `if`, `for`, `while`, etc. +* Use one space after `function` for anonymous functions but not for named functions: +```javascript +var a = function () {}; +function a() {} +``` +* Feel free to indent variable assignments or property definitions if it makes the code look better. But don't abuse that: +```javascript + +// Good +var next = token.peak(); +var prev = token.peak(-1); +var cur = token.current; + +var scope = { + name: '(global)', + parent: parentScope, + vars: [], + uses: [] +}; + +// Bad +var cur = token.current; +var isSemicolon = cur.isPunctuator(";"); +``` +* Wrap multi-line comments with new lines on both sides. + +### Variables + +* Use one `var` per variable unless you don't assign any values to it (and it's short enough): +```javascript +var token = tokens.find(index); +var scope = scopes.current; +var next, prev, cur; +``` +* Don't be overly descriptive with your variable names but don't abuse one-letter variables either. Find a sweet spot somewhere in between. + +### Comments + +* Use `//` for all comments. +* Comment everything that is not obvious. +* If you're adding a new check, write a comment describing why this check is important and what it checks for. + +### Misc + +* Always use strict mode. +* Always use strict comparisons: `===` and `!==`. +* Use semicolons. +* Don't use comma-first notation. +* Try not to chain stuff unless it **really** helps (e.g. in tests). +* Don't short-circuit expressions if you're not assigning the result: +```javascript + +// Good +token = token || tokens.find(0); + +// Bad +token.isPunctuator(";") && report.addWarning("W001"); + +// Good +if (token.isPunctuator(";")) + report.addWarning("W001"); +``` + +Today we use JSHint's `white:true` to enforce some of these rules. Eventually we'll switch to JSHint Next style enforcing component. But it's not ready yet. diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..0e247b19f --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright 2012 Anton Kovalyov (http://jshint.com) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index ab6e72781..1f4ba7f10 100755 --- a/README.md +++ b/README.md @@ -2,16 +2,18 @@ JSHint, A Static Code Analysis Tool for JavaScript ================================================== JSHint is a community-driven tool to detect errors and potential problems in -JavaScript code and to enforce your team's coding conventions. +JavaScript code and to enforce your team's coding conventions. We made JSHint +very flexible so you can easily adjust it to your particular coding guidelines +and the environment you expect your code to execute in. -**IMPORTANT**: +Our goal is to help JavaScript developers write complex programs without +worrying about typos and language gotchas. - * This README is for people who are thinking about contributing to JSHint. For general usage - please refer to [our website](http://jshint.com/). - * If you want to report a bug about the website, please go to the - [jshint/site](https://github.com/jshint/site/) repository. - * If you want to report a bug or contribute to our NPM package, please go to the - [jshint/node-jshint](https://github.com/jshint/node-jshint/) repository. +We believe that static code analysis programs—as well as other code quality +tools—are important and beneficial to the JavaScript community and, thus, +should not alienate their users. + +For general usage information, visit our website: [http://jshint.com/](http://jshint.com/). Reporting a bug --------------- @@ -24,36 +26,32 @@ not limited to: * When JSHint complains about valid JavaScript code that works in all browsers * When you simply want a new option or feature -Please, before reporting a bug look around to see if there are any open or closed tickets that +Before reporting a bug look around to see if there are any open or closed tickets that cover your issue. And remember the wisdom: pull request > bug report > tweet. -Submitting patches ------------------- - -The best way to make sure your issue is addressed is to submit a patch. GitHub provides a very -nice interface--pull requests--for that but we accept patches through all mediums: email, issue -comment, tweet with a link to a snippet, etc. +Installation +------------ -Before submitting a patch make sure that you comply to our style. We don't have specific style -guide so just look around the code you are changing. +You can install JSHint via NPM: -Also, make sure that you write tests for new features and make sure that all tests pass before -submitting a patch. Patches that break the build will be rejected. + npm install jshint -g -**FEATURE FREEZE**: Please note that we currently have a feature freeze on new environments and -styling options. The only patches we accept at this time are for bug fixes. +We also provide platform wrappers for Rhino, JavaScriptCore and Windows Script Host. To +use them, clone this repo and run our build command: -Tests ------ + node make.js -To run tests you will need to install [node.js](http://nodejs.org/) and -expresso. You can install the latter with npm: +Contributing +------------ - npm install expresso +Look for a file named CONTRIBUTING.md in this repository. It contains our contributing +guidelines. We also have [a mailing list](http://groups.google.com/group/jshint/). -After that, running the unit tests is as easy as: +License +------- - expresso tests/unit/*.js +JSHint is distributed under the MIT License. One file (`src/stable/jshint.js`) is +distributed under the slightly modified MIT License. Attribution ----------- @@ -63,38 +61,10 @@ Core Team members: * [Anton Kovalyov](http://anton.kovalyov.net/) ([@valueof](http://twitter.com/valueof)) * [Wolfgang Kluge](http://klugesoftware.de/) ([blog](http://gehirnwindung.de/)) * [Josh Perez](http://www.goatslacker.com/) ([@goatslacker](http://twitter.com/goatslacker)) + * [Brent Lintner](http://brentlintner.heroku.com/) ([@brentlintner](http://twitter.com/brentlintner)) Maintainer: Anton Kovalyov -License -------- - -JSHint is licensed under the MIT license. - -JSHint is a derivative work of JSLint: - -Copyright (c) 2002 Douglas Crockford (www.JSLint.com) - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -JSHint was forked from the 2010-12-14 edition of JSLint. - Thank you! ---------- diff --git a/src/stable/jshint.js b/src/stable/jshint.js index f5fcf5d88..a97b6bd44 100644 --- a/src/stable/jshint.js +++ b/src/stable/jshint.js @@ -25,8 +25,6 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * JSHint was forked from the 2010-12-14 edition of JSLint. - * */ /*