Define Coding Standards

Created on 12 July 2023, over 1 year ago
Updated 1 November 2023, about 1 year ago

Problem/Motivation

As outlined in Perform A Software Evaluation โ†’ , we will need to define what the coding standards for this project will be.

Proposed resolution

My initial assumption was that Drupal Core's current JS Coding standards โ†’ wouldn't quite be what we needed, but upon closer look they might not be that far off.

> Use eslint for Drupal JS coding standards. See the eslint settings information. Drupal uses 'eslint-config-airbnb' as ESLint shareable config. Therefore it's reasonable to use 'Airbnb JavaScript Style Guide' as Drupal JS coding standard.

Cores standards / Airbnb might not be too far off from what we need. The main thing we need to factor in is TypeScript. Are we essentially developing Drupal TypeScript coding standards here?

Things to consider:
* Is Airbnb a reasonable starting point for this project? We can always make adjustments as we go.
* Does Airbnb have opinions on TypeScript? If not, what additional standards will we need for TypeScript?
* Will Core's JSDoc Standards โ†’ work for us? Is there any other considerations needed for TSDoc?
* Is there anything that can be learned from the configuration of https://git.drupalcode.org/project/decoupled_menu_parser? I'm not sure it is a safe assumption that Drupal's JS coding standards were thoughtfully considered here, but the project does use TS.

Remaining tasks

* Determine if Drupal Core's JS Standards work as a starting point for this project.
* Determine the adjustments that will be necessary for TypeScript.
* Determine if we've accidentally developed potential 'Drupal TypeScript Coding Standards'. If so, create a follow up issue to document and socialize those potential standards.

๐Ÿ“Œ Task
Status

Fixed

Component

Documentation

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States brianperry

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @brianperry
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mitchellmarkoff

    On their own, Drupal Coreโ€™s JS Standards should mostly suffice as a starting point for this project. The usage of the eslint-config-airbnb is already familiar to most in the JS ecosystem and is well documented.

    Unfortunately, the AirBnb style guide does not officially offer TypeScript support. However, there is a very popular npm package eslint-config-airbnb-typescript (Git Repo) that gives us an easy way to add TypeScript support to these design standards.

    Since we are planning on building on top of the existing Drupal JS Coding Standards with only a minor adjustment for now, I donโ€™t think a follow up issue is needed to socialize a new set of standards.

    As this project will be using TypeScript, it makes the most sense to use TSDoc over the current doc standard โ†’ of JSDoc3. TSDoc will provide better integration with the TS type system, enabling support for advanced types. It will also ensure a consistent type interface which will keep this codebase clean and easy to maintain.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States brianperry

    That all makes sense to me @mitchellmarkoff

    When we implement this, in the project readme I think we should document anywhere we diverge from Drupal's JS Standards / AirBnb. Based on what you outlined that would at least be eslint-config-airbnb-typescript and tsdoc.

  • Status changed to Fixed about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States brianperry

    Marking as fixed as we have outlined our standards in the readme: https://git.drupalcode.org/project/api_client/-/blob/canary/README.md#co... and implemented them in the project. As of now the only adjustments we have made to the default AirBNB standards were related to TypeScript support.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024