From 7e956ac401da268aacb6b2c03541bc8f5a57d340 Mon Sep 17 00:00:00 2001 From: Mickael Jeanroy Date: Sat, 1 Jun 2019 22:25:26 +0200 Subject: [PATCH] chore: update eslint configuration --- .eslintrc | 22 +++++++++++++++-- scripts/lint/index.js | 7 ++++++ scripts/log/index.js | 53 ++++++++++++++++++++++++++++++++++++++++ scripts/release/index.js | 2 +- src/license-plugin.js | 1 + test/.eslintrc | 6 +++++ 6 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 scripts/log/index.js create mode 100644 test/.eslintrc diff --git a/.eslintrc b/.eslintrc index 78b9280c..59a38352 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,12 +1,30 @@ { - "extends": "google", + "extends": [ + "eslint:recommended", + "google" + ], "parserOptions": { "ecmaVersion": 6 }, "env": { + "es6": true, "node": true }, "rules": { - "max-len": [2, 140, 2] + "max-len": [2, 140, 2], + "no-console": [0], + "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 c8cc897e..b07fb6cd 100644 --- a/scripts/lint/index.js +++ b/scripts/lint/index.js @@ -25,6 +25,7 @@ const path = require('path'); const gulp = require('gulp'); const eslint = require('gulp-eslint'); +const log = require('../log'); const config = require('../config'); module.exports = function lint() { @@ -35,6 +36,12 @@ module.exports = function lint() { path.join(config.scripts, '**', '*.js'), ]; + log.debug('Linting files: '); + + src.forEach((input) => ( + log.debug(` ${input}`) + )); + 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 341fe0d9..1eb8d234 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/src/license-plugin.js b/src/license-plugin.js index 6fe52db5..8e6fd44d 100644 --- a/src/license-plugin.js +++ b/src/license-plugin.js @@ -321,6 +321,7 @@ module.exports = class LicensePlugin { * Log debug message if debug mode is enabled. * * @param {string} msg Log message. + * @return {void} */ debug(msg) { if (this._debug) { 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