• Stars
    star
    360
  • Rank 118,230 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node.js module generator/boilerplate with Babel, Jest, Flow, Documentation and more

nod

NPM version Build Status Coverage Status

NodeJS module generator/boilerplate.

Features

  • Babel - Write next generation JavaScript today.
  • Jest - JavaScript testing framework used by Facebook.
  • ESLint - Make sure you are writing a quality code.
  • Prettier - Enforces a consistent style by parsing your code and re-printing it.
  • Flow - A static type checker for JavaScript used heavily within Facebook.
  • Travis CI - Automate tests and linting for every push or pull request.
  • Documentation - A documentation system so good, you'll actually write documentation.
  • Standard Version - Automate versioning and CHANGELOG generation.

Install

The easiest way to use nod is through the Yeoman Generator.

$ npm install -g yo generator-nod
$ yo nod

If you don't want to use the generator, you can also download or git clone this repo

$ git clone https://github.com/diegohaz/nod my-module
$ cd my-module
$ rm -rf .git
$ npm install # or yarn

Just make sure to edit package.json, README.md and LICENSE files accordingly with your module's info.

Commands

$ npm test # run tests with Jest
$ npm run coverage # run tests with coverage and open it on browser
$ npm run lint # lint code
$ npm run docs # generate docs
$ npm run build # generate docs and transpile code

Publish

$ npm release
$ npm publish

It'll automatically run test, lint, docs, build, generate CHANGELOG.md, and push commits and tags to the remote repository.

Removing stuff

Flow
  1. Remove .flowconfig file.

  2. Remove flow from package.json:

      "scripts": {
    -   "flow": "flow check",
    -   "flowbuild": "flow-copy-source src dist",
    -   "prebuild": "npm run docs && npm run clean && npm run flowbuild",
    +   "prebuild": "npm run docs && npm run clean",
      },
      "devDependencies": {
    -   "@babel/preset-flow": "^7.0.0",
    -   "eslint-plugin-flowtype": "^2.50.0",
    -   "eslint-plugin-flowtype-errors": "^3.5.1",
    -   "flow-bin": "^0.81.0",
    -   "flow-copy-source": "^2.0.2",
      }
  3. Remove flow from .babelrc:

      "presets": [
    -   "@babel/preset-flow"
      ]
  4. Remove flow from .eslintrc:

      "extends": [
    -   "plugin:flowtype/recommended",
    -   "prettier/flowtype"
      ],
      "plugins": [
    -   "flowtype",
    -   "flowtype-errors"
      ],
      "rules": {
    -   "flowtype-errors/show-errors": "error"
      }
  5. Run yarn.

Documentation
  1. Remove documentation from package.json:

      "scripts": {
    -   "docs": "documentation readme src --section=API",
    -   "postdocs": "git add README.md",
    -   "prebuild": "npm run docs && npm run clean",
    +   "prebuild": "npm run clean",
      },
      "devDependencies": {
    -   "documentation": "^8.0.0",
      }
  2. Run yarn.

Adding stuff

TypeScript
  1. Install dependencies:

    yarn add -D @babel/preset-typescript @types/jest @typescript-eslint/eslint-plugin @typescript-eslint/parser typescript
  2. Update package.json:

    + "types": "dist/ts/src",
      "scripts": {
    +   "type-check": "tsc --noEmit",
    -   "lint": "eslint .",
    +   "lint": "eslint . --ext js,ts,tsx",
    -   "build": "babel src -d dist",
    +   "build": "tsc --emitDeclarationOnly && babel src -d dist -x .js,.ts,.tsx",
      },
      "lint-staged": {
    -   "*.js": [
    +   "*.{js,ts,tsx}": [
    -     "eslint --fix",
    +     "eslint --fix --ext js,ts,tsx",
          "git add"
        ]
      }
  3. Create tsconfig.json

    {
      "compilerOptions": {
        "outDir": "dist/ts",
        "target": "esnext",
        "module": "esnext",
        "moduleResolution": "node",
        "jsx": "react",
        "strict": true,
        "declaration": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitReturns": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "stripInternal": true
      }
    }
  4. Update .babelrc:

      "presets": [
    +   "@babel/preset-typescript"
      ]
  5. Update .eslintrc with these settings:

      "settings": {
        "import/resolver": {
          "node": {
            "extensions": [".js", ".jsx", ".ts", ".tsx"]
          }
        }
      },
      "overrides": [
        {
          "files": ["**/*.ts", "**/*.tsx"],
          "parser": "@typescript-eslint/parser",
          "parserOptions": {
            "project": "./tsconfig.json"
          },
          "plugins": [
            "@typescript-eslint"
          ],
          "rules": {
            "no-undef": "off",
            "no-unused-vars": "off",
            "no-restricted-globals": "off"
          }
        }
      ]

API

Table of Contents

sayHello

This function says hello.

Parameters

  • name string Some name to say hello for. (optional, default "Haz")

Returns string The hello.

License

MIT ยฉ Diego Haz

More Repositories

1

constate

React Context + State
TypeScript
3,924
star
2

arc

React starter kit based on Atomic Design
JavaScript
2,914
star
3

rest

REST API generator with Node.js, Express and Mongoose
JavaScript
1,788
star
4

generact

Generate React components by replicating your own
JavaScript
1,482
star
5

awesome-react-context

๐Ÿ˜Ž A curated list of stuff related to the new React Context API
JavaScript
917
star
6

styled-tools

Useful interpolated functions for CSS-in-JS
JavaScript
802
star
7

schm

Composable schemas for JavaScript and Node.js
JavaScript
513
star
8

reuse

โ™ป๏ธ Reuse React components to create new ones
TypeScript
495
star
9

singel

Single Element Pattern
JavaScript
408
star
10

redux-saga-thunk

Dispatching an action handled by redux-saga returns promise
JavaScript
221
star
11

styled-theme

Extensible theming system for styled-components ๐Ÿ’…
JavaScript
182
star
12

querymen

Querystring parser middleware for MongoDB, Express and Nodejs (MEN)
JavaScript
129
star
13

parse-prop-types

Parses React prop-types into a readable object
JavaScript
69
star
14

bodymen

Body parser middleware for MongoDB, Express and Nodejs (MEN)
JavaScript
47
star
15

list-react-files

List React component files inside a directory
JavaScript
25
star
16

redux-saga-social-login

Facebook/Google login implementation with redux-saga
JavaScript
25
star
17

mongoose-keywords

Mongoose plugin that generates a keywords path combining other paths values
JavaScript
22
star
18

redux-modules

A modular approach to better organize redux stuff (not another library)
JavaScript
21
star
19

coolors-to-hex

Get hexadecimal values from a coolors url
JavaScript
18
star
20

generator-rest-example

A fully commented RESTful API example generated with generator-rest
JavaScript
18
star
21

styled-selector

Get static CSS(-in-JS) selectors from React components
TypeScript
17
star
22

webpack-blocks-split-vendor

A webpack block that splits vendor javascript into separated bundle
JavaScript
15
star
23

webpack-blocks-happypack

A webpack block that adds happypack support to your webpack config
JavaScript
12
star
24

redux-form-submit

Adds an async submit action creator to redux-form
JavaScript
9
star
25

webpack-spawn-plugin

A webpack plugin that runs child_process.spawn within compilation
JavaScript
7
star
26

waterfall-grid

A Polymer wrapper element for waterfall.js, a 1KB Javascript library for Pinterest-like grids.
HTML
7
star
27

webpack-blocks-server-source-map

A webpack block that adds source map support to server bundle
JavaScript
5
star
28

yo

A Yeoman generator for generating next generation of Yeoman generators
JavaScript
5
star
29

webpack-assets-by-type-plugin

A webpack plugin that save assets by type
JavaScript
5
star
30

arc-universal-redux

Universal Redux version of ARc boilerplate
JavaScript
5
star
31

webpack-sort-chunks

Sorts webpack chunks by dependency
JavaScript
4
star
32

webpack-child-config-plugin

A webpack plugin that runs/watches another config
JavaScript
4
star
33

rest-api

REST API Boilerplate with Mongoose, Express and Nodejs
JavaScript
4
star
34

rich-param

An object with name and value which accepts pluggable methods as formatters or validators
JavaScript
3
star
35

reakit-code-lab

TypeScript
3
star
36

arc-fullstack

Fullstack version of ARc boilerplate
JavaScript
3
star
37

is-git-rev

Verify if a string is a git-rev hash
JavaScript
3
star
38

mongoose-create-unique

Mongoose plugin to create a document or return the existing one based on the unique index
JavaScript
3
star
39

divisa

A game about war and peace.
JavaScript
2
star
40

eyeport

Collection of useful methods to deal with element and viewports in DOM
JavaScript
2
star
41

alpha-bank

JavaScript
2
star
42

guild

Just a social network prototype made with jQuery
HTML
2
star
43

adjacente

Blog para disciplina Expansรฃo dos Sentidos
JavaScript
1
star
44

radiotoca

A PHP web radio with Twitter integration
PHP
1
star
45

clone

JavaScript
1
star
46

diegohaz

1
star
47

hear-parse

JavaScript
1
star
48

hear-api

JavaScript
1
star
49

diegohaz.com

JavaScript
1
star