Skip to content

Latest commit

 

History

History
169 lines (107 loc) · 5.47 KB

CONTRIBUTING.md

File metadata and controls

169 lines (107 loc) · 5.47 KB

Setup | Running tests | Workflow | Dependencies | Code Standards


Contributing

Contributions are always welcome, no matter how large or small. Before contributing, please read the code of conduct.

Developing

Setup

$ git clone https://github.com/babel/babel
$ cd babel
$ make bootstrap

Then you can either run:

$ make build-core

to build Babel once or:

$ make watch-core

to have Babel build itself then incrementally build files on change.

Running tests

You can run tests via:

$ make test

This is mostly overkill and you can limit the tests to a select few by directly running them with mocha:

$ mocha test/core/transformation.js

Use mocha's --grep option to run a subset of tests by name:

$ mocha test/core/transformation.js --grep es7

If you don't have mocha installed globally, you can still use it from Babel's dependencies in node_modules, but make sure node_modules/.bin is added to your $PATH environment variable.

Workflow

  • Fork the repository
  • Clone your fork and change directory to it (git clone git@github.com:yourUserName/babel.git && cd babel)
  • Install the project dependencies (make bootstrap)
  • Link your forked clone (npm link)
  • Develop your changes ensuring you're fetching updates from upstream often
  • Ensure the test are passing (make test)
  • Create new pull request explaining your proposed change or reference an issue in your commit message

Dependencies

  • ast-types This is required to monkeypatch regenerators AST definitions. Could be improved in the future.

  • chalk This is used for terminal color highlighting for syntax errors.

  • convert-source-map Turns a source map object into a comment etc.

  • core-js Used for the polyfill.

  • debug Used to output debugging information when NODE_DEBUG is set to babel.

  • detect-indent This is used in the code generator so it can infer indentation.

  • estraverse The only method on this is attachComments. I'd like to implement our own comment attachment algorithm eventually though.

  • esutils Various ES related utilities. Check whether something is a keyword etc.

  • fs-readdir-recursive Recursively search a directory for.

  • globals A list of JavaScript global variables. This is used by the scope tracking to check for colliding variables.

  • is-integer Checks if something is an integer.

  • js-tokens This is used to get tokens for syntax error highlighting.

  • leven A levenstein algorithm to determine how close a word is to another. This is used to offer suggestions when using the utility.undeclaredVariableCheck transformer.

  • line-numbers Used to produce the code frames in syntax errors.

  • lodash Used for various utilities.

  • minimatch This is used to match glob-style ignore/only filters.

  • output-file-sync Synchronously writes a file and create its ancestor directories if needed.

  • path-is-absolute Checks if a path is absolute. C:\foo and \foo are considered absolute.

  • regenerator This is used to transform generators/async functions.

  • regexpu Used to transform unicode regex patterns.

  • repeating Repeats a string.

  • shebang-regex Literally just a regex that matches shebangs.

  • slash Normalises path separators.

  • source-map Generates sourcemaps.

  • source-map-support Adds source map support to babel-node/babel/register.

  • strip-json-comments Remove comments from a JSON string. This is used for .babelrc files.

  • to-fast-properties A V8 trick to put an object into fast properties mode.

  • trim-right Trims the rightside whitespace.

  • user-home Gets the users home directory. This is used to resolve the babel-node/babel/register cache.

Code Standards

  • General

    • Max of five arguments for functions
    • Max depth of four nested blocks
    • 2-spaced soft tabs
  • Naming

    • CamelCase all class names
    • camelBack all variable names
  • Spacing

    • Spaces after all keywords
    • Spaces before all left curly braces
  • Comments

    • Use JSDoc-style comments for methods
    • Single-line comments for ambiguous code
  • Quotes

    • Always use double quotes
    • Only use single quotes when the string contains a double quote
  • Declaration

    • No unused variables
    • No pollution of global variables and prototypes