diff --git a/.eslintrc b/.eslintrc index dd56667a..d5e6ed3e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,12 +1,32 @@ { - "extends": "google", + "extends": [ + "eslint:recommended", + "google" + ], "parserOptions": { - "ecmaVersion": 6, + "ecmaVersion": 6 }, "env": { + "es6": true, "node": true }, "rules": { - "max-len": [2, 140, 2] + "max-len": [2, 140, 2], + "no-console": [2, { + "allow": ["warn", "error"] + }], + "valid-jsdoc": [2, { + "requireReturn": true, + "requireParamDescription": true, + "requireReturnDescription": true, + "prefer": { + "return": "return", + "arg": "param", + "argument": "param" + }, + "preferType": { + "object": "object" + } + }] } } diff --git a/scripts/lint/index.js b/scripts/lint/index.js index 8e527324..9c667b3e 100644 --- a/scripts/lint/index.js +++ b/scripts/lint/index.js @@ -26,6 +26,7 @@ const path = require('path'); const gulp = require('gulp'); const eslint = require('gulp-eslint'); const config = require('../config'); +const log = require('../log'); module.exports = function lint() { const src = [ @@ -35,6 +36,12 @@ module.exports = function lint() { path.join(config.scripts, '**', '*.js'), ]; + log.debug('Linting files: '); + + src.forEach((f) => { + log.debug(` ${f}`); + }); + return gulp.src(src) .pipe(eslint()) .pipe(eslint.format()) diff --git a/scripts/log/index.js b/scripts/log/index.js new file mode 100644 index 00000000..b8925026 --- /dev/null +++ b/scripts/log/index.js @@ -0,0 +1,53 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2016-2018 Mickael Jeanroy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +'use strict'; + +const log = require('fancy-log'); +const colors = require('ansi-colors'); + +/** + * Log message to output using `DEBUG` level. + * + * @param {string} msg Message to log. + * @return {void} + */ +function debug(msg) { + log(colors.grey(msg)); +} + +/** + * Log message to output using `ERROR` level. + * + * @param {string} msg Message to log. + * @return {void} + */ +function error(msg) { + log(colors.red(msg)); +} + +module.exports = { + debug, + error, +}; diff --git a/scripts/release/index.js b/scripts/release/index.js index f033d83f..20591457 100644 --- a/scripts/release/index.js +++ b/scripts/release/index.js @@ -26,7 +26,7 @@ const fs = require('fs'); const gulp = require('gulp'); const git = require('gulp-git'); const bump = require('gulp-bump'); -const log = require('fancy-log'); +const log = require('../log'); const config = require('../config'); /** diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000..f6524563 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,6 @@ +{ + "env": { + "jasmine": true + } +} + \ No newline at end of file