Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: standard/standard
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3f88a12d661d936612c6f5337ee8085d014d31e5
Choose a base ref
...
head repository: standard/standard
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a5994268773a1c12d9e1e23c786ed8f7e90d41e5
Choose a head ref

Commits on Nov 24, 2016

  1. Portuguese version

    alexmoreno committed Nov 24, 2016
    Copy the full SHA
    898537c View commit details
  2. Portuguese version

    alexmoreno committed Nov 24, 2016
    Copy the full SHA
    489f850 View commit details

Commits on Nov 25, 2016

  1. Updated configuration file for WebStorm

    <XML> is now required in the configuration.
    <option name="SPACE_WITHIN_BRACKETS" value="true" /> contradicts the code style used  in the samples (`var list = [1, 2, 3, 4]`)
    prigara authored Nov 25, 2016
    Copy the full SHA
    cf85c03 View commit details
  2. Copy the full SHA
    a2ce522 View commit details
  3. Merge pull request #705 from prigara/master

    Updated configuration file for WebStorm
    feross authored Nov 25, 2016
    Copy the full SHA
    d68e968 View commit details

Commits on Dec 7, 2016

  1. Update RULES.md

    Remove unnecessary `*`
    Erik Müller authored Dec 7, 2016
    Copy the full SHA
    ef17442 View commit details
  2. Merge pull request #713 from erikmueller/patch-1

    Update RULES.md
    dcousens authored Dec 7, 2016
    Copy the full SHA
    d99fc38 View commit details

Commits on Dec 9, 2016

  1. Copy the full SHA
    2b9afb6 View commit details

Commits on Jan 7, 2017

  1. Added --save-dev to readme

    I think it would make sense to add the `--save-dev` flag, since this would mean `standard` is installed when people clone and `npm install` a project. Since one advantage is that teams have a common base, this seems to be a typical use case.
    Lukas Oppermann authored Jan 7, 2017
    Copy the full SHA
    a58296f View commit details

Commits on Jan 8, 2017

  1. Merge pull request #739 from lukasoppermann/patch-1

    Added --save-dev to readme
    feross authored Jan 8, 2017
    Copy the full SHA
    3b433fc View commit details

Commits on Jan 10, 2017

  1. Add reference to responsible rule in RULES.md

    Joshua P. Colvin committed Jan 10, 2017
    Copy the full SHA
    153a3ff View commit details

Commits on Jan 13, 2017

  1. Merge pull request #741 from joshuacolvin/eslint-rules

    Add reference to responsible rule in RULES.md
    feross authored Jan 13, 2017
    Copy the full SHA
    028e0dc View commit details

Commits on Jan 14, 2017

  1. Merge pull request #702 from alexmoreno/master

    Added portuguese version
    feross authored Jan 14, 2017
    Copy the full SHA
    555f1a0 View commit details
  2. readme: clarify ignore text

    feross committed Jan 14, 2017
    Copy the full SHA
    ca323e0 View commit details
  3. move translations into docs/

    feross committed Jan 14, 2017
    Copy the full SHA
    493720b View commit details
  4. Copy the full SHA
    566b8b8 View commit details
  5. Copy the full SHA
    d13767b View commit details
  6. Copy the full SHA
    4cc9270 View commit details
  7. Copy the full SHA
    36eef5f View commit details

Commits on Jan 16, 2017

  1. Merge pull request #748 from falmar/spanish-docs

    add readme & rules in spanish
    feross authored Jan 16, 2017
    Copy the full SHA
    1e75ce3 View commit details

Commits on Jan 20, 2017

  1. Copy the full SHA
    949181f View commit details
  2. Copy the full SHA
    9219218 View commit details
  3. Merge pull request #752 from feross/translation-links

    Add translation links between language versions
    feross authored Jan 20, 2017
    Copy the full SHA
    e6b623c View commit details
  4. Lots of readme improvements

    - Add a new "How do I check code inside of Markdown or HTML files?"
    section
    - Merge the "Can you make rule X configurable?" section with "I
    disagree with rule X, can you change it?"
    - Document command line flags like --parser, --env, --global and their
    aliases
    - Remove link to overcommit, because it's installed with RubyGems,
    something not all our users will have
    - Document that WebStorm supports `standard` natively now!
    feross committed Jan 20, 2017
    Copy the full SHA
    86e0454 View commit details

Commits on Jan 21, 2017

  1. Copy the full SHA
    f6745d0 View commit details
  2. Fix minor typos

    falmar committed Jan 21, 2017
    Copy the full SHA
    bf1de47 View commit details

Commits on Jan 23, 2017

  1. Merge pull request #753 from feross/readme

    Lots of readme improvements
    feross authored Jan 23, 2017
    Copy the full SHA
    228302e View commit details
  2. Merge pull request #754 from falmar/spanish-readme

    Fixes and updates on README-esla.md according to changes on PR #753
    feross authored Jan 23, 2017
    Copy the full SHA
    6f2d821 View commit details

Commits on Jan 24, 2017

  1. Update webstorm.md

    force to put space before closing bracket tag  <div_/>. see https://twitter.com/webstormide/status/705688309079654400
    yanxi123-com authored Jan 24, 2017
    Copy the full SHA
    b7438bb View commit details
  2. fix #760

    callmecavs authored Jan 24, 2017
    Copy the full SHA
    847ef63 View commit details
  3. Copy the full SHA
    821add0 View commit details
  4. Copy the full SHA
    a160e94 View commit details
  5. Copy the full SHA
    b144218 View commit details

Commits on Jan 25, 2017

  1. Merge pull request #759 from yanxi-me/patch-1

    Update webstorm.md
    feross authored Jan 25, 2017
    Copy the full SHA
    a594b38 View commit details

Commits on Jan 26, 2017

  1. Add more rules

    joshuacolvin committed Jan 26, 2017
    Copy the full SHA
    d73bc76 View commit details

Commits on Jan 27, 2017

  1. Ignore misc package files

    Usually I'm against this kind of hyper-optimizing. But unlike most
    modules, the tests aren't really very useful documentation about how
    `standard` works. We have README.md and RULES.md for that.
    feross committed Jan 27, 2017
    Copy the full SHA
    714b7b9 View commit details
  2. Merge pull request #765 from feross/feross/npmignore

    Ignore misc package files
    feross authored Jan 27, 2017
    Copy the full SHA
    5d8c175 View commit details
  3. readme: Add company logos, other readme cleanup

    For: #744
    
    Moved some of the early sections ("Badge", "Text editor plugins") into
    the FAQ section, so important sections like "Why should I use
    JavaScript Standard Style?" and "Who uses JavaScript Standard Style?"
    come first. Once they're convinced, the can read about badges and text
    editor plugins.
    
    - Renamed, reordered some sections.
    - Converted h3s into h2s since it delineates the sections better
    feross committed Jan 27, 2017
    Copy the full SHA
    6920b66 View commit details
  4. Merge pull request #764 from feross/feross/readme

    readme: Add company logos, other readme cleanup
    feross authored Jan 27, 2017
    Copy the full SHA
    ba4daca View commit details
  5. readme: fix broken toc link

    feross committed Jan 27, 2017
    Copy the full SHA
    6a42fd9 View commit details
  6. readme: fix toc link

    feross committed Jan 27, 2017
    Copy the full SHA
    9aa1c0b View commit details

Commits on Jan 29, 2017

  1. Copy the full SHA
    e538a4c View commit details
  2. Merge pull request #767 from despia/patch-1

    added missing "/" in github logo link
    feross authored Jan 29, 2017
    Copy the full SHA
    5b973b6 View commit details
  3. Copy the full SHA
    33997d6 View commit details

Commits on Jan 30, 2017

  1. Copy the full SHA
    5eaeb61 View commit details

Commits on Jan 31, 2017

  1. Merge pull request #763 from joshuacolvin/rules

    WIP - Add missing rules to RULES.md
    feross authored Jan 31, 2017
    Copy the full SHA
    a526758 View commit details

Commits on Feb 6, 2017

  1. Fix typos

    peterjenkins committed Feb 6, 2017
    Copy the full SHA
    bca2434 View commit details

Commits on Feb 7, 2017

  1. Merge pull request #774 from peterjenkins/patch-1

    Fix typos
    LinusU authored Feb 7, 2017

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    4f5ec53 View commit details

Commits on Feb 8, 2017

  1. Copy the full SHA
    57f9c79 View commit details

Commits on Feb 9, 2017

  1. travis: add node v6

    feross committed Feb 9, 2017
    Copy the full SHA
    57d1b8a View commit details
Showing with 13,833 additions and 1,072 deletions.
  1. +9 −0 .editorconfig
  2. +5 −0 .npmignore
  3. +1 −0 .travis.yml
  4. +46 −1 AUTHORS.md
  5. +271 −78 CHANGELOG.md
  6. +2 −2 CONTRIBUTING.md
  7. +0 −601 README.md
  8. +1 −0 README.md
  9. +0 −335 RULES.md
  10. +1 −0 RULES.md
  11. +43 −0 SECURITY.md
  12. +0 −1 bin/cmd.js
  13. +3 −0 bin/update-authors.sh
  14. +781 −0 docs/README-en.md
  15. +667 −0 docs/README-esla.md
  16. +680 −0 docs/README-iteu.md
  17. +697 −0 docs/README-kokr.md
  18. +574 −0 docs/README-ptbr.md
  19. +639 −0 docs/README-zhcn.md
  20. +622 −0 docs/README-zhtw.md
  21. +1,405 −0 docs/RULES-en.md
  22. +1,389 −0 docs/RULES-esla.md
  23. +1,393 −0 docs/RULES-iteu.md
  24. +1,397 −0 docs/RULES-kokr.md
  25. +339 −0 docs/RULES-ptbr.md
  26. +1,398 −0 docs/RULES-zhcn.md
  27. +1,395 −0 docs/RULES-zhtw.md
  28. BIN docs/logos/atom.png
  29. BIN docs/logos/bitcoinjs.png
  30. BIN docs/logos/brave.png
  31. BIN docs/logos/bustle.jpg
  32. BIN docs/logos/clevertech.png
  33. BIN docs/logos/ctrl-alt-deseat.png
  34. BIN docs/logos/dat.png
  35. BIN docs/logos/eaze.png
  36. BIN docs/logos/electron.png
  37. BIN docs/logos/express.png
  38. BIN docs/logos/github.png
  39. BIN docs/logos/gov-uk.png
  40. BIN docs/logos/greenkeeper.png
  41. BIN docs/logos/ipfs.png
  42. BIN docs/logos/jaguar-landrover.png
  43. BIN docs/logos/karma.png
  44. BIN docs/logos/mongodb.jpg
  45. BIN docs/logos/nearform.png
  46. BIN docs/logos/neo4j.png
  47. BIN docs/logos/nodesource.png
  48. BIN docs/logos/npm.png
  49. BIN docs/logos/opbeat.png
  50. BIN docs/logos/optiopay.png
  51. BIN docs/logos/rentograph.png
  52. BIN docs/logos/studynotes.jpg
  53. BIN docs/logos/taser.png
  54. BIN docs/logos/treasuredata.png
  55. BIN docs/logos/typeform.jpg
  56. BIN docs/logos/voltra.png
  57. BIN docs/logos/webtorrent.png
  58. BIN docs/logos/zeit.png
  59. BIN docs/logos/zendesk.png
  60. BIN docs/logos/zentrick.png
  61. +15 −12 docs/webstorm.md
  62. +20 −18 package.json
  63. +40 −24 test/clone.js
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
test/
docs/logos/
tmp/
bin/update-authors.sh
.npmignore
badge.png
badge.svg
CONTRIBUTING.md
sticker.png
sticker.svg
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: node_js
node_js:
- '4'
- '6'
- 'node'
47 changes: 46 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

- Feross Aboukhadijeh (feross@feross.org)
- Jonny Buchanan (jonathan.buchanan@gmail.com)
- Dan Flettre (fletd01@yahoo.com)
- Dan Flettre (flettre@gmail.com)
- Brandon Horst (brandonhorst@gmail.com)
- Yoshua Wuyts (yoshuawuyts@gmail.com)
- Alexander Gugel (alexander.gugel@gmail.com)
@@ -73,5 +73,50 @@
- Linus Unnebäck (linus@folkdatorn.se)
- sam (chenxsan@gmail.com)
- Robin Whittleton (robin.whittleton@digital.cabinet-office.gov.uk)
- Alex Moreno (alexmorenodealmeida@gmail.com)
- Ekaterina Prigara (ekaterina@prigara.com)
- Erik Müller (e.mueller@epages.com)
- Lukas Oppermann (oppermann.lukas@googlemail.com)
- Joshua P. Colvin (colvinj@ewashtenaw.org)
- David Lavieri (daviddlavier@gmail.com)
- Yanxi (blogbbs@gmail.com)
- Michael Cavalea (callmecavs@gmail.com)
- Joshua Colvin (joshua@joshuacolvin.net)
- despia (despia@users.noreply.github.com)
- Peter Jenkins (peterjenkins@users.noreply.github.com)
- nyuszika7h (nyuszika7h@openmailbox.org)
- Asoul Yang (azx754@gmail.com)
- Peter Dave Hello (hsu@peterdavehello.org)
- Wayou Liu (liuwayong@gmail.com)
- Thomas Watson (w@tson.dk)
- Pablo Varela (pablopunk@users.noreply.github.com)
- xiaoyu2er (zongyanqi@foxmail.com)
- devjin0617 (devjin0617@gmail.com)
- ehmicky (ehmicky@users.noreply.github.com)
- Stanislav Termosa (termosa.stanislav@gmail.com)
- yanxiaodi (929213769@qq.com)
- developerjin (devjin0617@gmail.com)
- Mark Peace (mark.peace@neotechnology.com)
- Alexandre Nicastro (kryndex@gmail.com)
- Ivan Ying (yyjazsf@live.cn)
- 薛定谔的猫 (hh_2013@foxmail.com)
- Robin (almigod0718@gmail.com)
- Stoppa, Emanuele (emanuele.stoppa@baml.com)
- CafeLungo (CafeLungo@users.noreply.github.com)
- Antério Vieira (anteriovieira@gmail.com)
- Bret Comnes (bcomnes@gmail.com)
- Jared Reich (jaredreich@gmail.com)
- Igor Santos (igorsantos07@gmail.com)
- daper (david@daper.email)
- Sola (airsolakey@icloud.com)
- Lion Yang (lion@aosc.xyz)
- Joseph Frazier (1212jtraceur@gmail.com)
- Emanuele (my.burning@gmail.com)
- Jakob Krigovsky (jakob@krigovsky.com)
- Joe Boyle (joe.boyle@jibo.com)
- Pablo Varela (pablovarela182@gmail.com)
- Luan Vicente (hi@idlua.me)
- Tony Finn (tony@tonyfinn.com)
- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com)

#### Generated by bin/update-authors.sh.
349 changes: 271 additions & 78 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@ This repository uses [`standard`][standard-url] to maintain code style and consi
and to avoid style arguments. `npm test` runs `standard` automatically, so you don't have
to!

[standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg
[standard-url]: https://github.com/feross/standard
[standard-image]: https://cdn.rawgit.com/standard/standard/master/badge.svg
[standard-url]: https://github.com/standard/standard

## Project Governance

601 changes: 0 additions & 601 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
335 changes: 0 additions & 335 deletions RULES.md

This file was deleted.

1 change: 1 addition & 0 deletions RULES.md
43 changes: 43 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Security Policies and Procedures

This document outlines security procedures and general policies for the `standard`
project.

* [Reporting a Bug](#reporting-a-bug)
* [Disclosure Policy](#disclosure-policy)
* [Comments on this Policy](#comments-on-this-policy)

## Reporting a Bug

The `standard` team and community take all security bugs in `standard` seriously.
Thank you for improving the security of `standard`. We appreciate your efforts and
responsible disclosure and will make every effort to acknowledge your
contributions.

Report security bugs by emailing the lead maintainer at feross@feross.org.

The lead maintainer will acknowledge your email within 48 hours, and will send a
more detailed response within 48 hours indicating the next steps in handling
your report. After the initial reply to your report, the security team will
endeavor to keep you informed of the progress towards a fix and full
announcement, and may ask for additional information or guidance.

Report security bugs in third-party modules to the person or team maintaining
the module. You can also report a vulnerability through the
[Node Security Project](https://nodesecurity.io/report).

## Disclosure Policy

When the security team receives a security bug report, they will assign it to a
primary handler. This person will coordinate the fix and release process,
involving the following steps:

* Confirm the problem and determine the affected versions.
* Audit code to find any potential similar problems.
* Prepare fixes for all releases still under maintenance. These fixes will be
released as fast as possible to npm.

## Comments on this Policy

If you have suggestions on how this process could be improved please submit a
pull request.
1 change: 0 additions & 1 deletion bin/cmd.js
Original file line number Diff line number Diff line change
@@ -6,4 +6,3 @@ if (process.version.match(/v(\d+)\./)[1] < 4) {
var opts = require('../options')
require('standard-engine').cli(opts)
}

3 changes: 3 additions & 0 deletions bin/update-authors.sh
Original file line number Diff line number Diff line change
@@ -6,10 +6,13 @@ 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 {
781 changes: 781 additions & 0 deletions docs/README-en.md

Large diffs are not rendered by default.

667 changes: 667 additions & 0 deletions docs/README-esla.md

Large diffs are not rendered by default.

680 changes: 680 additions & 0 deletions docs/README-iteu.md

Large diffs are not rendered by default.

697 changes: 697 additions & 0 deletions docs/README-kokr.md

Large diffs are not rendered by default.

574 changes: 574 additions & 0 deletions docs/README-ptbr.md

Large diffs are not rendered by default.

639 changes: 639 additions & 0 deletions docs/README-zhcn.md

Large diffs are not rendered by default.

622 changes: 622 additions & 0 deletions docs/README-zhtw.md

Large diffs are not rendered by default.

1,405 changes: 1,405 additions & 0 deletions docs/RULES-en.md

Large diffs are not rendered by default.

1,389 changes: 1,389 additions & 0 deletions docs/RULES-esla.md

Large diffs are not rendered by default.

1,393 changes: 1,393 additions & 0 deletions docs/RULES-iteu.md

Large diffs are not rendered by default.

1,397 changes: 1,397 additions & 0 deletions docs/RULES-kokr.md

Large diffs are not rendered by default.

339 changes: 339 additions & 0 deletions docs/RULES-ptbr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
# JavaScript Standard Style

<p align="center">
<a href="/docs/RULES-en.md">English</a> •
<a href="/docs/RULES-esla.md">Español (Latinoamérica)</a> •
<a href="/docs/RULES-iteu.md">Italiano (Italian)</a> •
<a href="/docs/RULES-kokr.md">한국어 (Korean)</a> •
<a href="/docs/RULES-ptbr.md">Português (Brasil)</a> •
<a href="/docs/RULES-zhcn.md">简体中文 (Simplified Chinese)</a> •
<a href="/docs/RULES-zhtw.md">繁體中文 (Taiwanese Mandarin)</a>
</p>

[![js-standard-style](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

Esse é um "TL;DR" (ou "muito grande; nemli") das regras do [standard](https://github.com/standard/standard)

A melhor forma de aprender sobre o `standard` é instalar e usar no seu código.


## Regras

* **Use 2 espaços** para identação.

```js
function hello (name) {
console.log('oi', name)
}
```

* **Use aspas simples para strings** exceto para evitar escapamento.

```js
console.log('olá, meu povo')
$("<div class='box'>")
```

* **Sem variáveis não-utilizadas.**

```js
function myFunction () {
var result = something() // ✗ evite
}
```

* **Adicione um espaço após as keywords.**

```js
if (condition) { ... } // ✓ ok
if(condition) { ... } // ✗ evite
```

* **Adicione um espaço antes do parêntese de declaração de funções.**

```js
function name (arg) { ... } // ✓ ok
function name(arg) { ... } // ✗ evite

run(function () { ... }) // ✓ ok
run(function() { ... }) // ✗ evite
```

* **Sempre use** `===` ao invés de `==`.<br>
Exceção: `obj == null` é permitido pra checar se `null || undefined`.

```js
if (name === 'John') // ✓ ok
if (name == 'John') // ✗ evite
```

```js
if (name !== 'John') // ✓ ok
if (name != 'John') // ✗ evite
```

* **Operadores infix** devem ser espaçados.

```js
// ✓ ok
var x = 2
var message = 'hello, ' + name + '!'
```

```js
// ✗ evite
var x=2
var message = 'hello, '+name+'!'
```

* **Vírgulas devem ter um espaço** depois delas.

```js
// ✓ ok
var list = [1, 2, 3, 4]
function greet (name, options) { ... }
```

```js
// ✗ evite
var list = [1,2,3,4]
function greet (name,options) { ... }
```

* **Mantenha os else** na mesma linha das suas chaves.

```js
// ✓ ok
if (condition) {
// ...
} else {
// ...
}
```

```js
// ✗ evite
if (condition) {
// ...
}
else {
// ...
}
```

* **Para ifs com mais de uma linha,** use chaves.

```js
// ✓ ok
if (options.quiet !== true) console.log('done')
```

```js
// ✓ ok
if (options.quiet !== true) {
console.log('done')
}
```

```js
// ✗ evite
if (options.quiet !== true)
console.log('done')
```

* **Sempre lide ** com o parâmetro `err` .

```js
// ✓ ok
run(function (err) {
if (err) throw err
window.alert('done')
})
```

```js
// ✗ evite
run(function (err) {
window.alert('done')
})
```

* **Sempre prefixe globais de browser** com `window.`.<br>
Exceções: `document`, `console` e `navigator`.

```js
window.alert('hi') // ✓ ok
```

* **Não é permitido múltiplas linhas em branco.**

```js
// ✓ ok
var value = 'hello world'
console.log(value)
```

```js
// ✗ evite
var value = 'hello world'


console.log(value)
```

* **Se for usar operador ternário** em múltiplas linhas, deixe `?` e `:` em suas próprias linhas.

```js
// ✓ ok
var location = env.development ? 'localhost' : 'www.api.com'

// ✓ ok
var location = env.development
? 'localhost'
: 'www.api.com'

// ✗ evite
var location = env.development ?
'localhost' :
'www.api.com'
```

* **Para declarações de var,** escreva cada declaração na sua própria instrução.

```js
// ✓ ok
var silent = true
var verbose = true

// ✗ evite
var silent = true, verbose = true

// ✗ evite
var silent = true,
verbose = true
```

* **Coloque parẽnteses adicionais** em declarações em condições. Isso torna mais claro que a expressão é uma declaração (`=`) e não um typo de equidade (`===`)

```js
// ✓ ok
while ((m = text.match(expr))) {
// ...
}

// ✗ evite
while (m = text.match(expr)) {
// ...
}
```
*
## Ponto-e-vírgula

* Não use. (veja: [1](http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding), [2](http://inimino.org/%7Einimino/blog/javascript_semicolons), [3](https://www.youtube.com/watch?v=gsfbh17Ax9I))

```js
window.alert('hi') // ✓ ok
window.alert('hi'); // ✗ evite
```

* Nunca comece uma linha com `(`, `[`, ou `` ` ``. Esse é o único problema em omitir ponto-e-vírgula, e standard te protege desse problema em potencial.

```js
// ✓ ok
;(function () {
window.alert('ok')
}())

// ✗ evite
(function () {
window.alert('ok')
}())
```

```js
// ✓ ok
;[1, 2, 3].forEach(bar)

// ✗ evite
[1, 2, 3].forEach(bar)
```

```js
// ✓ ok
;`hello`.indexOf('o')

// ✗ evite
`hello`.indexOf('o')
```

Nota: Se você frequentemente escreve código assim, você pode estar querendo ser o inteligentão. Cuidado.

Atalhos inteligentes são desencorajados, em favor de expressões mais limpas e legíveis, sempre que possível.


Ao invés disso:

```js
;[1, 2, 3].forEach(bar)
```

Isso é bem melhor

```js
var nums = [1, 2, 3]
nums.forEach(bar)
```


## Uma leitura boa

- [An Open Letter to JavaScript Leaders Regarding Semicolons][1]
- [JavaScript Semicolon Insertion – Everything you need to know][2]

##### E um vídeo bem explicativo:

- [Are Semicolons Necessary in JavaScript? - YouTube][3]

Todos os minificadores de código populares usam minificação baseada em AST, logo, podem lidar com JavaScript sem ponto-e-vírgula sem problemas (já que ponto-e-vírgula não é obrigatório no JavaScript).

##### Um pedaço de *["An Open Letter to JavaScript Leaders Regarding Semicolons"][1]*, traduzido:

[Depender de inserção automática de ponto-e-vírgula] é algo bem seguro, e é perfeitamente válido, de forma que qualquer navegador entende. Compilador Closure, yuicompressos, packer e jsmin... todos conseguem minificar sem problemas. Não há impacto de performance.

Lamento que ao invés de educar, os líderes da comunidade dessa linguagem mentem pra você, te deixam com medo. Isso é vergonhoso. Eu recomendo aprender como declarações no JS são terminadas (e em que caso elas não são terminadas), para que você possa escrever os códigos que acha bonito.


De forma geral, `\n` termina uma declaração a menos que:
1. A declaração possua um parêntese que não foi fechado, um array literal ou um objeto literal, ou termina de alguma outra forma que não seja um fim de declaração válido (por exemplo, `.` ou `,`)
2. A linha é apenas `--` ou `++` (nesse caso vai decrementar ou incrementar o próximo token)
3. Ela seja um `for()`, `while()`, `while()`, `do`, `if()`, ou `else`, e não possui `{`
4. A próxima linha começa com `[`, `(`, `+`, `*`, `/`, `-`, `,`, `.`, ou algum outro operador binário que só pode ser encontrado entre 2 tokens em uma única expressão.

A primeira linha é bem óbvia. Qualquer JSLint não vê problemas em `\n` em json e construtores "aparêntetizados", e com declarações `var` que se extendem por múltiplas linhas, terminado em `,`;
A segunda é muito esquisita. Nunca vi um caso (fora de ambientes específicos pra esse caso) onde você iria querer escrever `i\n++\nj`, mas pra todos os fins, isso é um `i; ++j`, e não `i++; j`.

A terceira é bem difundida, embora geralmente deixada pra lá. `if (x)\ny()` é equivalente a `if (x) { y() }`. O construtor não termina até que ache um bloco, ou uma declaração.

`;` é uma declaração válida, logo `if(x);` `if(x){}` ou, “se X, não faça nada". Isso é mais comum quando aplicado em loops onde a checagem do loop é a própria função de update. Incomum, mas não totalmente desconhecida.

A quarta é geralmente o que deixa a galera louca, tipo "meu deus, você precisa de ponto-e-vírgula!" Mas é bem fácil *prefixar* essas linhas com ponto-e-vírgula se você não quer que elas sejam continuações da linha anterior. Por exempl, ao invés disso:

```js
foo();
[1,2,3].forEach(bar);
```

você pode fazer isso

```js
foo()
;[1,2,3].forEach(bar)
```

A vantagem disso é que prefixos são mais fáceis de perceber, uma vez que você acostuma a nunca mias ver linhas com `(` e `[` sem semis.

*Fim da citação de "An Open Letter to JavaScript Leaders Regarding Semicolons".*

[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
1,398 changes: 1,398 additions & 0 deletions docs/RULES-zhcn.md

Large diffs are not rendered by default.

1,395 changes: 1,395 additions & 0 deletions docs/RULES-zhtw.md

Large diffs are not rendered by default.

Binary file added docs/logos/atom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logos/bitcoinjs.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/brave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logos/bustle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logos/clevertech.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logos/ctrl-alt-deseat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logos/dat.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/eaze.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/electron.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/express.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/github.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/gov-uk.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/greenkeeper.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/ipfs.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/jaguar-landrover.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/karma.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/mongodb.jpg

Unable to render rich display

Invalid image source.

Binary file added docs/logos/nearform.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/neo4j.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/nodesource.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/npm.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/opbeat.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/optiopay.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/rentograph.png

Unable to render rich display

Invalid image source.

Binary file added docs/logos/studynotes.jpg

Unable to render rich display

Invalid image source.

Binary file added docs/logos/taser.png
Binary file added docs/logos/treasuredata.png
Binary file added docs/logos/typeform.jpg
Binary file added docs/logos/voltra.png
Binary file added docs/logos/webtorrent.png
Binary file added docs/logos/zeit.png
Binary file added docs/logos/zendesk.png
Binary file added docs/logos/zentrick.png
27 changes: 15 additions & 12 deletions docs/webstorm.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# [WebStorm/PhpStorm][webstorm-1] configuration for Standard Style
# [WebStorm][webstorm-1] configuration for Standard Style

## Native support for `standard`

WebStorm [recently announced native support](https://blog.jetbrains.com/webstorm/2017/01/webstorm-2017-1-eap-171-2272/)
for `standard` directly in the IDE!

This applies to all JetBrains products, including PhpStorm, IntelliJ, RubyMine, etc.

If you still prefer to configure `standard` manually, use the following guide.

## Configure `standard` support manually

1. Close your IDE.
2. [Figure out where your configuration lives][webstorm-2] (_IDE Settings_ section)
@@ -10,15 +21,10 @@
<JSCodeStyleSettings>
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
<option name="USE_DOUBLE_QUOTES" value="false" />
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
<option name="SPACES_WITHIN_IMPORTS" value="true" />
</JSCodeStyleSettings>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="JavaScript">
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="SPACE_WITHIN_BRACKETS" value="true" />
<option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
@@ -48,15 +54,12 @@

6. Start up the IDE and open a _Settings_/_Preferences_ screen (choose between project and default settings accordingly to your preference)
7. Under `Editor > Code Style > JavaScript` change `Scheme` to `Standard`
8. Under `Editor > Inspections > JavaScript > Code style issues` untick `Unterminated statement`
9. Under `Languages & Frameworks > JavaScript > Code Quality Tools > ESLint` just select `Enable`. If you didn't install `ESLint` before and you don't have it in your dependencies - that's all. If you do - be sure to use `ESLint package` of the same version as current version of `standard` is using. Or just remove your old one - you probably won't need it anymore
8. Under `Editor > Code Style > HTML` just select `Other`, in `Spaces` setting, check `In empty tag`
9. Under `Editor > Inspections > JavaScript > Code style issues` untick `Unterminated statement`
10. Under `Languages & Frameworks > JavaScript > Code Quality Tools > ESLint` just select `Enable`. If you didn't install `ESLint` before and you don't have it in your dependencies - that's all. If you do - be sure to use `ESLint package` of the same version as current version of `standard` is using. Or just remove your old one - you probably won't need it anymore

---

If you're a Webstorm or PhpStorm user, [vote for `standard` to be one of the default styles][webstorm-3]
built into the app.

[npm-article]: https://docs.npmjs.com/getting-started/fixing-npm-permissions
[webstorm-1]: https://www.jetbrains.com/webstorm/
[webstorm-2]: https://www.jetbrains.com/help/phpstorm/2016.1/directories-used-by-phpstorm-to-store-settings-caches-plugins-and-logs.html?origin=old_help#d66583e60
[webstorm-3]: https://youtrack.jetbrains.com/issue/WEB-17331
38 changes: 20 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
{
"name": "standard",
"description": "JavaScript Standard Style",
"version": "8.6.0",
"version": "11.0.0",
"author": {
"email": "feross@feross.org",
"name": "Feross Aboukhadijeh",
"url": "http://feross.org/"
},
"bin": "./bin/cmd.js",
"bugs": {
"url": "https://github.com/feross/standard/issues"
"url": "https://github.com/standard/standard/issues"
},
"dependencies": {
"eslint": "~3.10.2",
"eslint-config-standard": "6.2.1",
"eslint-config-standard-jsx": "3.2.0",
"eslint-plugin-promise": "~3.4.0",
"eslint-plugin-react": "~6.7.1",
"eslint-plugin-standard": "~2.0.1",
"standard-engine": "~5.2.0"
"eslint": "~4.18.0",
"eslint-config-standard": "11.0.0",
"eslint-config-standard-jsx": "5.0.0",
"eslint-plugin-import": "~2.8.0",
"eslint-plugin-node": "~6.0.0",
"eslint-plugin-promise": "~3.6.0",
"eslint-plugin-react": "~7.6.1",
"eslint-plugin-standard": "~3.0.1",
"standard-engine": "~8.0.0"
},
"devDependencies": {
"babel-eslint": "^7.0.0",
"cross-spawn": "^5.0.1",
"babel-eslint": "^8.0.3",
"cross-spawn": "^6.0.3",
"eslint-index": "^1.3.0",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"run-parallel-limit": "^1.0.3",
"standard-packages": "^3.1.9",
"standard-packages": "^3.4.0",
"tape": "^4.6.0"
},
"engines": {
"node": ">=4"
},
"homepage": "http://standardjs.com",
"homepage": "https://standardjs.com",
"keywords": [
"JavaScript Standard Style",
"check",
@@ -62,14 +65,13 @@
"main": "index.js",
"repository": {
"type": "git",
"url": "git://github.com/feross/standard.git"
"url": "git://github.com/standard/standard.git"
},
"scripts": {
"show-rules": "eslint-index eslintrc.json",
"show-rules-disabled": "eslint-index eslintrc.json --status omitted off",
"show-summary": "eslint-index eslintrc.json --format table",
"test": "./bin/cmd.js --verbose && tape test/*.js",
"test-disabled": "npm test -- --disabled",
"test-offline": "npm test -- --offline",
"test-offline-quick": "npm test -- --offline --quick",
"test-quick": "npm test -- --quick",
"update-authors": "./bin/update-authors.sh"
}
}
64 changes: 40 additions & 24 deletions test/clone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

/**
* Clones several projects that are known to follow "JavaScript Standard Style" and runs
* the `standard` style checker to verify that it passes without warnings. This helps
@@ -21,14 +19,15 @@ var test = require('tape')
var GIT = 'git'
var STANDARD = path.join(__dirname, '..', 'bin', 'cmd.js')
var TMP = path.join(__dirname, '..', 'tmp')
var PARALLEL_LIMIT = os.cpus().length
var PARALLEL_LIMIT = Math.max(os.cpus().length - 1, 1)

var argv = minimist(process.argv.slice(2), {
boolean: [
'disabled',
'offline',
'quick',
'quiet'
'quiet',
'fix'
]
})

@@ -46,15 +45,10 @@ if (argv.disabled) {
testPackages = disabledPackages
} else {
test('Disabled Packages', function (t) {
if (disabledPackages.length === 0) {
t.pass('no disabled packages')
t.end()
} else {
t.plan(disabledPackages.length)
disabledPackages.forEach(function (pkg) {
t.pass('DISABLED: ' + pkg.name + ': ' + pkg.disable + ' (' + pkg.repo + ')')
})
}
disabledPackages.forEach(function (pkg) {
console.log('DISABLED: ' + pkg.name + ': ' + pkg.disable + ' (' + pkg.repo + ')')
})
t.end()
})
}

@@ -69,24 +63,19 @@ test('test github repos that use `standard`', function (t) {
var folder = path.join(TMP, name)
return function (cb) {
fs.access(path.join(TMP, name), fs.R_OK | fs.W_OK, function (err) {
if (argv.offline) {
if (err) {
t.pass('SKIPPING (offline): ' + name + ' (' + pkg.repo + ')')
return cb(null)
}
if (argv.offline && err) {
t.pass('SKIPPING (offline): ' + name + ' (' + pkg.repo + ')')
cb(null)
} else if (argv.offline) {
runStandard(cb)
} else {
var downloadPackage = err ? gitClone : gitPull
downloadPackage(function (err) {
if (err) return cb(err)
runStandard(cb)
})
}

function downloadPackage (cb) {
if (err) gitClone(cb)
else gitPull(cb)
}

function gitClone (cb) {
var args = [ 'clone', '--depth', 1, url, path.join(TMP, name) ]
spawn(GIT, args, { stdio: 'ignore' }, function (err) {
@@ -108,8 +97,35 @@ test('test github repos that use `standard`', function (t) {
if (pkg.args) args.push.apply(args, pkg.args)
spawn(STANDARD, args, { cwd: folder }, function (err) {
var str = name + ' (' + pkg.repo + ')'
if (err && argv.fix) {
t.comment('Attempting --fix on ' + str)
runStandardFix(cb)
} else if (err) {
t.fail(str)
cb(null)
} else {
t.pass(str)
cb(null)
}
})
}

function runStandardFix (cb) {
var args = [ '--fix', '--verbose' ]
if (pkg.args) args.push.apply(args, pkg.args)
spawn(STANDARD, args, { cwd: folder }, function (err) {
var str = name + ' (' + pkg.repo + ') ** with --fix'
if (err) { t.fail(str) } else { t.pass(str) }
cb(null)
runGitReset(cb)
})
}

function runGitReset (cb) {
var args = [ 'reset', '--hard' ]
spawn(GIT, args, { cwd: folder }, function (err) {
if (err) err.message += ' (git reset) (' + name + ')'
// Fatal error if can't git reset
cb(err)
})
}
})