Skip to content

Commit 9630cdc

Browse files
committed
feat: add a jsdoc option so that projects can ignore jsdoc rules (#36)
1 parent f72c553 commit 9630cdc

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
tmp/
3+
.eslintcache

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ Lead Maintainer: Pat O'Neill [@misteroneill](https://github.com/misteroneill)
1212

1313
Maintenance Status: Stable
1414

15+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
16+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
17+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
18+
19+
- [Install](#install)
20+
- [Usage](#usage)
21+
- [Arguments](#arguments)
22+
- [Options](#options)
23+
- [`-e`/`--errors`](#-e--errors)
24+
- [`-w`/`--warnings`](#-w--warnings)
25+
- [`--format`/`--fix`](#--format--fix)
26+
- [`--help`](#--help)
27+
- [`--version`](#--version)
28+
- [Ignoring Files](#ignoring-files)
29+
- [Don't check jsdoc](#dont-check-jsdoc)
30+
- [Contributing](#contributing)
31+
- [Versioning Guidelines](#versioning-guidelines)
32+
- [License](#license)
33+
34+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
35+
1536
## Install
1637

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

111+
### Don't check jsdoc
112+
113+
> Note: By default this option is set to true, even if the option is not provided.
114+
115+
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`:
116+
117+
```json
118+
{
119+
"vjsstandard": {
120+
"jsdoc": false,
121+
}
122+
}
123+
```
124+
90125
## Contributing
91126

92127
This project should almost never change.

cli.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const path = require('path');
88
const os = require('os');
99
const tsmlb = require('tsmlb');
1010
const filterer = require('./filterer');
11-
const ignores = require('./ignores');
11+
const getConfig = require('./get-config');
1212
const pkg = require(path.join(__dirname, 'package.json'));
1313

1414
commander.
@@ -27,12 +27,22 @@ if (!commander.targets || !commander.targets.length) {
2727
commander.targets = ['.'];
2828
}
2929

30+
const config = getConfig(process.cwd());
31+
const rules = {};
32+
33+
if (config.jsdoc === false) {
34+
rules['require-jsdoc'] = 'off';
35+
rules['valid-jsdoc'] = 'off';
36+
rules['jsdoc/newline-after-description'] = 'off';
37+
}
38+
3039
const cli = new CLIEngine({
3140
cwd: process.cwd(),
3241
configFile: path.join(__dirname, 'eslintrc.json'),
3342
fix: Boolean(commander.format),
34-
ignorePattern: ignores(process.cwd()),
35-
cache: true
43+
ignorePattern: config.ignore,
44+
cache: true,
45+
rules
3646
});
3747

3848
const report = filterer(cli.executeOnFiles(commander.targets),

ignores.js renamed to get-config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ module.exports = function ignores(dir) {
1313
try {
1414
root = findRoot(dir);
1515
} catch (x) {
16-
return;
16+
return {};
1717
}
1818

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

21-
if (pkg.vjsstandard && pkg.vjsstandard.hasOwnProperty('ignore')) {
22-
return pkg.vjsstandard.ignore;
23-
}
21+
return pkg.vjsstandard || {};
2422
};

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)