# Setting up the developer environment

## Git

Git is a free and open source version control system that is widely used across the world. It can be installed by following the guide [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). It is needed for any type of code-related contribution to the OpenActive ecosystem.

## JavaScript

JavaScript is used for a variety of projects in the OpenActive ecosystem. This includes [Test Suite](https://github.com/openactive/openactive-test-suite), [Validator](https://github.com/openactive/data-model-validator), and [SKOS.js](https://github.com/openactive/skos.js). For ease of contribution and collaboration, the following guidelines should be followed.

### VSCode

VSCode is the recommended IDE to use for JavaScript contributions. It is a cross platform, open source, industry leading IDE, that is lightweight, extensible, and full-featured.

All repositories include configuration files for VSCode to simplify debugging, as well as configuration file for some of the plugins below. Hence development within the OpenActive codebase is significantly easier using this IDE.

To install VSCode follow the instructions outlined [here](https://code.visualstudio.com/Download).

### nvm, Node.js, and npm

`nvm`, Node.js, and `npm` must be installed in order to make contributions to most OpenActive JavaScript projects.&#x20;

Node.js is a cross-platform JavaScript runtime that is used for back-end JavaScript development. It  therefore executes JavaScript outside of the web browser.&#x20;

`npm` (**N**ode **p**ackage **m**anager) is a package manager for JavaScript and the default package manager for Node.js. Many OpenActive packages are published on npm.

`nvm` (**N**ode **v**ersion **m**anager) is a tool used for installing and managing Node versions on your computer.

The easiest way to install Node.js and `npm` is through `nvm`. In order to install `nvm`, follow the instructions [here](https://github.com/nvm-sh/nvm#install--update-script).

After installing `nvm` follow the instructions [here](https://github.com/nvm-sh/nvm#install--update-script) to install Node.js (`npm` is automatically installed by Node.js).

{% hint style="info" %}
Different OpenActive projects have different Node versions.

Running `nvm use` in the project directory will automatically switch to the version of Node.js specified by that project.

The Node.js version for each project is specified in both the `.nvmrc` file, and in `package.json` under `engines.node`.&#x20;

To switch between versions manually, run `nvm use xx.xx.x` in the project folder e.g. `nvm use 14.16.0` &#x20;
{% endhint %}

### Useful Plugins

The following plugins are recommended for a better developer experience:

#### IntelliCode

IntelliCode by Microsoft provides AI-powered code completion that helps drive accuracy and consistency. It can be installed [here](https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.vscodeintellicode).

#### ESLint

The ESLint plugin integrates ESLint into VSCode, which highlights lint errors in the IDE. For more information on installing ESLint see below. The plugin can be found [here](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).

#### GitHub Pull Requests and Issues

GitHub integration allows for creation and reviewing of Pull Requests directly within VSCode. The plugin can be found [here](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github).

#### GitHub Actions

GitHub Actions are used in various OpenActive projects. The VSCode extension helps view, create, and manage these workflows. The plugin can be found [here](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-github-actions).&#x20;

#### Document This

JSDocs are used throughout the various OpenActive JavaScript projects. Document This provides the standard structure for JSDocs ensuring consistency across contributors. The plugin can be found [here](https://marketplace.visualstudio.com/items?itemName=oouo-diogo-perdigao.docthis).&#x20;

### ESLint

ESLint is a static code analysis tool that checks your JavaScript code for common problems, such as syntax errors, formatting issues, code style violations, and potential bugs.&#x20;

Across the OpenActive ecosystem, the AirBnb ESLint style guide is used. It is a very popular guide that results in clean and consistent code.

In most projects in the OA ecosystem, ESLint is already installed and configured, and therefore no further work is necessary. However if a project does not already have ESLint installed and configured [these](https://www.makeuseof.com/eslint-with-airbnb-javascript-style-guide/) instructions can be followed. Please ignore the section called "Customizing the Airbnb Style Guide". Finally to `eslintrc.js` add the following rules, which have been customised for the needs of OpenActive tooling:

```javascript
 rules: {
    'object-curly-newline': ['error', {
      ObjectExpression: {
        multiline: true, minProperties: 3, consistent: true,
      },
      ObjectPattern: { multiline: true, consistent: true },
      ImportDeclaration: 'never',
      ExportDeclaration: {
        multiline: true, minProperties: 3, consistent: true,
      },
    }],
    'arrow-parens': ['error', 'as-needed', {
      requireForBlockBody: true,
    }],
    'max-classes-per-file': 'off',
    'max-len': 'off',
    'no-await-in-loop': 'off',
    'no-console': 'off',
    'no-continue': 'off',
    'no-restricted-syntax': 'off',
    'func-names': 'off',
    'no-return-await': 'off',
    'prefer-arrow-callback': 'off',
    'class-methods-use-this': [
      'error',
      {
        exceptMethods: [
        ],
      },
    ],
    'import/no-extraneous-dependencies': [
      'error',
      {
        devDependencies: [
          '**/*-test.js',
        ],
      },
    ],
    'no-underscore-dangle': 'off',
    'no-use-before-define': ['error', { functions: false, classes: false }],
  },
```

## C\#

C# is used for a variety of projects in the OpenActive ecosystem. This includes [OpenActive.NET](https://github.com/openactive/OpenActive.NET), [OpenActive.Server.NET](https://github.com/openactive/OpenActive.Server.NET), and [OpenActive.DataSite.NET](https://github.com/openactive/OpenActive.DatasetSite.NET).

### Visual Studio

Visual Studio is a powerful IDE that can be used to develop in multiple languages and ecosystems. In OpenActive it is used as the primary IDE for C# development.&#x20;

To install Visual Studio, follow the instructions outlined [here](https://visualstudio.microsoft.com/downloads/).

{% hint style="warning" %}
Both VSCode and Visual Studio can be used to write JavaScript and C#. However it is recommended to use VSCode for JavaScript and Visual Studio for C# as the developer experience is significantly better.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://contributor.openactive.io/setting-up-the-developer-environment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
