chore: add eslint-jsdoc-plugin to eslint (#1585)

This plugin helps us detect some things the built-in jsdoc rules can't,
like whether there is an example or not.

As expected, the addition of this plugin helped detect some minor JSDoc
issues.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
This commit is contained in:
Juan Cruz Viotti 2017-07-12 10:19:08 -04:00 committed by GitHub
parent 58fa59e06d
commit a5b1a92920
10 changed files with 56 additions and 1 deletions

View File

@ -6,7 +6,13 @@ env:
mocha: true mocha: true
plugins: plugins:
- lodash - lodash
- jsdoc
extends: 'eslint:recommended' extends: 'eslint:recommended'
settings:
jsdoc:
additionalTagNames:
customTags:
- fulfil
rules: rules:
# Possible Errors # Possible Errors
@ -645,3 +651,24 @@ rules:
- error - error
lodash/prefer-times: lodash/prefer-times:
- error - error
# JSDoc
jsdoc/check-param-names:
- error
jsdoc/check-tag-names:
- error
jsdoc/newline-after-description:
- error
jsdoc/require-example:
- error
jsdoc/require-hyphen-before-param-description:
- error
jsdoc/require-param:
- error
jsdoc/require-param-description:
- error
jsdoc/require-param-type:
- error
jsdoc/require-returns-type:
- error

View File

@ -16,6 +16,8 @@
'use strict'; 'use strict';
/* eslint-disable jsdoc/require-example */
const _ = require('lodash'); const _ = require('lodash');
const electron = require('electron'); const electron = require('electron');
const angular = require('angular'); const angular = require('angular');

View File

@ -16,6 +16,8 @@
'use strict'; 'use strict';
/* eslint-disable jsdoc/require-example */
/** /**
* @module Etcher.Components.SVGIcon * @module Etcher.Components.SVGIcon
*/ */

View File

@ -36,6 +36,9 @@ module.exports = function(WarningModalService) {
* @summary Refresh current settings * @summary Refresh current settings
* @function * @function
* @public * @public
*
* @example
* SettingsController.refreshSettings();
*/ */
this.refreshSettings = () => { this.refreshSettings = () => {
this.currentData = settings.getAll(); this.currentData = settings.getAll();

View File

@ -60,6 +60,7 @@ const IMAGE_EXTENSIONS = _.reduce(supportedFileTypes, (accumulator, file) => {
* @fulfil {*} contents * @fulfil {*} contents
* @returns {Promise} * @returns {Promise}
* *
* @example
* extractEntryByPath('my/archive.zip', '_info/logo.svg', { * extractEntryByPath('my/archive.zip', '_info/logo.svg', {
* hooks: { ... }, * hooks: { ... },
* entries: [ ... ], * entries: [ ... ],
@ -98,6 +99,7 @@ const extractEntryByPath = (archive, filePath, options) => {
* @fulfil {Object} - metadata * @fulfil {Object} - metadata
* @returns {Promise} * @returns {Promise}
* *
* @example
* extractArchiveMetadata('my/archive.zip', '.meta', { * extractArchiveMetadata('my/archive.zip', '.meta', {
* hooks: { ... }, * hooks: { ... },
* entries: [ ... ] * entries: [ ... ]

View File

@ -16,6 +16,8 @@
'use strict'; 'use strict';
/* eslint-disable jsdoc/require-example */
const Bluebird = require('bluebird'); const Bluebird = require('bluebird');
const fs = Bluebird.promisifyAll(require('fs')); const fs = Bluebird.promisifyAll(require('fs'));
const PassThroughStream = require('stream').PassThrough; const PassThroughStream = require('stream').PassThrough;

View File

@ -152,7 +152,6 @@ const parsePartitionTables = (image, buffer) => {
* @param {Object} image - image metadata * @param {Object} image - image metadata
* @returns {Promise} * @returns {Promise}
* @fulfil {Object} image * @fulfil {Object} image
* @reject {Error}
* *
* @example * @example
* parsePartitions(image) * parsePartitions(image)

View File

@ -47,6 +47,7 @@ const getExtensionsFromTypeGetter = (type) => {
* *
* @returns {String[]} compressed extensions * @returns {String[]} compressed extensions
* *
* @example
* _.each(supportedFormats.getCompressedExtensions(), (extension) => { * _.each(supportedFormats.getCompressedExtensions(), (extension) => {
* console.log('We support the ' + extension + ' compressed file format'); * console.log('We support the ' + extension + ' compressed file format');
* }); * });
@ -60,6 +61,7 @@ exports.getCompressedExtensions = getExtensionsFromTypeGetter('compressed');
* *
* @returns {String[]} no compressed extensions * @returns {String[]} no compressed extensions
* *
* @example
* _.each(supportedFormats.getNonCompressedExtensions(), (extension) => { * _.each(supportedFormats.getNonCompressedExtensions(), (extension) => {
* console.log('We support the ' + extension + ' file format'); * console.log('We support the ' + extension + ' file format');
* }); * });
@ -73,6 +75,7 @@ exports.getNonCompressedExtensions = getExtensionsFromTypeGetter('image');
* *
* @returns {String[]} archive extensions * @returns {String[]} archive extensions
* *
* @example
* _.each(supportedFormats.getArchiveExtensions(), (extension) => { * _.each(supportedFormats.getArchiveExtensions(), (extension) => {
* console.log('We support the ' + extension + ' file format'); * console.log('We support the ' + extension + ' file format');
* }); * });
@ -86,6 +89,7 @@ exports.getArchiveExtensions = getExtensionsFromTypeGetter('archive');
* *
* @returns {String[]} extensions * @returns {String[]} extensions
* *
* @example
* _.each(supportedFormats.getAllExtensions(), (extension) => { * _.each(supportedFormats.getAllExtensions(), (extension) => {
* console.log('We support the ' + extension + ' format'); * console.log('We support the ' + extension + ' format');
* }); * });
@ -102,6 +106,7 @@ exports.getAllExtensions = () => {
* @param {String} imagePath - image path * @param {String} imagePath - image path
* @returns {Boolean} whether the image is supported * @returns {Boolean} whether the image is supported
* *
* @example
* if (supportedFormats.isSupportedImage('foo.iso.bz2')) { * if (supportedFormats.isSupportedImage('foo.iso.bz2')) {
* console.log('The image is supported!'); * console.log('The image is supported!');
* } * }

12
npm-shrinkwrap.json generated
View File

@ -863,6 +863,12 @@
"from": "commander@>=2.8.1 <2.9.0", "from": "commander@>=2.8.1 <2.9.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz" "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz"
}, },
"comment-parser": {
"version": "0.4.0",
"from": "comment-parser@>=0.4.0 <0.5.0",
"resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.4.0.tgz",
"dev": true
},
"commoner": { "commoner": {
"version": "0.10.8", "version": "0.10.8",
"from": "commoner@>=0.10.3 <0.11.0", "from": "commoner@>=0.10.3 <0.11.0",
@ -1910,6 +1916,12 @@
} }
} }
}, },
"eslint-plugin-jsdoc": {
"version": "3.1.1",
"from": "eslint-plugin-jsdoc@latest",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-3.1.1.tgz",
"dev": true
},
"eslint-plugin-lodash": { "eslint-plugin-lodash": {
"version": "2.3.6", "version": "2.3.6",
"from": "eslint-plugin-lodash@2.3.6", "from": "eslint-plugin-lodash@2.3.6",

View File

@ -87,6 +87,7 @@
"electron-builder": "19.9.1", "electron-builder": "19.9.1",
"electron-mocha": "3.3.0", "electron-mocha": "3.3.0",
"eslint": "3.18.0", "eslint": "3.18.0",
"eslint-plugin-jsdoc": "^3.1.1",
"eslint-plugin-lodash": "2.3.6", "eslint-plugin-lodash": "2.3.6",
"file-exists": "1.0.0", "file-exists": "1.0.0",
"html-angular-validate": "0.1.9", "html-angular-validate": "0.1.9",