microsoft / microsoft/vscode-cpptools

TS Modernization - Code Cleanup

Open
#11,119 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

More code cleanup tasks

In the effort to reduce some complexity and technical debt in the extension codebase - the following are the outstanding things to address after the TS Modernization PR is completed: #11085

  • clean up clients.ActiveClient vs getActiveClient() -- pick one and stick with it.
  • clean up ui vs getUI() - consistency - same thing
  • elminiate use of null
  • clean up use of os.platform() everywhere with the use of a constants
  • unify use of guards and replace util.is* with guards
  • replace filesystem wrappers (those that provide promise-based fs functions) with use of built-in node:fs.promises.XXX functions
  • examine all use of new Promise(...) to ensure that there isn't a cleaner use available.
  • enable plugin:@typescript-eslint/strict in eslint and fix all errors (about ~450), including:
    • A record is preferred over an index signature
    • Do not delete dynamically computed property keys
    • Expected a 'for-of' loop instead of a 'for' loop with this simple iteration
    • Expected an error object to be thrown
    • Explicit enum value must only be a literal value (string, number, boolean, etc)
    • Literals should be exposed using readonly fields
    • Prefer using an optional chain expression instead, as it is more concise and easier to read
    • Prefer using nullish coalescing operator ('??') instead of a logical or ('||'), as it is a safer operator
    • The generic type arguments should be specified as part of the constructor type arguments
    • The two values in this comparison do not have a shared enum type
    • Unexpected class with only static properties
    • Unnecessary conditional, both sides of the expression are literal values
    • Unnecessary conditional, expected left-hand side of '??' operator to be possibly null or undefined
    • Unnecessary conditional, the types have no overlap
    • Unnecessary conditional, value is always falsy
    • Unnecessary conditional, value is always truthy
    • Unnecessary optional chain on a non-nullish value
    • Use 'as XXX' instead of '<XXX>'
    • Use 'includes()' method instead
    • Use 'String#startsWith' method instead
    • Use an 'interface' instead of a 'type'
    • Use the 'String#endsWith' method instead
    • Useless constructor
    • void is not valid as a constituent in a union type
    • void is only valid as a return type or generic type argument

Refactoring:

  • investigate and fix initialization and remove BlockingTask concept and move to a resettable Signal -- should make blocking at the high-order tasks much cleaner
  • refactor protocolFilter to ensure order of processed messages is maintained.

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

Start by reviewing the completed TS Modernization PR #11085 and the outstanding cleanup areas listed here. Done requires resolving the identified TypeScript and ESLint issues, simplifying the initialization and protocolFilter designs, and addressing each consistency and promise/filesystem cleanup item.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, node.js, typescript
Domain
developer-experience, 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.