GithubHelp home page GithubHelp logo

eslint's Introduction

eslint-config-hjf

My personal eslint configs

Rules and Rationale

Typescript only

I like to throw code around in JS every now and then, but for hacks and giggles. When coding gets important, I bring tooling in, like the TypeScript compiler and ESLint.

Tabs

Anybody can pick their indent width this way: there's no argument between 2 or 4 spaces.

Unix Line Endings

These are portable, unlike windows line endings: publishing a CLI with these means that your shebang won't be recognised.

Single Quotes

Single quotes generally make it easier to deal with quoting a person. They're not ideal when you've got contractions though. It's the lesser of two evils. There's also one less keypress.

// correct
const host = 'github.com'

// incorrect
const remoteHost = "something.com"

// WHY
const notAHost = `template literals are inconsistent across keyboards`

Strict equality always

It's JavaScript - '1' == 1 is true. Let's ignore any confusion.

No floating promises

If something's a promise, we want to know - even if we're not awaiting it. This makes understanding a new codebase easier.

There are two ways of calling a promise:

// async-blocking
await makeApiRequest()

// just leave it to get picked up whenever in the microtask queue
void doSomething()

Object curly spacing

There's no functional reason for this: I just like the way it looks

import {pickBy, is} from 'ramda'

const isNumeric = is(Number)

const data = {a: 1, b: 'bar'}

const pickNumbers = pickBy(isNumeric)

const numbers = pickNumbers(data) // {a: 1}

Returning await

This is only acceptable in a try-catch. Returning await can throw.

async function willThrow() {
	// will throw here, as we wait for r.json() to evaluate
	return await fetch('/not_json').then(r => r.json())
}

Semicolons

They're not necessary in JavaScript. Don't bother.


eslint's People

Watchers

Harry avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.