1.0.0 • Published 2 years ago

eslint-plugin-waterfall v1.0.0

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

ESLint Plugin Waterfall

Write code like waterfall. more beautiful more readable.

ESLint Plugin Waterfall

Installation

npm i eslint-plugin-waterfall --save-dev
// or
yan add eslint-plugin-watefall --dev

Usage

Add waterfall in plugins section of your eslint config:

{
  "plugins": ["waterfall"]
}

Then configure the rules you want to use under the rules section:

{
  "rules": {
    "waterfall/waterfall-objects": "error",
    "waterfall/waterfall-imports": "error",
    "waterfall/waterfall-requires": "error",
  }
}

Rules

waterfall-objects:

// ℹ️ Before:
const person = {
  username: 'test',
  name: 'jason',
  email: 'json@gmail.com',
  country: 'usa',
}

// ✅ After:
const peson = {
  name: 'jason',
  country: 'usa',
  username: 'test',
  email: 'jason@gmail.com',
}

waterfall-imports:

// ℹ️ Before:
import { useContext, useEffect, useState } from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import axios from 'axios'
import { getAccessToken, clearAuthCookies } from './auth'
import Error from 'next/error'

// ✅ After:
import axios from 'axios'
import Link from 'next/link'
import Error from 'next/error'
import { useRouter } from 'next/router'
import { useContext, useEffect, useState } from 'react'
import { getAccessToken, clearAuthCookies } from './auth'

waterfall-requires:

// ℹ️ Before:
const path = require('path')
const fs = require('fs')
const express = require('express')
const auth = require('./auth')

// ✅ After:
const fs = require('fs')
const path = require('path')
const auth = require('./auth')
const express = reqiure('express')
1.0.0

2 years ago