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.

Comments

brianperry created an issue. See original summary.

mitchellmarkoff’s picture

On their own, Drupal Core’s JS Standards should mostly suffice as a starting point for this TypeScript project. The usage of 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.

brianperry’s picture

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.

brianperry’s picture

Status: Active » Fixed

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.

Status: Fixed » Closed (fixed)

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