Skip to content

Commit

Permalink
Resolve discs 2.0 js-doc errors;
Browse files Browse the repository at this point in the history
Align jscs and eslint config regarding js-doc @returns;
  • Loading branch information
adametry committed Aug 1, 2015
1 parent 89a1bae commit 85672b8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rules:
space-before-function-paren: [2, "never"]
space-after-keywords: [2, "always"]
space-before-blocks: 2
valid-jsdoc: [1, { prefer: { "return": "returns" }}]
valid-jsdoc: [1, { requireReturn: false, prefer: { return": "returns" }}]
wrap-iife: 2
guard-for-in: 2
strict: [2, "global"]
Expand Down
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var util = require('./util');

/**
* Append eslint result to each file
* @param {(object|string)} [options] - Configure rules, env, global, and other options for running eslint
*
* @param {(Object|String)} [options] - Configure rules, env, global, and other options for running eslint
* @returns {stream} gulp file stream
*/
function gulpEslint(options) {
Expand Down Expand Up @@ -42,6 +43,7 @@ function gulpEslint(options) {

/**
* Fail when an eslint error is found in eslint results.
*
* @returns {stream} gulp file stream
*/
gulpEslint.failOnError = function() {
Expand Down Expand Up @@ -71,6 +73,7 @@ gulpEslint.failOnError = function() {

/**
* Fail when the stream ends if any eslint error(s) occurred
*
* @returns {stream} gulp file stream
*/
gulpEslint.failAfterError = function() {
Expand Down Expand Up @@ -101,8 +104,9 @@ gulpEslint.failAfterError = function() {

/**
* Wait until all files have been linted and format all results at once.
* @param {(string|function)} [formatter=stylish] - The name or function for a eslint result formatter
* @param {(function|stream)} [writable=gulp-util.log] - A funtion or stream to write the formatted eslint results.
*
* @param {(String|Function)} [formatter=stylish] - The name or function for a eslint result formatter
* @param {(Function|stream)} [writable=gulp-util.log] - A funtion or stream to write the formatted eslint results.
* @returns {stream} gulp file stream
*/
gulpEslint.format = function(formatter, writable) {
Expand All @@ -128,8 +132,9 @@ gulpEslint.format = function(formatter, writable) {

/**
* Format the results of each file individually.
* @param {(string|function)} [formatter=stylish] - The name or function for a eslint result formatter
* @param {(function|stream)} [writable=gulp-util.log] - A funtion or stream to write the formatted eslint results.
*
* @param {(String|Function)} [formatter=stylish] - The name or function for a eslint result formatter
* @param {(Function|Stream)} [writable=gulp-util.log] - A funtion or stream to write the formatted eslint results.
* @returns {stream} gulp file stream
*/
gulpEslint.formatEach = function(formatter, writable) {
Expand Down
17 changes: 9 additions & 8 deletions test/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('gulp-eslint format', function() {
/**
* Custom eslint formatted result writer for counting write attempts
* rather than writing to the console.
* @param {string} message - a message to count as written
* @returns {undefined} void
*
* @param {String} message - a message to count as written
*/
function outputWriter(message) {
should.exist(message);
Expand All @@ -47,9 +47,9 @@ describe('gulp-eslint format', function() {

/**
* Custom eslint formatted result writer that will throw an exception
* @exception Error Always thrown to test error handling in writers
* @param {string} message - a message to trigger an error
* @returns {undefined} void
*
* @throws Error Always thrown to test error handling in writers
* @param {String} message - a message to trigger an error
*/
function failWriter(message) {
var error = new Error('Writer Test Error');
Expand All @@ -61,9 +61,10 @@ describe('gulp-eslint format', function() {
/**
* Custom eslint result formatter for counting format passes and
* returning a expected formatted result message.
* @param {array} results - eslint results
* @param {object} config - format config
* @returns {string} formatted results
*
* @param {Array} results - eslint results
* @param {Object} config - format config
* @returns {String} formatted results
*/
function formatResults(results, config) {
should.exist(config);
Expand Down
42 changes: 24 additions & 18 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ var ignoreFileFinder = new FileFinder('.eslintignore');

/**
* Convenience method for creating a transform stream in object mode
* @param {function} transform - An async function that is called for each stream chunk
* @param {function} [flush] - An async function that is called before closing the stream
*
* @param {Function} transform - An async function that is called for each stream chunk
* @param {Function} [flush] - An async function that is called before closing the stream
* @returns {stream} A transform stream
*/
exports.transform = function(transform, flush) {
Expand All @@ -31,9 +32,10 @@ exports.transform = function(transform, flush) {
/**
* Mimic the CLIEngine.isPathIgnored,
* but resolve .eslintignore based on file's directory rather than process.cwd()
* @param {object} file - file with a "path" property
* @param {object} options - linter options
* @returns {boolean} Whether the path is ignored
*
* @param {Object} file - file with a "path" property
* @param {Object} options - linter options
* @returns {Boolean} Whether the path is ignored
*/
exports.isPathIgnored = function(file, options) {
var filePath;
Expand All @@ -56,8 +58,9 @@ exports.isPathIgnored = function(file, options) {

/**
* Create config helper to merge various config sources
* @param {object} options - options to migrate
* @returns {object} migrated options
*
* @param {Object} options - options to migrate
* @returns {Object} migrated options
*/
exports.migrateOptions = function migrateOptions(options) {
if (typeof options === 'string') {
Expand Down Expand Up @@ -107,8 +110,9 @@ exports.migrateOptions = function migrateOptions(options) {

/**
* Resolve writable
* @param {object} message - an eslint message
* @returns {boolean} whether the message is an error message
*
* @param {Object} message - an eslint message
* @returns {Boolean} whether the message is an error message
*/
exports.isErrorMessage = function(message) {
var level = message.fatal ? 2 : message.severity;
Expand All @@ -120,9 +124,10 @@ exports.isErrorMessage = function(message) {

/**
* Resolve formatter from unknown type (accepts string or function)
* @exception TypeError thrown if unable to resolve the formatter type
* @param {(string|function)} [formatter=stylish] - A name to resolve as a formatter. If a function is provided, the same function is returned.
* @returns {function} An eslint formatter
*
* @throws TypeError thrown if unable to resolve the formatter type
* @param {(String|Function)} [formatter=stylish] - A name to resolve as a formatter. If a function is provided, the same function is returned.
* @returns {Function} An eslint formatter
*/
exports.resolveFormatter = function(formatter) {
// use eslint to look up formatter references
Expand All @@ -141,8 +146,9 @@ exports.resolveFormatter = function(formatter) {

/**
* Resolve writable
* @param {(function|stream)} [writable=gulp-util.log] - A stream or function to resolve as a format writer
* @returns {function} A function that writes formatted messages
*
* @param {(Function|stream)} [writable=gulp-util.log] - A stream or function to resolve as a format writer
* @returns {Function} A function that writes formatted messages
*/
exports.resolveWritable = function(writable) {
if (!writable) {
Expand All @@ -155,10 +161,10 @@ exports.resolveWritable = function(writable) {

/**
* Write formatter results to writable/output
* @param {object[]} results - A list of eslint results
* @param {function} formatter - A function used to format eslint results
* @param {function} writable - A function used to write formatted eslint results
* @returns {undefined} void
*
* @param {Object[]} results - A list of eslint results
* @param {Function} formatter - A function used to format eslint results
* @param {Function} writable - A function used to write formatted eslint results
*/
exports.writeResults = function(results, formatter, writable) {
var config;
Expand Down

0 comments on commit 85672b8

Please sign in to comment.