Setting up the developer environment

Guides on how to set up JavaScript and C# development environments

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. 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, Validator, and 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.

nvm, Node.js, and npm

nvm, Node.js, and npm must be installed in order to make contributions to most OpenActive JavaScript projects.

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.

npm (Node package manager) is a package manager for JavaScript and the default package manager for Node.js. Many OpenActive packages are published on npm.

nvm (Node version manager) 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.

After installing nvm follow the instructions here to install Node.js (npm is automatically installed by Node.js).

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.

To switch between versions manually, run nvm use xx.xx.x in the project folder e.g. nvm use 14.16.0

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.

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.

GitHub Pull Requests and Issues

GitHub integration allows for creation and reviewing of Pull Requests directly within VSCode. The plugin can be found here.

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.

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.

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.

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 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:

 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, OpenActive.Server.NET, and OpenActive.DataSite.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.

To install Visual Studio, follow the instructions outlined here.

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.

Last updated