Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

smarlhens/opinionated-safe-code-normalizer

Repository files navigation

Opinionated safe code normalizer

TypeScript opinionated safe code normalizer using ts-morph & ESLint.

GitHub CI node-current (scoped) GitHub license Commitizen friendly code style: prettier Conventional Commits

This tool helps you to add public keyword to your code methods, properties, getters & setters to be compliant with @typescript-eslint/explicit-member-accessibility rule.


Table of Contents


Prerequisites

  • Node.JS version ^14.17.0 || >=16.0.0

Installation

Install globally:

npm install -g @smarlhens/opinionated-safe-code-normalizer

Usage

Use inside a directory which contain an .eslintrc.js configuration file and **/*.ts files (can be in subdirectories of the working directory).
Using ts-morph & ESLint, your code will be updated adding public keyword to methods, properties, getters & setters.

$ oscn

Example

class Foo {
  private propA: string;
  protected propB: string;
  public propC?: string;
- propD?: string;
+ public propD?: string;

  private _propE?: string;

- get propE(): string | undefined {
* public get propE(): string | undefined {
    return this._propE;
  }

- set propE(value: string | undefined) {
+ public set propE(value: string | undefined) {
    this._propE = value;
  }

  constructor() {
    this.propA = 'lorem';
    this.propB = 'ispum';
  }

- methodA(): void {}
+ public methodA(): void {}
}