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!

|
|---|---|---|---|---|

In addition to companies, many community members use standard on packages that
are too numerous
to list here.

Sublime Text

Atom

Alternatively, you can install linter-js-standard-engine. 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.

I disagree with rule X, can you change it?

No. The whole point of standard is to save you time by avoiding
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 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

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.

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:

/* global myVar1, myVar2 */

If you have hundreds of files, it may be desirable to avoid adding comments to
every file. In this case, run:

$ standard --global myVar1 --global myVar2

Or, add this to package.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.

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.

What about Mocha, Jasmine, QUnit, etc?

To support mocha in test files, add this to the top of the test files:

/* eslint-env mocha */

Or, run:

$ 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
documentation. For a list of what globals are available for these environments,
check the
globals npm
module.

Note: env and envs are equivalent.

What about Web Workers?

Add this to the top of worker files:

/* eslint-env serviceworker */

This lets standard (as well as humans reading the code) know that self is a
global in web worker code.