From f77ca5d56c06a98cd81ade020a2ffbf2c73940a6 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Wed, 14 Dec 2016 00:16:55 -0800 Subject: [PATCH] added linting and testing boilerplate with sanity check --- .babelrc | 4 ++++ .eslintrc | 15 +++++++++++++++ .jshintrc | 3 --- Makefile | 13 ++++++++++++- debug.js | 6 ------ package.json | 12 +++++++++++- test/debug_spec.js | 12 ++++++++++++ test/mocha.opts | 1 + 8 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 .babelrc create mode 100644 .eslintrc delete mode 100644 .jshintrc create mode 100644 test/debug_spec.js create mode 100644 test/mocha.opts diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..1b790bfa --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["es2015"], + "sourceMaps": true +} diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..21bfbb5a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "parser": "babel-eslint", + "env": { + "browser": true, + "node": true + }, + "rules": { + "no-console": 0 + }, + "extends": "eslint:recommended" +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 299877f2..00000000 --- a/.jshintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "laxbreak": true -} diff --git a/Makefile b/Makefile index db71cafc..19716b29 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ - # get Makefile directory name: http://stackoverflow.com/a/5982798/376773 THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) @@ -6,12 +5,18 @@ THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) # BIN directory BIN := $(THIS_DIR)/node_modules/.bin +# Path +PATH := node_modules/.bin:$(PATH) +SHELL := /bin/bash + # applications NODE ?= $(shell which node) YARN ?= $(shell which yarn) PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm)) BROWSERIFY ?= $(NODE) $(BIN)/browserify +.FORCE: + all: dist/debug.js install: node_modules @@ -33,5 +38,11 @@ distclean: clean node_modules: package.json @NODE_ENV= $(PKG) install @touch node_modules + +lint: .FORCE + eslint debug.js + +test: .FORCE + mocha .PHONY: all install clean distclean diff --git a/debug.js b/debug.js index 4ea6d93e..7b0632db 100644 --- a/debug.js +++ b/debug.js @@ -28,12 +28,6 @@ exports.skips = []; exports.formatters = {}; -/** - * Previously assigned color. - */ - -var prevColor = 0; - /** * Previous log timestamp. */ diff --git a/package.json b/package.json index 18d69eb0..5dd407ac 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,18 @@ "ms": "0.7.2" }, "devDependencies": { + "babel": "^6.5.2", + "babel-eslint": "^7.1.1", + "babel-polyfill": "^6.20.0", + "babel-preset-es2015": "^6.18.0", + "babel-register": "^6.18.0", + "babel-runtime": "^6.20.0", "browserify": "9.0.3", - "mocha": "*" + "chai": "^3.5.0", + "eslint": "^3.12.1", + "eslint-plugin-babel": "^4.0.0", + "mocha": "^3.2.0", + "sinon": "^1.17.6" }, "main": "./index.js", "browser": "./browser.js", diff --git a/test/debug_spec.js b/test/debug_spec.js new file mode 100644 index 00000000..b0339218 --- /dev/null +++ b/test/debug_spec.js @@ -0,0 +1,12 @@ +import { expect } from 'chai'; + +import debug from '../index'; + +describe('debug', () => { + describe('sanity check', () => { + it('passes', () => { + const log = debug('test'); + log('hello world'); + }); + }); +}) diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 00000000..6b233a1c --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1 @@ +--compilers js:babel-register