saucelabs / saucelabs/node-saucelabs

suggested various refactors

Open
#136 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
98
Forks
45
Avg merge
3d 23h
Merged PRs (30d)
10

Description

Taking a look at the state of the codebase, I'd like to recommend the following changes:

  1. Drop any use of stage-2 or lower JS syntax (e.g., the bind operator ::). We shouldn't use any JS that isn't guaranteed to one day actually be valid syntax.
  2. Configure babel-env to use shippedProposals: true, which should replace most of the one-off babel plugins.
  3. Change the formatting to use two (2) spaces instead of four (4), and use semicolons, which is the most typical/popular way of formatting JS.
  4. Adopt prettier, eslint-plugin-prettier, husky and lint-staged to perform automatic formatting and fixing as a pre-commit hook. This should eliminate any further fussing about formatting in future discussions or code reviews.
  5. (Re-)write all docstrings as TypeScript-compatible JSDoc and use tsc as a type-checker. This will give us the types from TypeScript and DefinitelyTyped, but does not demand we rewrite the project in TS. We're taking this approach in Appium and I've found it works well. This shouldn't conflict with what we're doing to generate typings, as much of the API seems to be automatically generated from a swagger doc. However, this will likely require a few refactors to keep TS happy (e.g., you cannot return anything from a constructor other than this, so we'll need to find a different way to accomplish the same thing).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the remaining unchecked proposals around JavaScript syntax, babel-env configuration, and TypeScript-compatible JSDoc with tsc, including the Swagger-based typings mentioned in the issue. Break the work into separately scoped changes and confirm that the obsolete syntax and one-off Babel plugins are removed while type checking remains successful.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript, typescript
Domain
api, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.