Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a jsdoc option so that projects can ignore jsdoc rules #36

Merged
merged 2 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
<!-- 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)*

- [video.js Standard Style](#videojs-standard-style)
- [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 -->

# video.js Standard Style

[![Build Status](https://travis-ci.org/videojs/standard.svg?branch=master)](https://travis-ci.org/videojs/standard)
Expand Down Expand Up @@ -87,6 +109,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.