Skip to content

Instantly share code, notes, and snippets.

@baozdemir
baozdemir / better-nodejs-require-paths.md
Created June 4, 2020 16:55 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@baozdemir
baozdemir / .eslintrc.js
Created July 11, 2018 22:12 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
[push]
default = current
[user]
email = [email protected]
name = Nik Butenko
[core]
autocrlf = input
excludesfile = /Users/nkbt/.gitignore
ignorecase = true
[alias]
@baozdemir
baozdemir / nodejs-custom-es6-errors.md
Created February 26, 2018 00:35 — forked from slavafomin/nodejs-custom-es6-errors.md
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js