diff --git a/.babelrc b/.babelrc index 341114c..a34ccc8 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,10 @@ { - "presets": ["es2015", "stage-0"] + "presets": ["es2015", "stage-0"], + "env": { + "test": { + "plugins": [ + "istanbul" + ] + } + } } diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..60c59df --- /dev/null +++ b/.eslintrc @@ -0,0 +1,8 @@ +{ + "extends": "trendmicro", + "parser": "babel-eslint", + "env": { + "browser": true, + "node": true + } +} diff --git a/.gitignore b/.gitignore index efa1fa9..7e8094c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules +/.nyc_output /lib /coverage diff --git a/.travis.yml b/.travis.yml index e66114a..f3e4e18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,3 @@ node_js: - '4' after_success: - npm run coveralls - - npm run coverage-clean diff --git a/gulpfile.babel.js b/gulpfile.babel.js deleted file mode 100644 index 11373b8..0000000 --- a/gulpfile.babel.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -import gulp from 'gulp'; -import babel from 'gulp-babel'; -import istanbul from 'gulp-istanbul'; -import mocha from 'gulp-mocha'; - -gulp.task('pre-test', () => { - return gulp.src(['lib/index.js']) - // Covering files - .pipe(istanbul()) - // Force `require` to return covered files - .pipe(istanbul.hookRequire()); -}); - -gulp.task('test', ['pre-test'], () => { - return gulp.src(['test/*.js']) - .pipe(mocha({ compilers: 'js:babel-core/register' })) - // Creating the reports after tests ran - .pipe(istanbul.writeReports()) - // Checking coverage against minimum acceptable thresholds - .pipe(istanbul.enforceThresholds({ - thresholds: { - global: { - statements: 95, - branches: 70, - functions: 85, - lines: 95 - } - } - })); -}); - -gulp.task('default', () => { - return gulp.src([ - 'src/index.js' - ]) - .pipe(babel({ - presets: ['es2015', 'stage-0'] - })) - .pipe(gulp.dest('lib')); -}); diff --git a/package.json b/package.json index 58d50cd..4567340 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gcode-interpreter", - "version": "1.2.0", + "version": "1.3.0", "description": "G-code Interpreter", "author": "Cheton Wu ", "homepage": "https://github.com/cncjs/gcode-interpreter", @@ -17,27 +17,43 @@ "gcode" ], "scripts": { - "prepublish": "npm run build && npm test", - "build": "gulp", - "test": "gulp test", - "coverage": "istanbul cover node_modules/mocha/bin/_mocha -- --require babel-core/register -R spec", - "coverage-clean": "rm -rf ./coverage", + "prepublish": "npm run eslint && npm run build && npm test", + "eslint": "eslint src", + "build": "babel --out-dir ./lib ./src", + "test": "cross-env NODE_ENV=test nyc mocha", "coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls" }, "main": "lib/index.js", "dependencies": { - "gcode-parser": "^1.2.0" + "gcode-parser": "^1.3.0" }, "devDependencies": { - "babel-core": "^6.26.0", + "babel-cli": "^6.26.0", + "babel-eslint": "^8.0.1", + "babel-plugin-istanbul": "^4.1.5", "babel-preset-es2015": "^6.24.1", "babel-preset-stage-0": "^6.24.1", - "chai": "^3.5.0", - "coveralls": "^2.13.2", - "gulp": "^3.9.1", - "gulp-babel": "^7.0.0", - "gulp-istanbul": "^1.1.2", - "gulp-mocha": "^4.3.1", - "mocha": "^3.5.3" + "babel-register": "^6.26.0", + "chai": "^4.1.2", + "coveralls": "^3.0.0", + "cross-env": "^5.0.5", + "eslint": "^4.7.2", + "eslint-config-trendmicro": "^1.0.0", + "eslint-plugin-import": "^2.7.0", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.4.0", + "mocha": "^3.5.3", + "nyc": "^11.2.1" + }, + "nyc": { + "require": [ + "babel-register" + ], + "reporter": [ + "lcov", + "text" + ], + "sourceMap": false, + "instrument": false } } diff --git a/src/index.js b/src/index.js index 8c4125c..f28156b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,4 @@ +/* eslint no-continue: 0 */ import { parseStream, parseFile, diff --git a/test/index.js b/test/index.js index dc9cb1f..d9a9f01 100644 --- a/test/index.js +++ b/test/index.js @@ -1,10 +1,7 @@ -import chai from 'chai'; +import { expect } from 'chai'; import fs from 'fs'; import { GCodeInterpreter } from '../lib/'; -const expect = chai.expect; -const should = chai.should(); - describe('G-code Interpreter', () => { describe('Pass a null value as the first argument', () => { class GCodeRunner extends GCodeInterpreter { @@ -41,7 +38,7 @@ describe('G-code Interpreter', () => { runner .loadFromFile(file, (err, results) => { - expect(err).to.be.okay; + expect(err).to.be.null; done(); }) .on('data', (data) => { @@ -59,7 +56,7 @@ describe('G-code Interpreter', () => { runner .loadFromStream(stream, (err, results) => { - expect(err).to.be.okay; + expect(err).to.be.null; done(); }) .on('data', (data) => { @@ -77,7 +74,7 @@ describe('G-code Interpreter', () => { runner .loadFromString(string, (err, results) => { - expect(err).to.be.okay; + expect(err).to.be.null; done(); }) .on('data', (data) => {