Перейти к основному содержимому

Guidelines for contributing to javascript snippets

Please follow these guidelines when contributing to javascript snippets.

Include snippet in the correct section

There are sections for the existing snippets. If your snippet is relevant for one of those sections, add it to that section.

If your snippet is on some topic for which a section does not yet exist, add a new section and place your snippet in it. Make sure that you add a link to that section at the top of the index.md.

Put a horizontal rule (---) between sections.

Follow format of existing snippets

  • Use headings demonstrated in existing snippets as appropriate:
    • Using ... - brief explanation of topic
    • When to use ... - brief indication of when to use it
    • Example ... - brief explanation of example
    • Code - the code snippet
  • It may not be necessary to include all of these sections. At a minimum, include a header and Code

Use the same header specifications as used for existing sections (for example, h2 for section heading, h5 for Code, etc.)

Use (```javascript) to format code snippets

To format code snippets, follow the example and use ```javascript.

Use ES6 syntax

Unless you are describing ES5 syntax, use ES6 syntax in the code snippets.

Follow the airbnb style guide for naming

In your code snippets, heed the airbnb style guide when deciding on capitalisation, casing, and naming of variables and functions.

Check your code snippets

Before you submit a snippet, make sure it runs without errors.

Check your spelling and grammar

To the best of your ability, check your spelling and grammar in your snippet explanations.