Skip to content

Commit

Permalink
feat: add a jsdoc option so that projects can ignore jsdoc rules (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Sep 7, 2018
1 parent f72c553 commit 9630cdc
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
tmp/
.eslintcache
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ Lead Maintainer: Pat O'Neill [@misteroneill](https://github.com/misteroneill)

Maintenance Status: Stable

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [Install](#install)
- [Usage](#usage)
- [Arguments](#arguments)
- [Options](#options)
- [`-e`/`--errors`](#-e--errors)
- [`-w`/`--warnings`](#-w--warnings)
- [`--format`/`--fix`](#--format--fix)
- [`--help`](#--help)
- [`--version`](#--version)
- [Ignoring Files](#ignoring-files)
- [Don't check jsdoc](#dont-check-jsdoc)
- [Contributing](#contributing)
- [Versioning Guidelines](#versioning-guidelines)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Install

```bash
Expand Down Expand Up @@ -87,6 +108,20 @@ File [glob][glob] patterns can be ignored by adding them to your project's `pack
}
```

### Don't check jsdoc

> Note: By default this option is set to true, even if the option is not provided.
Some projects don't use jsdoc and don't care if jsdoc exists or not. We added an option that you can add in you `package.json` in order to turn off all the jsdoc rules. All you have to do is set `vjsstandard.jsdoc` to `false`:

```json
{
"vjsstandard": {
"jsdoc": false,
}
}
```

## Contributing

This project should almost never change.
Expand Down
16 changes: 13 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const path = require('path');
const os = require('os');
const tsmlb = require('tsmlb');
const filterer = require('./filterer');
const ignores = require('./ignores');
const getConfig = require('./get-config');
const pkg = require(path.join(__dirname, 'package.json'));

commander.
Expand All @@ -27,12 +27,22 @@ if (!commander.targets || !commander.targets.length) {
commander.targets = ['.'];
}

const config = getConfig(process.cwd());
const rules = {};

if (config.jsdoc === false) {
rules['require-jsdoc'] = 'off';
rules['valid-jsdoc'] = 'off';
rules['jsdoc/newline-after-description'] = 'off';
}

const cli = new CLIEngine({
cwd: process.cwd(),
configFile: path.join(__dirname, 'eslintrc.json'),
fix: Boolean(commander.format),
ignorePattern: ignores(process.cwd()),
cache: true
ignorePattern: config.ignore,
cache: true,
rules
});

const report = filterer(cli.executeOnFiles(commander.targets),
Expand Down
6 changes: 2 additions & 4 deletions ignores.js → get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ module.exports = function ignores(dir) {
try {
root = findRoot(dir);
} catch (x) {
return;
return {};
}

const pkg = require(path.join(root, 'package.json'));

if (pkg.vjsstandard && pkg.vjsstandard.hasOwnProperty('ignore')) {
return pkg.vjsstandard.ignore;
}
return pkg.vjsstandard || {};
};
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9630cdc

Please sign in to comment.