Repository: JedWatson/happiness Branch: master Commit: 8d99bc3eb3ea Files: 33 Total size: 413.9 KB Directory structure: gitextract_6yufa38k/ ├── .gitignore ├── .npmignore ├── .travis.yml ├── AUTHORS.md ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RULES.md ├── bin/ │ ├── cmd.js │ └── update-authors.sh ├── docs/ │ ├── README-en.md │ ├── README-esla.md │ ├── README-iteu.md │ ├── README-kokr.md │ ├── README-ptbr.md │ ├── README-zhcn.md │ ├── README-zhtw.md │ ├── RULES-en.md │ ├── RULES-esla.md │ ├── RULES-iteu.md │ ├── RULES-kokr.md │ ├── RULES-ptbr.md │ ├── RULES-zhcn.md │ ├── RULES-zhtw.md │ └── webstorm.md ├── eslintrc.json ├── index.js ├── options.js ├── package.json └── test/ ├── api.js ├── clone.js └── cmd.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ node_modules/ tmp/ ================================================ FILE: .npmignore ================================================ test/ docs/logos/ tmp/ bin/update-authors.sh .travis.yml badge.png badge.svg CONTRIBUTING.md sticker.png sticker.svg ================================================ FILE: .travis.yml ================================================ language: node_js node_js: - '4' - '6' - 'node' ================================================ FILE: AUTHORS.md ================================================ # Authors #### Ordered by first contribution. - Feross Aboukhadijeh (feross@feross.org) - Jonny Buchanan (jonathan.buchanan@gmail.com) - Dan Flettre (flettre@gmail.com) - Brandon Horst (brandonhorst@gmail.com) - Yoshua Wuyts (yoshuawuyts@gmail.com) - Alexander Gugel (alexander.gugel@gmail.com) - Nate Goldman (nnmgoldman@gmail.com) - Max Ogden (max@maxogden.com) - Ricardo Barros (ricardofbarros@hotmail.com) - Yoshua Wuyts (i@yoshuawuyts.com) - Shahar Or (mightyiampresence@gmail.com) - Brent Burgoyne (bburgoyne@instructure.com) - Santiago Gil (gil.educaciontdf@gmail.com) - Vasiliy Loginevskiy (yeti-or@yandex-team.ru) - Joe Lencioni (joe.lencioni@brigade.com) - Leo Melin (leo.melin@eee.do) - G. Kay Lee (balancetraveller+github@gmail.com) - Lorenzo Villani (lorenzo@villani.me) - Ahmad Nassri (ahmad@ahmadnassri.com) - Mathias Buus (mathiasbuus@gmail.com) - Alex Potsides (alex@achingbrain.net) - Dan Lee (dlee@yammer-inc.com) - ishamf (ishamf@users.noreply.github.com) - Eric Zeng (leizeng@thoughtworks.com) - Cesar Andreu (cesarandreu@gmail.com) - Daniel Cousens (dcousens@users.noreply.github.com) - Enikő Nagy (eenagy@users.noreply.github.com) - Matthieu Prat (matthieuprat@gmail.com) - Dany Shaanan (danyshaanan@gmail.com) - Thomas Reggi (socialtr@gmail.com) - Stephen Kubovic (skubovic@gmail.com) - David Keijser (keijser@gmail.com) - Nick Colley (nickcolley7@gmail.com) - Florian Ebeling (mail@florianebeling.com) - Rico Sta. Cruz (rstacruz@users.noreply.github.com) - reggi (thomas@reggi.com) - Machisté N. Quintana (mnquintana@users.noreply.github.com) - Jiri Spac (capajj@gmail.com) - Sonny Piers (sonny@fastmail.net) - fscherwi (fscherwi@users.noreply.github.com) - Gustav Nikolaj Olsen (gno@one.com) - skorlir (skorlir@gmail.com) - JP Richardson (jprichardson@gmail.com) - chenxsan (chenxsan@users.noreply.github.com) - Tara Z. Manicsic (tara@modulus.io) - Jakub Elżbieciak (jelz@post.pl) - Dale Jefferson (dale@dalejefferson.com) - Paul Kernfeld (paulkernfeld@gmail.com) - Wes Todd (wes@wesleytodd.com) - rajcoss (nagrajan@ciena.com) - Jed Watson (jed.watson@me.com) - Joe Whitfield-Seed (joeseed86@gmail.com) - botbotbot (tkroputa@gmail.com) - Žiga Vidic (zigomir@gmail.com) - Wade Simmons (wsimmons@gmail.com) - Tushar Mathur (tusharmath@gmail.com) - Joshua Jabbour (code@joshuajabbour.com) - Zeke Sikelianos (zeke@sikelianos.com) - darren higgins (darrhiggs@users.noreply.github.com) - Joris Blaak (joris@label305.com) #### Generated by bin/update-authors.sh. ================================================ FILE: CHANGELOG.md ================================================ # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## 10.0.2 - 2017-04-14 ### Changed rules - Relax rule: Disallow import of modules using absolute paths ([import/no-absolute-path](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md)) [#861](https://github.com/standard/standard/issues/861) - This rule was responsible for up to 25% of the running time of `standard`, so we are disabling it until its performance improves. ## 10.0.1 - 2017-04-06 - Internal changes (incremented dependency versions) ## 10.0.0 - 2017-04-04 **`standard` just turned 10.0.0!** 🎉 As with every new major release, there are lots of new rules in 10.0.0 designed to help catch bugs and make programmer intent more explicit. `standard` is more popular than ever – **330,000 downloads per month!** It's even more popular – **670,000 downloads per month** – if you include the [shareable ESLint config](https://www.npmjs.com/package/eslint-config-standard) that we also publish. The most important change in 10.0.0 is that **using deprecated Node.js APIs is now considered an error**. It's finally time to update those dusty old APIs! Deprecated APIs are problematic because they may print warning messages in the console in recent versions of Node.js. This often confuses users and leads to unnecessary support tickets for project maintainers. Some deprecated APIs are even insecure (or at least prone to incorrect usage) which can have serious security implications. For that reason, `standard` now considers usage of `Buffer(num)` to be an error, since this function returns uninitialized program memory which could contain confidential information like passwords or keys. Instead of `Buffer(num)`, consider using `Buffer.alloc(num)` or `Buffer.from(obj)` which make the programmer's intent clearer. These functions exist in all currently supported versions of Node.js, including Node.js 4.x. For more background, [see this Node.js issue](https://github.com/nodejs/node/issues/4660). We also improved some rules to support common patterns in code bases that use React, JSX, and Flow. When you upgrade, consider running `standard --fix` to automatically fix some of the issues caught by this new version. ### New features - Update ESLint from 3.15.x to 3.19.x. - Node.js API: Add `standard.lintTextSync` method ### New rules *(Estimated % of affected standard users, based on test suite in parens)* - Disallow using deprecated Node.js APIs ([node/no-deprecated-api](https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md)) [#693](https://github.com/standard/standard/issues/693) (13%) - Ensures that code always runs without warnings on the latest versions of Node.js - Ensures that safe Buffer methods (`Buffer.from()`, `Buffer.alloc()`) are used instead of `Buffer()` - Enforce callbacks always called with Node.js-style error first ([standard/no-callback-literal](https://github.com/xjamundx/eslint-plugin-standard#rules-explanations)) [#623](https://github.com/standard/standard/issues/623) (3%) - Functions named `callback` or `cb` must be invoked with `null`, `undefined`, or an `Error` as the first argument - Disallows using a string instead of an `Error` object - Disallows confusing callbacks that do not follow the standard Node.js pattern - Disallow any imports that come after non-import statements ([import/first](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md)) [#806](https://github.com/standard/standard/issues/806) (1%) - Disallow unnecessary return await ([no-return-await](http://eslint.org/docs/rules/no-return-await)) [#695](https://github.com/standard/standard/issues/695) (0%) - Disallow comma-dangle in functions ([comma-dangle](http://eslint.org/docs/rules/comma-dangle)) [#787](https://github.com/standard/standard/issues/787) (0%) - Disallow repeated exports of names or defaults ([import/export](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md)) [#806](https://github.com/standard/standard/issues/806) (0%) - Disallow import of modules using absolute paths ([import/no-absolute-path](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md)) [#806](https://github.com/standard/standard/issues/806) (0%) - Disallow Webpack loader syntax in imports ([import/no-webpack-loader-syntax](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md)) [#806](https://github.com/standard/standard/issues/806) (0%) - Disallow comparing against -0 ([no-compare-neg-zero](http://eslint.org/docs/rules/no-compare-neg-zero)) [#812](https://github.com/standard/standard/issues/812) (0%) ### Changed rules - Relax rule: allow using `...rest` to omit properties from an object ([no-unused-vars](http://eslint.org/docs/rules/no-unused-vars)) [#800](https://github.com/standard/standard/issues/800) - This is a common and useful pattern in React/JSX apps! - Relax rule: allow Flow `import type` statements ([import/no-duplicates](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md)) [#599](https://github.com/standard/standard/issues/599) - These are no longer considered to be "duplicate imports" - Relax rule: Treat `process.exit()` the same as `throw` in code path analysis ([node/process-exit-as-throw](https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/process-exit-as-throw.md)) [#699](https://github.com/standard/standard/issues/699) - Makes certain other rules work better and give fewer false positives - Relax rule: allow Unnecessary Labels ([no-extra-label](http://eslint.org/docs/rules/no-extra-label)) - Redundant, since "no-labels" is already enabled, which is more restrictive ## 9.0.2 - 2017-03-17 ### Changed rules - Relax rule: Allow tagged template string expressions ([no-unused-expressions](http://eslint.org/docs/rules/no-unused-expressions)) [#822](https://github.com/standard/standard/issues/822) ## 9.0.1 - 2017-03-07 ### Changed rules - Relax rule: Allow mixing basic operators without parens ([no-mixed-operators](http://eslint.org/docs/rules/no-mixed-operators)) [#816](https://github.com/standard/standard/issues/816) - Specifically, these operators: `+`, `-`, `*`, `/`, `%`, and `**` ## 9.0.0 - 2017-02-28 It's time for a new major version of `standard`! As usual, this release contains a bunch of awesomeness to help you keep your code in tip-top shape! We've added several new rules designed to **catch potential programmer errors** (i.e. bugs), as well as rules to make programmer intent **more explicit** in certain circumstances. This release continues our trend of tightening up rules so that, wherever possible, there's one "right" way to do things. This design goal is intended to reduce the time that teams and maintainers spend giving code review feedback in pull requests. When you upgrade, consider running `standard --fix` to automatically fix some of the errors caught by the new rules in this version. *Note: If you use the Chai test framework, you will need to make some changes to your tests to improve their robustness. [Read about the changes you need to make](https://github.com/standard/standard/issues/690#issuecomment-278533482).* ### New features - Update ESLint from 3.10.x to 3.15.x - 3 additional rules are now fixable with `standard --fix` ### New rules *(Estimated % of affected standard users, based on test suite in parens)* - Disallow mixing different operators without parens ([no-mixed-operators](http://eslint.org/docs/rules/no-mixed-operators)) [#566](https://github.com/standard/standard/issues/566) (5%) - Enforce 1 newline at end of file (previously 1 or 2 were ok) ([no-multiple-empty-lines](http://eslint.org/docs/rules/no-multiple-empty-lines)) [#733](https://github.com/standard/standard/issues/733) (3%) - Disallow Unused Expressions ([no-unused-expressions](http://eslint.org/docs/rules/no-unused-expressions)) [#690](https://github.com/standard/standard/issues/690) (3%) - Note: this affects users of the Chai test framework. [Read about the changes you need to make](https://github.com/standard/standard/issues/690#issuecomment-278533482). - Disallow redundant return statements ([no-useless-return](http://eslint.org/docs/rules/no-useless-return)) [#694](https://github.com/standard/standard/issues/694) (1%) - Disallow Incorrect Early Use ([no-use-before-define](http://eslint.org/docs/rules/no-use-before-define)) [#636](https://github.com/standard/standard/issues/636) (0%) - Enforce that Promise rejections are passed an Error object as a reason ([prefer-promise-reject-errors](http://eslint.org/docs/rules/prefer-promise-reject-errors)) [#777](https://github.com/standard/standard/issues/777) (0%) - Enforce comparing `typeof` expressions against string literals ([valid-typeof](http://eslint.org/docs/rules/valid-typeof)) [#629](https://github.com/standard/standard/issues/629) (0%) - Enforce spacing around * in generator functions ([generator-star-spacing](http://eslint.org/docs/rules/generator-star-spacing)) [#724](https://github.com/standard/standard/issues/724) (0%) - Disallow Unnecessary Labels ([no-extra-label](http://eslint.org/docs/rules/no-extra-label)) [#736](https://github.com/standard/standard/issues/736) (0%) - Disallow spacing between template tags and their literals ([template-tag-spacing](http://eslint.org/docs/rules/template-tag-spacing)) [#755](https://github.com/standard/standard/issues/775) (0%) - Disallow padding within switch statements and classes ([padded-blocks](http://eslint.org/docs/rules/padded-blocks)) [#610](https://github.com/standard/standard/issues/610) (0%) - Enforce that Symbols are passed a description ([symbol-description](http://eslint.org/docs/rules/symbol-description)) [#630](https://github.com/standard/standard/issues/630) (0%) ### Changed rules - Relax rule: allow TypeScript Triple-Slash Directives ([spaced-comment](http://eslint.org/docs/rules/spaced-comment)) [#660](https://github.com/standard/standard/issues/660) - Relax rule: allow Flow Comments ([spaced-comment](http://eslint.org/docs/rules/spaced-comment)) [#661](https://github.com/standard/standard/issues/661) ## 8.6.0 - 2016-11-22 - Update ESLint from 3.8.x to 3.10.x - 3 additional rules are now fixable with `standard --fix` ## 8.5.0 - 2016-10-25 - Update ESLint from 3.7.x to 3.8.x - 2 additional rules are now fixable with `standard --fix` ## 8.4.0 - 2016-10-10 - Update ESLint from 3.6.x to 3.7.x - 5 additional rules are now fixable with `standard --fix` - Use more conservative semver ranges [#654](https://github.com/standard/standard/issues/654) ## 8.3.0 - 2016-09-29 The last release (`8.2.0`) added ES7 support. This release (`8.3.0`) adds ES8 support ...just 3 days later! This release should eliminate the need to specify `babel-eslint` as a custom parser, since `standard` can now parse ES8 (i.e. ES2017) syntax out of the box. That means `async` and `await` will just work. - Support ES8 (i.e. ES2017) syntax. ## 8.2.0 - 2016-09-26 For many users, this release should eliminate the need to specify `babel-eslint` as a custom parser, since `standard` can now parse ES7 (i.e. ES2016) syntax out of the box. - Support ES7 (i.e. ES2016) syntax. - Update ESLint from 3.5.x to 3.6.x - 4 additional rules are now fixable with `standard --fix` ## 8.1.0 - 2016-09-17 - Update ESLint from 3.3.x to 3.5.x - Around 10 additional rules are now fixable with `standard --fix` ## 8.0.0 - 2016-08-23 This release contains a bunch of goodies, including new rules that catch potential programmer errors (i.e. bugs) and enforce additional code consistency. However, the best feature is surely the new `--fix` command line flag to automatically fix problems. If you ever used [`standard-format`](https://www.npmjs.com/package/standard-format) and ran into issues with the lack of ES2015+ support, you'll be happy about `--fix`. `standard --fix` is built into `standard` v8.0.0 for maximum convenience, it supports ES2015, and it's lightweight (no additional dependencies since it's part of ESLint which powers `standard`). Lots of problems are already fixable, and more are getting added with each ESLint release. `standard` also outputs a message ("Run `standard --fix` to automatically fix some problems.") when it detects problems that can be fixed automatically so you can save time! With `standard` v8.0.0, we are also dropping support for Node.js versions prior to v4. Node.js 0.10 and 0.12 are in maintenance mode and will be unsupported at the end of 2016. Node.js 4 is the current LTS version. If you are using an older version of Node.js, we recommend upgrading to at least Node.js 4 as soon as possible. If you are unable to upgrade to Node.js 4 or higher, then we recommend continuing to use `standard` v7.x until you are ready to upgrade Node.js. **Important:** We will not be updating the `standard` v7.x versions going forward. All bug fixes and enhancements will land in `standard` v8.x. Full changelog below. Cheers! ### New features - Upgrade to ESLint v3 (http://eslint.org/docs/user-guide/migrating-to-3.0.0) [#565](https://github.com/standard/standard/pull/565) - **BREAKING:** Drop support for node < 4 (this was a decision made by the ESLint team) - Expose ESLint's `--fix` command line flag [#540](https://github.com/standard/standard/issues/540) [standard-engine/#107](https://github.com/Flet/standard-engine/issues/107) - Lightweight, no additional dependencies, fixes dozens of rules automatically ### New rules *(Estimated % of affected standard users, based on test suite in parens)* - Enforce placing object properties on separate lines ([object-property-newline](http://eslint.org/docs/rules/object-property-newline)) [#524](https://github.com/standard/standard/issues/524) (2%) - Require block comments to be balanced ([spaced-comment "balanced"](http://eslint.org/docs/rules/spaced-comment)) [#572](https://github.com/standard/standard/issues/572) (2%) - Disallow constant expressions in conditions ([no-constant-condition](http://eslint.org/docs/rules/no-constant-condition)) [#563](https://github.com/standard/standard/issues/563) (1%) - Disallow renaming import, export, and destructured assignments to the same name ([no-useless-rename](http://eslint.org/docs/rules/no-useless-rename)) [#537](https://github.com/standard/standard/issues/537) (0%) - Disallow spacing between rest and spread operators and their expressions ([rest-spread-spacing](http://eslint.org/docs/rules/rest-spread-spacing)) [#567](https://github.com/standard/standard/issues/567) (0%) - Disallow the Unicode Byte Order Mark (BOM) ([unicode-bom](http://eslint.org/docs/rules/unicode-bom)) [#538](https://github.com/standard/standard/issues/538) (0%) - Disallow assignment to native objects/global variables ([no-global-assign](http://eslint.org/docs/rules/no-global-assign)) [#596](https://github.com/standard/standard/issues/596) (0%) - Disallow negating the left operand of relational operators ([no-unsafe-negation](http://eslint.org/docs/rules/no-unsafe-negation)) [#595](https://github.com/standard/standard/issues/595) (0%) - Disallow template literal placeholder syntax in regular strings ([no-template-curly-in-string](http://eslint.org/docs/rules/no-template-curly-in-string)) [#594](https://github.com/standard/standard/issues/594) (0%) - Disallow tabs in file ([no-tabs](http://eslint.org/docs/rules/no-tabs)) [#593](https://github.com/standard/standard/issues/593) (0%) ### Changed rules - Relax rule: Allow template literal strings (backtick strings) to avoid escaping
 [#421](https://github.com/standard/standard/issues/421) - Relax rule: Do not enforce spacing around * in generator functions (https://github.com/standard/standard/issues/564#issuecomment-234699126) - This is a temporary workaround for `babel` users who use async generator functions. ## 7.1.2 - 2016-06-03 - Fix install errors for some users by updating eslint peer dependency ## 7.1.1 - 2016-05-26 - Add back full node 0.10, 0.12 support ## 7.1.0 - 2016-05-16 - Upgrade eslint to version ~2.10.2 ## 7.0.1 - 2016-05-04 - Relax "no-duplicate-imports" rule to not include `export` so the following is allowed: ```js import { foo } from 'bar' export * from 'bar' ``` ## 7.0.0 - 2016-05-02 ### Changes - Upgrade eslint to version ~2.9.0 - Remove "rules" configuration option [#367](https://github.com/standard/standard/issues/367) from `package.json` (Reasoning is [here](https://github.com/standard/standard/issues/399#issuecomment-180961891)) ### New rules *Estimated % of affected standard users, based on test suite* - Require camelCase ([camelcase](http://eslint.org/docs/rules/camelcase)) [4%] - Disallow unnecessary escape usage ([no-useless-escape](http://eslint.org/docs/rules/no-useless-escape)) [4% -- but, including many bugs] - Disallow duplicate imports ([no-duplicate-imports](http://eslint.org/docs/rules/no-duplicate-imports)) [0%] - Disallow unmodified conditions of loops ([no-unmodified-loop-condition](http://eslint.org/docs/2.0.0/rules/no-unmodified-loop-condition)) [0%] - Disallow whitespace before properties ([no-whitespace-before-property](http://eslint.org/docs/2.0.0/rules/no-whitespace-before-property)) [0%] - Disallow control flow statements in `finally` blocks ([no-unsafe-finally](http://eslint.org/docs/rules/no-unsafe-finally)) [0%] - Disallow unnecessary computed property keys on objects ([no-useless-computed-key](http://eslint.org/docs/rules/no-useless-computed-key)) [0%] - Validate spacing before closing bracket in JSX ([react/jsx-space-before-closing](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md)) [0%] ### Removed rules - Require parens in arrow function arguments ([arrow-parens](http://eslint.org/docs/rules/arrow-parens)) ## 6.0.8 - 2016-03-07 - Pin eslint to version ~2.2.0 - Update eslint-plugin-react to version 4.0.0 ## 6.0.7 - 2016-02-18 - Revert: Use install location of standard as eslint `cwd` (fixes [#429](https://github.com/standard/standard/issues/429)) ## 6.0.6 - 2016-02-18 - Use eslint 2.1.0 - Fix: Use install location of standard as eslint `cwd` (fixes [snazzy/#8](https://github.com/standard/snazzy/issues/8)) ## 6.0.5 - 2016-02-12 - Use eslint 2.0.0 stable ## 6.0.4 - 2016-02-07 - Relax rule: Validate closing bracket location in JSX ([jsx-closing-bracket-location](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md)) ## 6.0.3 - 2016-02-06 - Fix "Error: Cannot find module 'eslint-config-standard-jsx'" with npm 2 (node 0.10, 0.12, 4) ## 6.0.2 - 2016-02-06 - Internal change: Remove .eslintrc file, and use inline config ## 6.0.1 - 2016-02-05 - Internal change: Move .eslintrc file to root folder ## 6.0.0 - 2016-02-05 The goal of this release is to make `standard` faster to install, and simpler to use. ### Remove `standard-format` ([#340](https://github.com/standard/standard/issues/340)) ([#397](https://github.com/standard/standard/issues/397)) - Eliminates 250 packages, and cuts install time in half! - For npm 2, install time goes from 20 secs —> 10 secs. - For npm 3, install time goes from 24 secs —> 12 secs. - To continue using `standard-format`, just install it separately: `npm install -g standard-format` ### React-specific linting rules are removed ([#351](https://github.com/standard/standard/issues/351)) ([#367](https://github.com/standard/standard/issues/367)) ([eslint-config-standard-react/#13](https://github.com/standard/eslint-config-standard-react/pull/13)) - JSX is still supported, and it continues to be checked for style. - There were only a few React-specific rules, but they made it extremely difficult for users of alternatives like `virtual-dom` or `deku`, and unecessarily tied `standard` to a single library. - JSX rules come from `eslint-config-standard-jsx`. The `eslint-config-standard-react` dependency was removed. ### New Rules *The percentage (%) of users that rule changes will effect, based on real-world testing of the top ~400 npm packages is denoted in brackets.* - Disallow `__dirname`/`__filename` string concatenation ([#403](https://github.com/standard/standard/issues/403)) ([no-path-concat](http://eslint.org/docs/2.0.0/rules/no-path-concat)) [5%] - Require parens in arrow function arguments
 ([#309](https://github.com/standard/standard/issues/309)) ([arrow-parens](http://eslint.org/docs/2.0.0/rules/arrow-parens.html)) [5%] - Ensure that `new Promise()` is instantiated with the parameter names `resolve`, `reject` ([#282](https://github.com/standard/standard/issues/282)) ([promise/param-names](https://github.com/xjamundx/eslint-plugin-promise#param-names)) [1%] - Enforce Usage of Spacing in Template Strings ([template-curly-spacing](http://eslint.org/docs/2.0.0/rules/template-curly-spacing)) [1%] - Template strings are only allowed when necessary, i.e. template string features are being used (eslint got stricter: https://github.com/eslint/eslint/issues/5147) [1%] - Better dead code detection after conditional statements (eslint got stricter) [1%] - Enforce spaces around `*` in `yield * something` ([#335](https://github.com/standard/standard/issues/335)) ([yield-star-spacing](http://eslint.org/docs/2.0.0/rules/yield-star-spacing)) [0%] - Disallow labels on loops/switch statements too (made rule stricter) ([no-labels](http://eslint.org/docs/2.0.0/rules/no-labels.html)) [0%] - Disallow unnecessary constructor ([no-useless-constructor](http://eslint.org/docs/2.0.0/rules/no-useless-constructor)) [0%] - Disallow empty destructuring patterns ([no-empty-pattern](http://eslint.org/docs/2.0.0/rules/no-empty-pattern)) [0%] - Disallow Symbol Constructor ([no-new-symbol](http://eslint.org/docs/2.0.0/rules/no-new-symbol)) [0%] - Disallow Self Assignment ([no-self-assign](http://eslint.org/docs/2.0.0/rules/no-self-assign)) [0%] ### Removed Rules - `parseInt()` radix rule because ES5 fixes this issue ([#384](https://github.com/standard/standard/issues/384))
 ([radix](http://eslint.org/docs/2.0.0/rules/radix.html)) [0%] ### Expose eslint configuration via command line options and `package.json` For power users, it might be easier to use one of these new hooks instead of forking `standard`, though that's still encouraged, too! - Set eslint "plugins" ([#386](https://github.com/standard/standard/issues/386)) - Set eslint "rules" ([#367](https://github.com/standard/standard/issues/367)) - Set eslint "env" ([#371](https://github.com/standard/standard/issues/371)) To set custom ESLint plugins, rules, or envs, use the command line `--plugin`, `--rules`, and `--env` flags. In `package.json`, use the "standard" property: ```json { "standard": { "plugins": [ "my-plugin" ] } } ``` ### Upgrade to ESLint v2 - There may be slight behavior changes to existing rules. When possible, we've noted these in the "New Rules" and "Removed Rules" section. ### Improve test suite - Rule changes can be tested against every package on npm. For sanity, this is limited to packages with at least 4 dependents. Around ~400 packages. ### Known Issues - Using prerelease eslint version (2.0.0-rc.0). There may be breaking changes before the stable release. - `no-return-assign` behavior changed with arrow functions (https://github.com/eslint/eslint/issues/5150) ### Relevant diffs - standard ([v5.4.1...v6.0.0](https://github.com/standard/standard/compare/v5.4.1...v6.0.0)) - eslint-config-standard ([v4.4.0...v5.0.0](https://github.com/standard/eslint-config-standard/compare/v4.4.0...v5.0.0)) - eslint-config-standard-jsx ([v1.0.0](https://github.com/standard/eslint-config-standard-jsx/commit/47d5e248e2e078eb87619493999e3e74d4b7e70e)) - standard-engine ([v2.2.4...v3.2.1](https://github.com/Flet/standard-engine/compare/v2.2.4...v3.2.1)) ## 5.4.1 - 2015-11-16 [view diff](https://github.com/standard/standard/compare/v5.4.0...v5.4.1) ### Fixed * Fix for `standard-engine` change. Fix error tagline. ## 5.4.0 - 2015-11-16 [view diff](https://github.com/standard/standard/compare/v5.3.1...v5.4.0) ### Added * eslint-config-standard-react@1.2.0 ([history](eslint-config-standard-react)) * Disallow duplicate JSX properties ## 5.3.1 - 2015-09-18 [view diff](https://github.com/standard/standard/compare/v5.3.0...v5.3.1) ### Changed * eslint-plugin-react@3.4.2 ([history](eslint-plugin-react)) ## 5.3.0 - 2015-09-16 [view diff](https://github.com/standard/standard/compare/v5.2.2...v5.3.0) ### Changed * eslint-config-standard@4.4.0 ([history][eslint-config-standard]) * **New rule:** must have space after semicolon in for-loop ([commit](https://github.com/standard/eslint-config-standard/commit/6e5025eef8900f686e19b4a31836743d98323119)) * **New rule:** No default assignment with ternary operator ([commit](https://github.com/standard/eslint-config-standard/commit/0903c19ca6a8bc0c8625c41ca844ee69968bf948)) * **New rule:** Require spaces before keywords ([commit](https://github.com/standard/eslint-config-standard/commit/656ba93cda9cd4ab38e032649aafb795993d5176)) * eslint-config-standard-react@1.1.0 ([history][eslint-config-standard-react]) * eslint-plugin-react@3.4.0 ([history][eslint-plugin-react]) * eslint-plugin-standard@1.3.1 ([history][eslint-plugin-standard]) ## 5.2.2 [view diff](https://github.com/standard/standard/compare/v5.2.1...v5.2.2) ### Fixed * We have a changelog now, and you're reading it! * Minor README update * Removed direct dependency on `eslint` (its now moved to [standard-engine](https://github.com/flet/standard-engine)) ## 5.2.1 - 2015-09-03 [view diff](https://github.com/standard/standard/compare/v5.2.0...v5.2.1) ### Changed * eslint-config-standard@4.3.1 ([history][eslint-config-standard]) * **Revert rule**: Disallow unncessary concatenation of strings ### Fixed * eslint-config-standard@4.3.1 ([history][eslint-config-standard]) * fix regression with ternary operator handling ## 5.2.0 - 2015-09-03 [view diff](https://github.com/standard/standard/compare/v5.1.1...v5.2.0) ### Added * eslint-config-standard@4.3.0 ([history][eslint-config-standard]) * **New rule:** Disallow unncessary concatenation of strings * **New rule:** Disallow duplicate name in class members * **New rule:** enforce spaces inside of single line blocks * **Re-add rule:** padded-blocks ([Closes #170](https://github.com/standard/standard/issues/170)) ### Changed * Bump `eslint` from 1.1.0 to 1.3.1 ([CHANGELOG][eslint]) * eslint-plugin-standard@1.3.0 ([history][eslint-plugin-standard]) * A small change to make the plugin compatible with browserify which does not affect behavior. ### Fixed * eslint-plugin-react@3.3.1 ([CHANGELOG][eslint-plugin-react]) * Fix object rest/spread handling. * Added white background to badge.svg to make it work with dark backgrounds ([Closes #234](https://github.com/standard/standard/issues/234)) * Minor updates to README.md ## 5.1.1 - 2015-08-28 [view diff](https://github.com/standard/standard/compare/v5.1.0...v5.1.1) ### Fixed * Update to RULES.md to remove a missing hyperlink * Add atom linter information to README.md * Fixed duplicated word in the tagline message on the CLI * Removed failing repository from tests (yoshuawuyts/initialize) ## 5.1.0 - 2015-08-14 [view diff](https://github.com/standard/standard/compare/v5.0.2...v5.1.0) ## Fixed * eslint-config-standard@4.1.0 ([history][eslint-config-standard]) * Added rest/spread feature to `eslintrc.json` to fix [#226](https://github.com/standard/standard/issues/226) and [eslint-plugin-standard#3](https://github.com/xjamundx/eslint-plugin-standard/issues/3) * eslint-plugin-react@3.2.2 ([CHANGELOG][eslint-plugin-react]) * Fix crash when propTypes don't have any parent * Fix jsx-no-literals reporting errors outside JSX ### Changed * Bump eslint from 1.0.0 to 1.2.0 ([CHANGELOG][eslint]) * Added more test repositories and disabled some that were failing * Update bikeshedding link on README.md ## 5.0.2 - 2015-08-06 [view diff](https://github.com/standard/standard/compare/v5.0.1...v5.0.2) ### Changed * eslint-config-standard-react@1.0.4 ([history][eslint-config-standard-react]) - **Disable Rule:** react/wrap-multilines * Minor README updates ## 5.0.1 - 2015-08-05 [view diff](https://github.com/standard/standard/compare/v5.0.0...v5.0.1) ## 5.0.0 - 2015-08-03 [view diff](https://github.com/standard/standard/compare/v4.5.4...v5.0.0) ## 4.5.4 - 2015-07-13 [view diff](https://github.com/standard/standard/compare/v4.5.3...v4.5.4) ## 4.5.3 - 2015-07-10 [view diff](https://github.com/standard/standard/compare/v4.5.2...v4.5.3) ## 4.5.2 - 2015-07-02 [view diff](https://github.com/standard/standard/compare/v4.5.1...v4.5.2) ## 4.5.1 - 2015-06-30 [view diff](https://github.com/standard/standard/compare/v4.5.0...v4.5.1) ## 4.5.0 - 2015-06-30 [view diff](https://github.com/standard/standard/compare/v4.4.1...v4.5.0) ## 4.4.1 - 2015-06-29 [view diff](https://github.com/standard/standard/compare/v4.4.0...v4.4.1) ## 4.4.0 - 2015-06-27 [view diff](https://github.com/standard/standard/compare/v4.3.3...v4.4.0) ## 4.3.3 - 2015-06-26 [view diff](https://github.com/standard/standard/compare/v4.3.2...v4.3.3) ## 4.3.2 - 2015-06-23 [view diff](https://github.com/standard/standard/compare/v4.3.1...v4.3.2) ## 4.3.1 - 2015-06-18 [view diff](https://github.com/standard/standard/compare/v4.3.0...v4.3.1) ## 4.3.0 - 2015-06-16 [view diff](https://github.com/standard/standard/compare/v4.2.1...v4.3.0) ## 4.2.1 - 2015-06-12 [view diff](https://github.com/standard/standard/compare/v4.2.0...v4.2.1) ## 4.2.0 - 2015-06-11 [view diff](https://github.com/standard/standard/compare/v4.1.1...v4.2.0) ## 4.1.1 - 2015-06-11 [view diff](https://github.com/standard/standard/compare/v4.1.0...v4.1.1) ## 4.1.0 - 2015-06-10 [view diff](https://github.com/standard/standard/compare/v4.0.1...v4.1.0) ## 4.0.1 - 2015-06-01 [view diff](https://github.com/standard/standard/compare/v4.0.0...v4.0.1) ## 4.0.0 - 2015-05-30 [view diff](https://github.com/standard/standard/compare/v3.9.0...v4.0.0) [eslint-config-standard-react]: https://github.com/standard/eslint-config-standard-react/commits/master [eslint-config-standard]: https://github.com/standard/eslint-config-standard/commits/master [eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md [eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard/commits/master [eslint]: https://github.com/eslint/eslint/blob/master/CHANGELOG.md ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing Guidelines Contributions welcome! **Before spending lots of time on something, ask for feedback on your idea first!** Please search issues and pull requests before adding something new to avoid duplicating efforts and conversations. This project welcomes non-code contributions, too! The following types of contributions are welcome: - **Ideas**: participate in an issue thread or start your own to have your voice heard. - **Writing**: contribute your expertise in an area by helping expand the included docs. - **Copy editing**: fix typos, clarify language, and improve the quality of the docs. - **Formatting**: help keep docs easy to read with consistent formatting. ## Code Style [![happiness][happiness-image]][happiness-url] This repository uses [`happiness`][happiness-url] to maintain code style and consistency, and to avoid style arguments. `npm test` runs `happiness` automatically, so you don't have to! [happiness-image]: https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg [happiness-url]: https://github.com/JedWatson/happiness ## Project Governance Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a happiness guarded open source project. ### Rules There are a few basic ground-rules for contributors: 1. **No `--force` pushes** or modifying the Git history in any way. 2. **Non-master branches** should be used for ongoing work. 3. **Significant modifications** like API changes should be subject to a **pull request** to solicit feedback from other contributors. 4. **Pull requests** are *encouraged* for all contributions to solicit feedback, but left to the discretion of the contributor. ### Releases Declaring formal releases remains the prerogative of the project maintainer. ### Changes to this arrangement This is an experiment and feedback is welcome! This document may also be subject to pull- requests or changes by contributors where you believe you have something valuable to add or change. ## Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: - (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or - (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or - (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. - (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) Jed Watson 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. ================================================ FILE: README.md ================================================

One Style You Might Like

[![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [travis-image]: https://travis-ci.org/JedWatson/happiness.svg?branch=master [travis-url]: https://travis-ci.org/JedWatson/happiness [npm-image]: https://img.shields.io/npm/v/happiness.svg?style=flat [npm-url]: https://npmjs.org/package/happiness [downloads-image]: https://img.shields.io/npm/dm/happiness.svg?style=flat [downloads-url]: https://npmjs.org/package/happiness [Standard](https://github.com/feross/standard) customised to make [us](#maintainers) happy. This is a fork of Standard with two changes: - **Tabs** for indentions - **Semicolons** always It is called happiness, because we hope that it brings you joy, love and ends strife among your fellow developers. **Reminder**: Happiness is not for everyone. Some people will choose to be sad, normal and some might even say "standard". That is alright. A happy person is comfortable with being them and fine to let others be who they want to be. *"You do you"* If the information you are looking for is not in this readme, you should take a look at the [Standard readme](https://github.com/feross/standard), it might have what you are looking for. ## Install ```bash $ npm install happiness ``` ## Usage The easiest way to use JavaScript Happiness Style to check your code is to install it globally as a Node command line program. To do so, simply run the following command in your terminal (flag `-g` installs `happiness` globally on your system, omit it if you want to install in the current working directory): ```bash $ npm install happiness -g ``` After you've done that you should be able to use the `happiness` program. The simplest use case would be checking the style of all JavaScript files in the current working directory: ```bash $ happiness Error: Use JavaScript happiness Style lib/torrent.js:950:11: Expected '===' and instead saw '=='. ``` You can optionally pass in a directory (or directories) using the glob pattern. Be sure to quote paths containing glob patterns so that they are expanded by standard instead of your shell: ```bash $ happiness "src/util/**/*.js" "test/**/*.js" ``` Many people like to add happiness to their testing setup. To do this, save the packge as a dev dependency and add happiness to your package.json's test script: ```bash $ npm install --save-dev happiness ``` ```json { "scripts": { "test": "happiness && mocha # <- or whatever test runner you use" } } ``` **Note:** by default `happiness` will look for all files matching the patterns: `**/*.js`, `**/*.jsx`. ## Badge Use this in one of your projects? Include one of these badges in your readme to let people know that your code is using the standard style. [![js-happiness-style](https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg)](https://github.com/JedWatson/happiness) ```markdown [![js-happiness-style](https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg)](https://github.com/JedWatson/happiness) ``` [![js-happiness-style](https://img.shields.io/badge/code%20style-happiness-brightgreen.svg)](https://github.com/JedWatson/happiness) ```markdown [![js-happiness-style](https://img.shields.io/badge/code%20style-happiness-brightgreen.svg)](https://github.com/JedWatson/happiness) ``` ### Text editor plugins **Coming Soon** ## Maintainers - [Jed Watson](https://www.github.com/JedWatson) - [Daniel Cousens](https://www.github.com/dcousens) - [Wes Todd](https://www.github.com/wesleytodd) ### I want to contribute to `happiness`. What packages should I know about? - **[happiness](https://github.com/JedWatson/happiness)** - this repo - **[standard-engine](https://github.com/flet/standard-engine)** - cli engine for arbitrary eslint rules - **[eslint-config-happiness](https://github.com/wesleytodd/eslint-config-happiness)** - eslint rules for happiness - **[eslint-plugin-standard](https://github.com/xjamundx/eslint-plugin-standard)** - custom eslint rules for standard (not part of eslint core) - **[eslint](https://github.com/eslint/eslint)** - the linter that powers happiness - **[happiness-format]()** - **Coming Soon** automatic code formatter - **[snazzy](https://github.com/feross/snazzy)** - pretty terminal output for happiness ## License MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org). ================================================ FILE: RULES.md ================================================ ## JavaScript Happiness Style [![js-happiness-style](https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg)](https://github.com/JedWatson/happiness) This is a TL;DR of the [happiness](https://github.com/JedWatson/happiness) JavaScript rules. The best way to learn about `happiness` is to just install it and give it a try on your code. ## Rules * **Use tabs** for indentation. ```js function hello (name) { console.log('hi', name) } ``` * **Use single quotes for strings** except to avoid escaping. ```js console.log('hello there') $("
") ``` * **No unused variables.** ```js function myFunction () { var result = something() // ✗ avoid } ``` * **Add a space after keywords.** ```js if (condition) { ... } // ✓ ok if(condition) { ... } // ✗ avoid ``` * **Add a space before a function declaration's parentheses.** ```js function name (arg) { ... } // ✓ ok function name(arg) { ... } // ✗ avoid run(function () { ... }) // ✓ ok run(function() { ... }) // ✗ avoid ``` * **Always use** `===` instead of `==`.
Exception: `obj == null` is allowed to check for `null || undefined`. ```js if (name === 'John') // ✓ ok if (name == 'John') // ✗ avoid ``` ```js if (name !== 'John') // ✓ ok if (name != 'John') // ✗ avoid ``` * **Infix operators** must be spaced. ```js // ✓ ok var x = 2 var message = 'hello, ' + name + '!' ``` ```js // ✗ avoid var x=2 var message = 'hello, '+name+'!' ``` * **Commas should have a space** after them. ```js // ✓ ok var list = [1, 2, 3, 4] function greet (name, options) { ... } ``` ```js // ✗ avoid var list = [1,2,3,4] function greet (name,options) { ... } ``` * **Keep else statements** on the same line as their curly braces. ```js // ✓ ok if (condition) { // ... } else { // ... } ``` ```js // ✗ avoid if (condition) { // ... } else { // ... } ``` * **For multi-line if statements,** use curly braces. ```js // ✓ ok if (options.quiet !== true) console.log('done') ``` ```js // ✓ ok if (options.quiet !== true) { console.log('done') } ``` ```js // ✗ avoid if (options.quiet !== true) console.log('done') ``` * **Always handle the** `err` function parameter. ```js // ✓ ok run(function (err) { if (err) throw err window.alert('done') }) ``` ```js // ✗ avoid run(function (err) { window.alert('done') }) ``` * **Always prefix browser globals** with `window.`.
Exceptions are: `document`, `console` and `navigator`. ```js window.alert('hi') // ✓ ok ``` * **Multiple blank lines not allowed.** ```js // ✓ ok var value = 'hello world' console.log(value) ``` ```js // ✗ avoid var value = 'hello world' console.log(value) ``` * **For the ternary operator** in a multi-line setting, place `?` and `:` on their own lines. ```js // ✓ ok var location = env.development ? 'localhost' : 'www.api.com' // ✓ ok var location = env.development ? 'localhost' : 'www.api.com' // ✗ avoid var location = env.development ? 'localhost' : 'www.api.com' ``` * **For var declarations,** write each declaration in its own statement. ```js // ✓ ok var silent = true var verbose = true // ✗ avoid var silent = true, verbose = true // ✗ avoid var silent = true, verbose = true ``` * **Wrap conditional assignments** with additional parentheses. This makes it clear that the expression is intentionally an assignment (`=`) rather than a typo for equality (`===`). ```js // ✓ ok while ((m = text.match(expr))) { // ... } // ✗ avoid while (m = text.match(expr)) { // ... } ``` * ## Semicolons * Always use semicolons. ```js window.alert('hi'); // ✓ ok window.alert('hi') // ✗ avoid ``` ================================================ FILE: bin/cmd.js ================================================ #!/usr/bin/env node if (process.version.match(/v(\d+)\./)[1] < 4) { console.error('happiness: Node v4 or greater is required. `happiness` did not run.'); } else { var opts = require('../options'); require('standard-engine').cli(opts); } ================================================ FILE: bin/update-authors.sh ================================================ #!/bin/sh # Update AUTHORS.md based on git history. git log --reverse --format='%aN (%aE)' | perl -we ' BEGIN { %seen = (), @authors = (); } while (<>) { s/fletd01\@yahoo.com/flettre\@gmail.com/; next if $seen{$_}; next if /(support\@greenkeeper.io)/; next if /(nate\@ngoldman.me)/; next if /(ahmad\@codeinchaos.com)/; next if /(wayou )/; $seen{$_} = push @authors, "- ", $_; } END { print "# Authors\n\n"; print "#### Ordered by first contribution.\n\n"; print @authors, "\n"; print "#### Generated by bin/update-authors.sh.\n"; } ' > AUTHORS.md ================================================ FILE: docs/README-en.md ================================================

Standard - JavaScript Style Guide
JavaScript Standard Style

travis npm version npm downloads Standard - JavaScript Style Guide

One JavaScript Style to Rule Them All

EnglishEspañol (Latinoamérica)Italiano (Italian)한국어 (Korean)Português (Brasil)简体中文 (Simplified Chinese)繁體中文 (Taiwanese Mandarin)


## JavaScript style guide, with linter & automatic code fixer This module saves you (and others!) time in three ways: - **No configuration.** The easiest way to enforce consistent style in your project. Just drop it in. - **Automatically format code.** Just run `standard --fix` and say goodbye to messy or inconsistent code. - **Catch style issues & programmer errors early.** Save precious code review time by eliminating back-and-forth between reviewer & contributor. No decisions to make. No `.eslintrc`, `.jshintrc`, or `.jscsrc` files to manage. It just works. Install with: ``` npm install standard --save-dev ``` ## The Rules - **2 spaces** – for indentation - **Single quotes for strings** – except to avoid escaping - **No unused variables** – this one catches *tons* of bugs! - **No semicolons** – [It's][1] [fine.][2] [Really!][3] - **Never start a line with `(`, `[`, or `` ` ``** - This is the **only** gotcha with omitting semicolons – *automatically checked for you!* - [More details][4] - **Space after keywords** `if (condition) { ... }` - **Space after function name** `function name (arg) { ... }` - Always use `===` instead of `==` – but `obj == null` is allowed to check `null || undefined`. - Always handle the node.js `err` function parameter - Always prefix browser globals with `window` – except `document` and `navigator` are okay - Prevents accidental use of poorly-named browser globals like `open`, `length`, `event`, and `name`. - **And [more goodness][5]** – *give `standard` a try today!* [1]: http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding [2]: http://inimino.org/~inimino/blog/javascript_semicolons [3]: https://www.youtube.com/watch?v=gsfbh17Ax9I [4]: RULES.md#semicolons [5]: RULES.md#javascript-standard-style To get a better idea, take a look at [a sample file](https://github.com/expressjs/body-parser/blob/master/index.js) written in JavaScript Standard Style. Or, check out one of the [thousands of projects](https://raw.githubusercontent.com/standard/standard-packages/master/all.json) that use `standard`! ## Table of Contents - Quick start - [Install](#install) - [Usage](#usage) - [What you might do if you're clever](#what-you-might-do-if-youre-clever) - FAQ - [Why should I use JavaScript Standard Style?](#why-should-i-use-javascript-standard-style) - [Who uses JavaScript Standard Style?](#who-uses-javascript-standard-style) - [Are there text editor plugins?](#are-there-text-editor-plugins) - [Is there a readme badge?](#is-there-a-readme-badge) - [I disagree with rule X, can you change it?](#i-disagree-with-rule-x-can-you-change-it) - [But this isn't a real web standard!](#but-this-isnt-a-real-web-standard) - [Is there an automatic formatter?](#is-there-an-automatic-formatter) - [How do I ignore files?](#how-do-i-ignore-files) - [How do I hide a certain warning?](#how-do-i-hide-a-certain-warning) - [I use a library that pollutes the global namespace. How do I prevent "variable is not defined" errors?](#i-use-a-library-that-pollutes-the-global-namespace-how-do-i-prevent-variable-is-not-defined-errors) - [How do I use experimental JavaScript (ES Next) features?](#how-do-i-use-experimental-javascript-es-next-features) - [Can I use a JavaScript language variant, like Flow or TypeScript?](#can-i-use-a-javascript-language-variant-like-flow-or-typescript) - [What about Mocha, Jasmine, QUnit, etc?](#what-about-mocha-jasmine-qunit-etc) - [What about Web Workers?](#what-about-web-workers) - [Can I check code inside of Markdown or HTML files?](#can-i-check-code-inside-of-markdown-or-html-files) - [Is there a Git `pre-commit` hook?](#is-there-a-git-pre-commit-hook) - [How do I make the output all colorful and *pretty*?](#how-do-i-make-the-output-all-colorful-and-pretty) - [Is there a Node.js API?](#is-there-a-nodejs-api) - [How do I contribute to `standard`?](#how-do-i-contribute-to-standard) - [License](#license) ## Install The easiest way to use JavaScript Standard Style is to install it globally as a Node command line program. Run the following command in Terminal: ```bash $ npm install standard --global ``` Or, you can install `standard` locally, for use in a single project: ```bash $ npm install standard --save-dev ``` *Note: To run the preceding commands, [Node.js](http://nodejs.org) and [npm](https://npmjs.com) must be installed.* ## Usage After you've installed `standard`, you should be able to use the `standard` program. The simplest use case would be checking the style of all JavaScript files in the current working directory: ```bash $ standard Error: Use JavaScript Standard Style lib/torrent.js:950:11: Expected '===' and instead saw '=='. ``` You can optionally pass in a directory (or directories) using the glob pattern. Be sure to quote paths containing glob patterns so that they are expanded by `standard` instead of your shell: ```bash $ standard "src/util/**/*.js" "test/**/*.js" ``` **Note:** by default `standard` will look for all files matching the patterns: `**/*.js`, `**/*.jsx`. ## What you might do if you're clever 1. Add it to `package.json` ```json { "name": "my-cool-package", "devDependencies": { "standard": "*" }, "scripts": { "test": "standard && node my-tests.js" } } ``` 2. Style is checked automatically when you run `npm test` ```bash $ npm test Error: Use JavaScript Standard Style lib/torrent.js:950:11: Expected '===' and instead saw '=='. ``` 3. Never give style feedback on a pull request again! ## Why should I use JavaScript Standard Style? The beauty of JavaScript Standard Style is that it's simple. No one wants to maintain multiple hundred-line style configuration files for every module/project they work on. Enough of this madness! This module saves you (and others!) time in three ways: - **No configuration.** The easiest way to enforce consistent style in your project. Just drop it in. - **Automatically format code.** Just run `standard --fix` and say goodbye to messy or inconsistent code. - **Catch style issues & programmer errors early.** Save precious code review time by eliminating back-and-forth between reviewer & contributor. Adopting `standard` style means ranking the importance of code clarity and community conventions higher than personal style. This might not make sense for 100% of projects and development cultures, however open source can be a hostile place for newbies. Setting up clear, automated contributor expectations makes a project healthier. ## Who uses JavaScript Standard Style? Lots of folks! [](https://www.npmjs.com) | [](https://github.com) | [](https://opbeat.com) | [](http://www.nearform.com) | [](https://www.brave.com) | |---|---|---|---|---| | [](https://zeit.co) | [](https://www.zendesk.com) | [](https://www.mongodb.com) | [](https://www.typeform.com) | [](https://gds.blog.gov.uk) | |---|---|---|---|---| [](http://expressjs.com) | [](https://webtorrent.io) | [](https://ipfs.io) | [](https://datproject.org) | [](https://bitcoinjs.org) | |---|---|---|---|---| [](https://atom.io) | [](http://electron.atom.io) | [](https://voltra.co) | [](https://www.treasuredata.com) | [](https://clevertech.biz) | |---|---|---|---|---| [](https://www.apstudynotes.org) | [](https://www.optiopay.com) | [](https://www.jlrtechincubator.com/jlrti/) | [](https://www.bustle.com) | [](https://www.zentrick.com) | |---|---|---|---|---| [](https://nodesource.com) | [](https://greenkeeper.io) | [](https://karma-runner.github.io) | [](https://www.taser.com) | [](https://www.neo4j.com) | |---|---|---|---|---| [](https://rentograph.com) | |---|---|---|---|---| In addition to companies, many community members use `standard` on packages that are [too numerous](https://raw.githubusercontent.com/standard/standard-packages/master/all.json) to list here. `standard` is also the top-starred linter in GitHub's [Clean Code Linter](https://github.com/showcases/clean-code-linters) showcase. ## Are there text editor plugins? First, install `standard`. Then, install the appropriate plugin for your editor: ### Sublime Text Using **[Package Control][sublime-1]**, install **[SublimeLinter][sublime-2]** and **[SublimeLinter-contrib-standard][sublime-3]**. For automatic formatting on save, install **[StandardFormat][sublime-4]**. [sublime-1]: https://packagecontrol.io/ [sublime-2]: http://www.sublimelinter.com/en/latest/ [sublime-3]: https://packagecontrol.io/packages/SublimeLinter-contrib-standard [sublime-4]: https://packagecontrol.io/packages/StandardFormat ### Atom Install **[linter-js-standard][atom-1]**. Alternatively, you can install **[linter-js-standard-engine][atom-4]**. Instead of bundling a version of `standard` it will automatically use the version installed in your current project. It will also work out of the box with other linters based on **[standard-engine][atom-5]**. For automatic formatting, install **[standard-formatter][atom-2]**. For snippets, install **[standardjs-snippets][atom-3]**. [atom-1]: https://atom.io/packages/linter-js-standard [atom-2]: https://atom.io/packages/standard-formatter [atom-3]: https://atom.io/packages/standardjs-snippets [atom-4]: https://atom.io/packages/linter-js-standard-engine [atom-5]: https://github.com/Flet/standard-engine ### Visual Studio Code Install **[vscode-standardjs][vscode-1]**. (Includes support for automatic formatting.) For JS snippets, install: **[vscode-standardjs-snippets][vscode-2]**. For React snippets, install **[vscode-react-standard][vscode-3]**. [vscode-1]: https://marketplace.visualstudio.com/items/chenxsan.vscode-standardjs [vscode-2]: https://marketplace.visualstudio.com/items?itemName=capaj.vscode-standardjs-snippets [vscode-3]: https://marketplace.visualstudio.com/items/TimonVS.ReactSnippetsStandard ### Vim Install **[ale][vim-1]**. For automatic formatting on save, add these lines to `.vimrc`: ```vim autocmd bufwritepost *.js silent !standard --fix % set autoread ``` Alternative plugins to consider include [neomake][vim-2] and [syntastic][vim-3], both of which have built-in support for `standard` (though configuration may be necessary). [vim-1]: https://github.com/w0rp/ale [vim-2]: https://github.com/neomake/neomake [vim-3]: https://github.com/vim-syntastic/syntastic ### Emacs Install **[Flycheck][emacs-1]** and check out the **[manual][emacs-2]** to learn how to enable it in your projects. [emacs-1]: http://www.flycheck.org [emacs-2]: http://www.flycheck.org/en/latest/user/installation.html ### Brackets Search the extension registry for **["Standard Code Style"][brackets-1]** and click "Install". [brackets-1]: https://github.com/ishamf/brackets-standard/ ### WebStorm (PhpStorm, IntelliJ, RubyMine, JetBrains, etc.) WebStorm [recently announced native support](https://blog.jetbrains.com/webstorm/2017/01/webstorm-2017-1-eap-171-2272/) for `standard` directly in the IDE. If you still prefer to configure `standard` manually, [follow this guide][webstorm-1]. This applies to all JetBrains products, including PhpStorm, IntelliJ, RubyMine, etc. [webstorm-1]: webstorm.md ## Is there a readme badge? Yes! If you use `standard` in your project, you can include one of these badges in your readme to let people know that your code is using the standard style. [![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard) ```md [![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard) ``` [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) ```md [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) ``` ## I disagree with rule X, can you change it? No. The whole point of `standard` is to save you time by avoiding [bikeshedding][bikeshedding] about code style. There are lots of debates online about tabs vs. spaces, etc. that will never be resolved. These debates just distract from getting stuff done. At the end of the day you have to 'just pick something', and that's the whole philosophy of `standard` -- its a bunch of sensible 'just pick something' opinions. Hopefully, users see the value in that over defending their own opinions. If you really want to configure hundreds of ESLint rules individually, you can always use `eslint` directly with [eslint-config-standard](https://github.com/standard/eslint-config-standard) to layer your changes on top. Pro tip: Just use `standard` and move on. There are actual real problems that you could spend your time solving! :P [bikeshedding]: https://www.freebsd.org/doc/en/books/faq/misc.html#bikeshed-painting ## But this isn't a real web standard! Of course it's not! The style laid out here is not affiliated with any official web standards groups, which is why this repo is called `standard/standard` and not `ECMA/standard`. The word "standard" has more meanings than just "web standard" :-) For example: - This module helps hold our code to a high *standard of quality*. - This module ensures that new contributors follow some basic *style standards*. ## Is there an automatic formatter? Yes! You can use `standard --fix` to fix most issues automatically. `standard --fix` is built into `standard` for maximum convenience. Most problems are fixable, but some errors (like forgetting to handle errors) must be fixed manually. To save you time, `standard` outputs the message "`Run standard --fix to automatically fix some problems`" when it detects problems that can be fixed automatically. ## How do I ignore files? Certain paths (`node_modules/`, `coverage/`, `vendor/`, `*.min.js`, `bundle.js`, and files/folders that begin with `.` like `.git/`) are automatically ignored. Paths in a project's root `.gitignore` file are also automatically ignored. Sometimes you need to ignore additional folders or specific minified files. To do that, add a `standard.ignore` property to `package.json`: ```json "standard": { "ignore": [ "**/out/", "/lib/select2/", "/lib/ckeditor/", "tmp.js" ] } ``` ## How do I hide a certain warning? In rare cases, you'll need to break a rule and hide the warning generated by `standard`. JavaScript Standard Style uses [ESLint](http://eslint.org/) under-the-hood and you can hide warnings as you normally would if you used ESLint directly. To get verbose output (so you can find the particular rule name to ignore), run: ```bash $ standard --verbose Error: Use JavaScript Standard Style routes/error.js:20:36: 'file' was used before it was defined. (no-use-before-define) ``` Disable **all rules** on a specific line: ```js file = 'I know what I am doing' // eslint-disable-line ``` Or, disable **only** the `"no-use-before-define"` rule: ```js file = 'I know what I am doing' // eslint-disable-line no-use-before-define ``` Or, disable the `"no-use-before-define"` rule for **multiple lines**: ```js /* eslint-disable no-use-before-define */ console.log('offending code goes here...') console.log('offending code goes here...') console.log('offending code goes here...') /* eslint-enable no-use-before-define */ ``` ## I use a library that pollutes the global namespace. How do I prevent "variable is not defined" errors? Some packages (e.g. `mocha`) put their functions (e.g. `describe`, `it`) on the global object (poor form!). Since these functions are not defined or `require`'d anywhere in your code, `standard` will warn that you're using a variable that is not defined (usually, this rule is really useful for catching typos!). But we want to disable it for these global variables. To let `standard` (as well as humans reading your code) know that certain variables are global in your code, add this to the top of your file: ```js /* global myVar1, myVar2 */ ``` If you have hundreds of files, it may be desirable to avoid adding comments to every file. In this case, run: ```bash $ standard --global myVar1 --global myVar2 ``` Or, add this to `package.json`: ```json { "standard": { "globals": [ "myVar1", "myVar2" ] } } ``` *Note: `global` and `globals` are equivalent.* ## How do I use experimental JavaScript (ES Next) features? `standard` supports the latest ECMAScript features, ES8 (ES2017), including language feature proposals that are in "Stage 4" of the proposal process. To support experimental language features, `standard` supports specifying a custom JavaScript parser. Before using a custom parser, consider whether the added complexity is worth it. To use a custom parser, first install it from npm: ```bash npm install babel-eslint --save-dev ``` Then run: ```bash $ standard --parser babel-eslint ``` Or, add this to `package.json`: ```json { "standard": { "parser": "babel-eslint" } } ``` If `standard` is installed globally (i.e. `npm install standard --global`), then be sure to install `babel-eslint` globally as well, with `npm install babel-eslint --global`. ## Can I use a JavaScript language variant, like Flow or TypeScript? `standard` supports the latest ECMAScript features. However, Flow and TypeScript add new syntax to the language, so they are not supported out-of-the-box. To support JavaScript language variants, `standard` supports specifying a custom JavaScript parser as well as an ESLint plugin to handle the changed syntax. Before using a JavaScript language variant, consider whether the added complexity is worth it. ### Flow To use Flow, you need to run `standard` with `babel-eslint` as the parser and `eslint-plugin-flowtype` as a plugin. ```bash npm install babel-eslint eslint-plugin-flowtype --save-dev ``` Then run: ```bash $ standard --parser babel-eslint --plugin flowtype ``` Or, add this to `package.json`: ```json { "standard": { "parser": "babel-eslint", "plugins": [ "flowtype" ] } } ``` *Note: `plugin` and `plugins` are equivalent.* If `standard` is installed globally (i.e. `npm install standard --global`), then be sure to install `babel-eslint` and `eslint-plugin-flowtype` globally as well, with `npm install babel-eslint eslint-plugin-flowtype --global`. ### TypeScript To use TypeScript, you need to run `standard` with `typescript-eslint-parser` as the parser, `eslint-plugin-typescript` as a plugin, and tell standard to lint `*.ts` files (since it doesn't by default). ```bash npm install typescript-eslint-parser eslint-plugin-typescript --save-dev ``` Then run: ```bash $ standard --parser typescript-eslint-parser --plugin typescript *.ts ``` Or, add this to `package.json`: ```json { "standard": { "parser": "typescript-eslint-parser", "plugins": [ "typescript" ] } } ``` With that in `package.json`, you can run: ```bash standard *.ts ``` If `standard` is installed globally (i.e. `npm install standard --global`), then be sure to install `typescript-eslint-parser` and `eslint-plugin-typescript` globally as well, with `npm install typescript-eslint-parser eslint-plugin-typescript --global`. ## What about Mocha, Jasmine, QUnit, etc? To support mocha in test files, add this to the top of the test files: ```js /* eslint-env mocha */ ``` Or, run: ```bash $ standard --env mocha ``` Where `mocha` can be one of `jasmine`, `qunit`, `phantomjs`, and so on. To see a full list, check ESLint's [specifying environments](http://eslint.org/docs/user-guide/configuring.html#specifying-environments) documentation. For a list of what globals are available for these environments, check the [globals](https://github.com/sindresorhus/globals/blob/master/globals.json) npm module. *Note: `env` and `envs` are equivalent.* ## What about Web Workers? Add this to the top of worker files: ```js /* eslint-env serviceworker */ ``` This lets `standard` (as well as humans reading the code) know that `self` is a global in web worker code. ## Can I check code inside of Markdown or HTML files? To check code inside Markdown files, use [`standard-markdown`](https://www.npmjs.com/package/standard-markdown). Alternatively, there are ESLint plugins that can check code inside Markdown, HTML, and many other types of language files: To check code inside Markdown files, use an ESLint plugin: ```bash $ npm install eslint-plugin-markdown ``` Then, to check JS that appears inside code blocks, run: ```bash $ standard --plugin markdown '**/*.md' ``` To check code inside HTML files, use an ESLint plugin: ```bash $ npm install eslint-plugin-html ``` Then, to check JS that appears inside `