UNPKG

canonical

Version:

Canonical code style linter and formatter for JavaScript, SCSS and CSS.

85 lines (84 loc) 19.5 kB
{ "_args": [ [ "eslint-plugin-jsdoc@https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-2.2.1.tgz", "/Users/gajus/Documents/dev/canonical-code-style/canonical" ] ], "_from": "eslint-plugin-jsdoc@>=2.1.1 <3.0.0", "_id": "eslint-plugin-jsdoc@2.2.1", "_inCache": true, "_location": "/eslint-plugin-jsdoc", "_phantomChildren": {}, "_requested": { "name": "eslint-plugin-jsdoc", "raw": "eslint-plugin-jsdoc@https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-2.2.1.tgz", "rawSpec": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-2.2.1.tgz", "scope": null, "spec": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-2.2.1.tgz", "type": "remote" }, "_requiredBy": [ "/eslint-config-canonical-jsdoc" ], "_resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-2.2.1.tgz", "_shasum": "286b2399b3e8fbdf8d5adebb826192b4da805431", "_shrinkwrap": null, "_spec": "eslint-plugin-jsdoc@https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-2.2.1.tgz", "_where": "/Users/gajus/Documents/dev/canonical-code-style/canonical", "author": { "email": "gajus@gajus.com", "name": "Gajus Kuizinas", "url": "http://gajus.com" }, "bugs": { "url": "https://github.com/gajus/eslint-plugin-jsdoc/issues" }, "dependencies": { "comment-parser": "^0.3.1", "lodash": "^3.10.1" }, "description": "JSDoc linting rules for ESLint.", "devDependencies": { "babel-cli": "^6.3.17", "babel-preset-es2015": "^6.3.13", "chai": "^3.4.1", "eslint": "^1.10.3", "gitdown": "^2.4.0", "globby": "^4.0.0", "mocha": "^2.3.4", "pragmatist": "^2.3.13" }, "homepage": "https://github.com/gajus/eslint-plugin-jsdoc#readme", "keywords": [ "eslint", "jsdoc", "plugin" ], "license": "BSD-3-Clause", "main": "./dist/index.js", "name": "eslint-plugin-jsdoc", "optionalDependencies": {}, "peerDependencies": { "eslint": ">=0.8.0" }, "readme": "<h1 id=\"eslint-plugin-jsdoc\">eslint-plugin-jsdoc</h1>\n\n[![NPM version](http://img.shields.io/npm/v/eslint-plugin-jsdoc.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-jsdoc)\n[![Travis build status](http://img.shields.io/travis/gajus/eslint-plugin-jsdoc/master.svg?style=flat-square)](https://travis-ci.org/gajus/eslint-plugin-jsdoc)\n[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n\nJSDoc linting rules for ESLint.\n\n* [eslint-plugin-jsdoc](#eslint-plugin-jsdoc)\n * [Reference to jscs-jsdoc](#eslint-plugin-jsdoc-reference-to-jscs-jsdoc)\n * [Installation](#eslint-plugin-jsdoc-installation)\n * [Configuration](#eslint-plugin-jsdoc-configuration)\n * [Settings](#eslint-plugin-jsdoc-settings)\n * [Alias Preference](#eslint-plugin-jsdoc-settings-alias-preference)\n * [Rules](#eslint-plugin-jsdoc-rules)\n * [`check-param-names`](#eslint-plugin-jsdoc-rules-check-param-names)\n * [`check-tag-names`](#eslint-plugin-jsdoc-rules-check-tag-names)\n * [`check-types`](#eslint-plugin-jsdoc-rules-check-types)\n * [`newline-after-description`](#eslint-plugin-jsdoc-rules-newline-after-description)\n * [`require-description-complete-sentence`](#eslint-plugin-jsdoc-rules-require-description-complete-sentence)\n * [`require-param-description`](#eslint-plugin-jsdoc-rules-require-param-description)\n * [`require-param`](#eslint-plugin-jsdoc-rules-require-param)\n * [`require-param-description`](#eslint-plugin-jsdoc-rules-require-param-description)\n * [`require-param-type`](#eslint-plugin-jsdoc-rules-require-param-type)\n * [`require-returns-description`](#eslint-plugin-jsdoc-rules-require-returns-description)\n * [`require-returns-type`](#eslint-plugin-jsdoc-rules-require-returns-type)\n\n\n<h3 id=\"eslint-plugin-jsdoc-reference-to-jscs-jsdoc\">Reference to jscs-jsdoc</h3>\n\nThis table maps the rules between `eslint-plugin-jsdoc` and `jscs-jsdoc`.\n\n| `eslint-plugin-jsdoc` | `jscs-jsdoc` |\n| --- | --- |\n| [`check-param-names`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-param-names) | [`checkParamNames`](https://github.com/jscs-dev/jscs-jsdoc#checkparamnames) |\n| [`check-tag-names`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-tag-names) | N/A ~ [`checkAnnotations`](https://github.com/jscs-dev/jscs-jsdoc#checkannotations) |\n| [`check-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-types) | [`checkTypes`](https://github.com/jscs-dev/jscs-jsdoc#checktypes) |\n| [`newline-after-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description) | [`requireNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirenewlineafterdescription) and [`disallowNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#disallownewlineafterdescription) |\n| [`require-description-complete-sentence`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence) | [`requireDescriptionCompleteSentence`](https://github.com/jscs-dev/jscs-jsdoc#requiredescriptioncompletesentence) |\n| [`require-hyphen-before-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-hyphen-before-description) | [`requireHyphenBeforeDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirehyphenbeforedescription) |\n| [`require-param`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param) | [`checkParamExistence`](https://github.com/jscs-dev/jscs-jsdoc#checkparamexistence) |\n| [`require-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-description) | [`requireParamDescription`](https://github.com/jscs-dev/jscs-jsdoc#requireparamdescription) |\n| [`require-param-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type) | [`requireParamTypes`](https://github.com/jscs-dev/jscs-jsdoc#requireparamtypes) |\n| [`require-returns-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-description) | [`requireReturnDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirereturndescription) |\n| [`require-returns-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type) | [`requireReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#requirereturntypes) |\n| N/A | [`checkReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#checkreturntypes) |\n| N/A | [`checkRedundantParams`](https://github.com/jscs-dev/jscs-jsdoc#checkredundantparams) |\n| N/A | [`checkReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#checkreturntypes) |\n| N/A | [`checkRedundantAccess`](https://github.com/jscs-dev/jscs-jsdoc#checkredundantaccess) |\n| N/A | [`enforceExistence`](https://github.com/jscs-dev/jscs-jsdoc#enforceexistence) |\n| N/A | [`leadingUnderscoreAccess`](https://github.com/jscs-dev/jscs-jsdoc#leadingunderscoreaccess) |\n\n<h2 id=\"eslint-plugin-jsdoc-installation\">Installation</h2>\n\nInstall [ESLint](https://www.github.com/eslint/eslint) either locally or globally.\n\n```sh\nnpm install eslint\n```\n\nIf you have installed `ESLint` globally, you have to install JSDoc plugin globally too. Otherwise, install it locally.\n\n```sh\nnpm install eslint-plugin-jsdoc\n```\n\n<h2 id=\"eslint-plugin-jsdoc-configuration\">Configuration</h2>\n\nAdd `plugins` section and specify `eslint-plugin-jsdoc` as a plugin.\n\n```json\n{\n \"plugins\": [\n \"jsdoc\"\n ]\n}\n```\n\nFinally, enable all of the rules that you would like to use.\n\n```json\n{\n \"rules\": {\n \"jsdoc/check-param-names\": 1,\n \"jsdoc/check-tag-names\": 1,\n \"jsdoc/check-types\": 1,\n \"jsdoc/newline-after-description\": 1,\n \"jsdoc/require-description-complete-sentence\": 1,\n \"jsdoc/require-hyphen-before-description\": 1,\n \"jsdoc/require-param\": 1,\n \"jsdoc/require-param-description\": 1,\n \"jsdoc/require-param-type\": 1,\n \"jsdoc/require-returns-description\": 1,\n \"jsdoc/require-returns-type\": 1\n }\n}\n```\n\n<h2 id=\"eslint-plugin-jsdoc-settings\">Settings</h2>\n\n<h3 id=\"eslint-plugin-jsdoc-settings-alias-preference\">Alias Preference</h3>\n\nUse `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a JSDoc tag. The format of the configuration is: `<primary tag name>: <preferred alias name>`, e.g.\n\n```json\n{\n \"rules\": {},\n \"settings\": {\n \"jsdoc\": {\n \"tagNamePreference\": {\n \"param\": \"arg\",\n \"returns\": \"return\"\n }\n }\n }\n}\n```\n\n<h2 id=\"eslint-plugin-jsdoc-rules\">Rules</h2>\n\n<h3 id=\"eslint-plugin-jsdoc-rules-check-param-names\"><code>check-param-names</code></h3>\n\nEnsures that parameter names in JSDoc match those in the function declaration.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`param`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @param Foo\n */\nfunction quux (foo = 'FOO') {\n\n}\n\n/**\n * @arg Foo\n */\nfunction quux (foo = 'FOO') {\n\n}\n\n/**\n * @param Foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param Foo.Bar\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo\n * @param Foo.Bar\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo\n * @param foo.bar\n * @param bar\n */\nfunction quux (bar, foo) {\n\n}\n\n/**\n * @param foo\n * @param bar\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n *\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo\n * @param bar\n */\nfunction quux (foo, bar) {\n\n}\n\n/**\n * @param foo\n * @param bar\n */\nfunction quux (foo, bar, baz) {\n\n}\n\n/**\n * @param foo\n * @param foo.foo\n * @param bar\n */\nfunction quux (foo, bar) {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-check-tag-names\"><code>check-tag-names</code></h3>\n\nReports invalid block tag names.\n\nValid [JSDoc 3 Block Tags](http://usejsdoc.org/#block-tags) are:\n\n```\nabstract\naccess\nalias\naugments\nauthor\nborrows\ncallback\nclass\nclassdesc\nconstant\nconstructs\ncopyright\ndefault\ndeprecated\ndescription\nenum\nevent\nexample\nexports\nexternal\nfile\nfires\nfunction\nglobal\nignore\nimplements\ninheritdoc\ninner\ninstance\ninterface\nkind\nlends\nlicense\nlistens\nmember\nmemberof\nmixes\nmixin\nmodule\nname\nnamespace\noverride\nparam\nprivate\nproperty\nprotected\npublic\nreadonly\nrequires\nreturns\nsee\nsince\nstatic\nsummary\nthis\nthrows\ntodo\ntutorial\ntype\ntypedef\nvariation\nversion\n```\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|N/A|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @Param\n */\nfunction quux () {\n\n}\n\n/**\n * @foo\n */\nfunction quux () {\n\n}\n\n/**\n * @arg foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n * @param foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @arg foo\n */\nfunction quux (foo) {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-check-types\"><code>check-types</code></h3>\n\nReports invalid types.\n\nEnsures that case of native types is the same as in this list:\n\n```\nboolean\nnumber\nstring\nObject\nArray\nDate\nRegExp\n```\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`class`, `constant`, `enum`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @param {Number} foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @arg {Number} foo\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n * @param {number} foo\n * @param {Bar} bar\n * @param {*} baz\n */\nfunction quux (foo, bar, baz) {\n\n}\n\n/**\n * @arg {number} foo\n * @arg {Bar} bar\n * @arg {*} baz\n */\nfunction quux (foo, bar, baz) {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-newline-after-description\"><code>newline-after-description</code></h3>\n\nEnforces a consistent padding of the block description.\n\nThis rule takes one argument. If it is `\"always\"` then a problem is raised when there is a newline after the description. If it is `\"never\"` then a problem is raised when there is no newline after the description. The default value is `\"always\"`.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|N/A|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * Foo.\n *\n * Foo.\n * @foo\n */\nfunction quux () {\n\n}\n\n/**\n * Bar.\n *\n * Bar.\n *\n * @bar\n */\nfunction quux () {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n * Foo.\n */\nfunction quux () {\n\n}\n\n/**\n * Bar.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo.\n *\n * @foo\n */\nfunction quux () {\n\n}\n\n/**\n * Bar.\n * @bar\n */\nfunction quux () {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-require-description-complete-sentence\"><code>require-description-complete-sentence</code></h3>\n\nRequires that block description and tag description are written in complete sentences, i.e.,\n\n* Description must start with an uppercase alphabetical character.\n* Paragraph must start with an uppercase alphabetical character.\n* Sentences must end with a period.\n* Every line that starts with a lowercase character must be preceded by a line ending the sentence.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`param`, `returns`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * foo.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo.\n *\n * foo.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo\n */\nfunction quux () {\n\n}\n\n/**\n * Foo\n * Bar.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo.\n *\n * @param foo foo.\n */\nfunction quux (foo) {\n\n}\n\n/**\n * Foo.\n *\n * @returns foo.\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n * @param foo - Foo.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo.\n * Bar.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo.\n *\n * Bar.\n */\nfunction quux () {\n\n}\n\n/**\n * Foo\n * bar.\n */\nfunction quux () {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-require-param-description\"><code>require-param-description</code></h3>\n\nRequires that `@param` tag has `description` value.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`param`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @param foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @arg foo\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n *\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo Foo.\n */\nfunction quux (foo) {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-require-param\"><code>require-param</code></h3>\n\nRequires that all function parameters are documented.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`param`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n *\n */\nfunction quux (foo) {\n\n}\n\n/**\n *\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo\n */\nfunction quux (foo, bar) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n * @param foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @arg foo\n */\nfunction quux (foo) {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-require-param-description\"><code>require-param-description</code></h3>\n\nRequires that `@param` tag has `description` value.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`param`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @param foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @arg foo\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n *\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param foo Foo.\n */\nfunction quux (foo) {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-require-param-type\"><code>require-param-type</code></h3>\n\nRequires that `@param` tag has `type` value.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`param`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @param foo\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @arg foo\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n *\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @param {number} foo\n */\nfunction quux (foo) {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-require-returns-description\"><code>require-returns-description</code></h3>\n\nRequires that `@returns` tag has `description` value.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`returns`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @returns\n */\nfunction quux (foo) {\n\n}\n\n/**\n * @return\n */\nfunction quux (foo) {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n *\n */\nfunction quux () {\n\n}\n\n/**\n * @returns Foo.\n */\nfunction quux () {\n\n}\n```\n\n\n<h3 id=\"eslint-plugin-jsdoc-rules-require-returns-type\"><code>require-returns-type</code></h3>\n\nRequires that `@returns` tag has `type` value.\n\n|||\n|---|---|\n|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|\n|Tags|`returns`|\n\nThe following patterns are considered problems:\n\n```js\n/**\n * @returns\n */\nfunction quux () {\n\n}\n\n/**\n * @returns Foo.\n */\nfunction quux () {\n\n}\n\n/**\n * @return Foo.\n */\nfunction quux () {\n\n}\n```\n\nThe following patterns are not considered problems:\n\n```js\n/**\n * @returns {number}\n */\nfunction quux () {\n\n}\n```\n\n\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/gajus/eslint-plugin-jsdoc.git" }, "scripts": { "build": "npm run pragmatist build", "lint": "npm run pragmatist lint", "pragmatist": "node ./node_modules/.bin/pragmatist --browser", "readme": "node ./node_modules/.bin/gitdown ./.README/README.md --output-file ./README.md; npm run readme-add-assertions", "readme-add-assertions": "babel-node --presets es2015 ./bin/readme-assertions.js", "test": "npm run pragmatist test", "watch": "npm run pragmatist watch", "watch-build": "npm run pragmatist watch-build", "watch-lint": "npm run pragmatist watch-lint", "watch-test": "npm run pragmatist watch-test" }, "version": "2.2.1" }