From 64f660dc87fad6746f08f750a469c13f2018e4d6 Mon Sep 17 00:00:00 2001 From: Anatoly Bubenkov Date: Thu, 1 Mar 2018 21:07:44 +0100 Subject: [PATCH] feat: Support `--shallow` argument for `lint` command. Closes #956 (#995) --- __tests__/bin.js | 9 +++++++++ .../fixture/lint/lint.input.dependency.js | 19 +++++++++++++++++++ __tests__/fixture/lint/lint.input.shallow.js | 7 +++++++ src/commands/lint.js | 5 ++++- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 __tests__/fixture/lint/lint.input.dependency.js create mode 100644 __tests__/fixture/lint/lint.input.shallow.js diff --git a/__tests__/bin.js b/__tests__/bin.js index fca6d019e..7ced5698c 100644 --- a/__tests__/bin.js +++ b/__tests__/bin.js @@ -228,6 +228,15 @@ describe('lint command', function() { expect(err.code > 0).toBeTruthy(); } }); + + test('generates lint output with shallow', async function() { + const data = await documentation( + ['lint fixture/lint/lint.input.shallow.js --shallow'], + {}, + false + ); + expect(data).toBe(''); + }); }); test('given no files', async function() { diff --git a/__tests__/fixture/lint/lint.input.dependency.js b/__tests__/fixture/lint/lint.input.dependency.js new file mode 100644 index 000000000..b4ff5d4d8 --- /dev/null +++ b/__tests__/fixture/lint/lint.input.dependency.js @@ -0,0 +1,19 @@ +/** + * @param {String} foo bar + * @returns {object} bad object return type + * @type {Array} bad object type + * @memberof notfound + */ + +/** + * @param {String} baz bar + * @property {String} bad property + * @private + */ + +/** + * @param {number} c explicit but not found + */ +function add(a, b) {} + +module.exports.add = add; diff --git a/__tests__/fixture/lint/lint.input.shallow.js b/__tests__/fixture/lint/lint.input.shallow.js new file mode 100644 index 000000000..aa404f37e --- /dev/null +++ b/__tests__/fixture/lint/lint.input.shallow.js @@ -0,0 +1,7 @@ +var dep = require('./lint.input.dependency'); + +/** + * @param {string} a + * @param {boolean} b + */ +function add(a, b) {} diff --git a/src/commands/lint.js b/src/commands/lint.js index d6ef90cff..a2cfbd49a 100644 --- a/src/commands/lint.js +++ b/src/commands/lint.js @@ -3,12 +3,15 @@ const documentation = require('../'); const fs = require('fs'); const path = require('path'); +const sharedOptions = require('./shared_options'); /* eslint no-console: 0 */ module.exports.command = 'lint [input..]'; module.exports.description = 'check for common style and uniformity mistakes'; -module.exports.builder = {}; +module.exports.builder = { + shallow: sharedOptions.sharedInputOptions.shallow +}; /** * Wrap around the documentation.lint method and add the additional