1.0.0 • Published 2 years ago

@enjinstarter/ejs-eslint-config v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Enjinstarter JavaScript Style Guide

This style guide is based off the Airbnb JavaScript Style Guide with the changes listed below.

Installation

Install the package:

# npm
npm install --save-dev @enjinstarter/ejs-eslint-config
# yarn
yarn add --dev @enjinstarter/ejs-eslint-config
# pnpm
pnpm add --save-dev @enjinstarter/ejs-eslint-config

Install the peer dependencies:

npm info "eslint-config-airbnb@latest" peerDependencies

If using npm 5+, use this shortcut

# npm
npx install-peerdeps --dev @enjinstarter/ejs-eslint-config
# yarn
npx install-peerdeps --dev --yarn @enjinstarter/ejs-eslint-config
# pnpm
npx install-peerdeps --dev --pnpm @enjinstarter/ejs-eslint-config

Add the following configuration to your eslint config:

"extends": [
  "@enjinstarter/ejs-eslint-config"
]

:warning: WARNING: react-scripts@4.x is not supported!

Table of Contents

  1. Naming Conventions

Naming Conventions

  • 1.1 All web3 variables or functions that are in WEI amounts should have the "_WEI" suffix. eslint: @typescript-eslint/naming-convention

    // bad
    const userBalance
    
    function getUserBalance() {
      // ...
    }
    
    // good
    const userBalance_WEI
    
    function getUserBalance_WEI() {
      // ...
    }

  • 1.2 All web3 variables or functions that are of the number type should have the "_NUM" suffice. eslint: @typescript-eslint/naming-convention

    // bad
    const userBalance
    
    function getUserBalance() {
      // ...
    }
    
    // good
    const userBalance_NUM
    
    function getUserBalance_NUM() {
      // ...
    }

  • 1.3 All web3 variables or functions that are of the BigNumber type should have the "_BN" suffix. eslint: @typescript-eslint/naming-convention

    // bad
    const userBalance
    
    function getUserBalance() {
      // ...
    }
    
    // good
    const userBalance_BN
    
    function getUserBalance_BN() {
      // ...
    }

  • 1.4 All variables or functions that are of the boolean type should have the "is" or "has" suffix. eslint: @typescript-eslint/naming-convention

    // bad
    const staked
    
    function checkLocked() {
      // ...
    }
    
    // good
    const hasStake
    
    function isLocked() {
      // ...
    }

⬆ back to top