• Stars
    star
    1,024
  • Rank 44,961 (Top 0.9 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JSDoc specific linting rules for ESLint.

eslint-plugin-jsdoc

NPM version Travis build status js-canonical-style Discord Chat

JSDoc linting rules for ESLint.

Installation

Install ESLint either locally or globally.

npm install --save-dev eslint

If you have installed ESLint globally, you have to install JSDoc plugin globally too. Otherwise, install it locally.

npm install --save-dev eslint-plugin-jsdoc

Configuration

Flat config

import jsdoc from 'eslint-plugin-jsdoc';

const config = [
  // configuration included in plugin
  jsdoc.configs['flat/recommended'],
  // other configuration objects...
  {
    files: ['**/*.js'],
    plugins: {
      jsdoc,
    },
    rules: {
      'jsdoc/require-description': 'warn'
    }
  }
];

export default config;

eslintrc

Add plugins section to .eslintrc.* and specify eslint-plugin-jsdoc as a plugin.

{
    "plugins": [
        "jsdoc"
    ]
}

Finally, enable all of the rules that you would like to use.

{
    "rules": {
        "jsdoc/check-access": 1, // Recommended
        "jsdoc/check-alignment": 1, // Recommended
        "jsdoc/check-examples": 1,
        "jsdoc/check-indentation": 1,
        "jsdoc/check-line-alignment": 1,
        "jsdoc/check-param-names": 1, // Recommended
        "jsdoc/check-property-names": 1, // Recommended
        "jsdoc/check-syntax": 1,
        "jsdoc/check-tag-names": 1, // Recommended
        "jsdoc/check-types": 1, // Recommended
        "jsdoc/check-values": 1, // Recommended
        "jsdoc/empty-tags": 1, // Recommended
        "jsdoc/implements-on-classes": 1, // Recommended
        "jsdoc/informative-docs": 1,
        "jsdoc/match-description": 1,
        "jsdoc/multiline-blocks": 1, // Recommended
        "jsdoc/no-bad-blocks": 1,
        "jsdoc/no-blank-block-descriptions": 1,
        "jsdoc/no-defaults": 1,
        "jsdoc/no-missing-syntax": 1,
        "jsdoc/no-multi-asterisks": 1, // Recommended
        "jsdoc/no-restricted-syntax": 1,
        "jsdoc/no-types": 1,
        "jsdoc/no-undefined-types": 1, // Recommended
        "jsdoc/require-asterisk-prefix": 1,
        "jsdoc/require-description": 1,
        "jsdoc/require-description-complete-sentence": 1,
        "jsdoc/require-example": 1,
        "jsdoc/require-file-overview": 1,
        "jsdoc/require-hyphen-before-param-description": 1,
        "jsdoc/require-jsdoc": 1, // Recommended
        "jsdoc/require-param": 1, // Recommended
        "jsdoc/require-param-description": 1, // Recommended
        "jsdoc/require-param-name": 1, // Recommended
        "jsdoc/require-param-type": 1, // Recommended
        "jsdoc/require-property": 1, // Recommended
        "jsdoc/require-property-description": 1, // Recommended
        "jsdoc/require-property-name": 1, // Recommended
        "jsdoc/require-property-type": 1, // Recommended
        "jsdoc/require-returns": 1, // Recommended
        "jsdoc/require-returns-check": 1, // Recommended
        "jsdoc/require-returns-description": 1, // Recommended
        "jsdoc/require-returns-type": 1, // Recommended
        "jsdoc/require-throws": 1,
        "jsdoc/require-yields": 1, // Recommended
        "jsdoc/require-yields-check": 1, // Recommended
        "jsdoc/sort-tags": 1,
        "jsdoc/tag-lines": 1, // Recommended
        "jsdoc/valid-types": 1 // Recommended
    }
}

Or you can simply add the following to .eslintrc.*, which enables the rules commented above as "recommended":

{
  "extends": ["plugin:jsdoc/recommended"]
}

You can then selectively add to or override the recommended rules.

Alternatively, if you wish to have all linting issues reported as failing errors, you may use the "recommended-error" config:

{
  "extends": ["plugin:jsdoc/recommended-error"]
}

If you plan to use TypeScript syntax (and not just "typescript" mode to indicate the JSDoc flavor is TypeScript), you can use:

{
  "extends": ["plugin:jsdoc/recommended-typescript"]
}

...or to report with failing errors instead of mere warnings:

{
  "extends": ["plugin:jsdoc/recommended-typescript-error"]
}

If you are not using TypeScript syntax (your source files are still .js files) but you are using the TypeScript flavor within JSDoc (i.e., the default "typescript" mode in eslint-plugin-jsdoc) and you are perhaps using allowJs and checkJs options of TypeScript's tsconfig.json), you may use:

{
  "extends": ["plugin:jsdoc/recommended-typescript-flavor"]
}

...or to report with failing errors instead of mere warnings:

{
  "extends": ["plugin:jsdoc/recommended-typescript-flavor-error"]
}

Options

Rules may, as per the ESLint user guide, have their own individual options. In eslint-plugin-jsdoc, a few options, such as, exemptedBy and contexts, may be used across different rules.

eslint-plugin-jsdoc options, if present, are generally in the form of an object supplied as the second argument in an array after the error level (any exceptions to this format are explained within that rule's docs).

// `.eslintrc.js`
{
  rules: {
    'jsdoc/require-example': [
        // The Error level should be `error`, `warn`, or `off` (or 2, 1, or 0)
        'error',
        // The options vary by rule, but are generally added to an options
        //  object as follows:
        {
          checkConstructors: true,
          exemptedBy: ['type']
        }
    ]
  }
}

Settings

See Settings.

Advanced

See Advanced.

Rules

Problems reported by rules which have a wrench πŸ”§ below can be fixed automatically by running ESLint on the command line with --fix option.

Note that a number of fixable rules have an enableFixer option which can be set to false to disable the fixer (or in the case of check-param-names, check-property-names, and no-blank-blocks, set to true to enable a non-default-recommended fixer).

recommended fixable rule description
βœ”οΈ check-access Enforces valid @access tags
βœ”οΈ πŸ”§ check-alignment Enforces alignment of JSDoc block asterisks
check-examples Linting of JavaScript within @example
check-indentation Checks for invalid padding inside JSDoc blocks
πŸ”§ check-line-alignment Reports invalid alignment of JSDoc block lines.
βœ”οΈ πŸ”§ check-param-names Checks for dupe @param names, that nested param names have roots, and that parameter names in function declarations match jsdoc param names.
βœ”οΈ πŸ”§ check-property-names Checks for dupe @property names, that nested property names have roots
check-syntax Reports use against current mode (currently only prohibits Closure-specific syntax)
βœ”οΈ πŸ”§ check-tag-names Reports invalid jsdoc (block) tag names
βœ”οΈ πŸ”§ check-types Reports types deemed invalid (customizable and with defaults, for preventing and/or recommending replacements)
βœ”οΈ check-values Checks for expected content within some miscellaneous tags (@version, @since, @license, @author)
βœ”οΈ πŸ”§ empty-tags Checks tags that are expected to be empty (e.g., @abstract or @async), reporting if they have content
βœ”οΈ implements-on-classes Prohibits use of @implements on non-constructor functions (to enforce the tag only being used on classes/constructors)
informative-docs Reports on JSDoc texts that serve only to restart their attached name.
match-description Defines customizable regular expression rules for your tag descriptions
πŸ”§ match-name Reports the name portion of a JSDoc tag if matching or not matching a given regular expression
βœ”οΈ πŸ”§ multiline-blocks Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks
πŸ”§ no-bad-blocks This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block
πŸ”§ no-blank-block-descriptions If tags are present, this rule will prevent empty lines in the block description. If no tags are present, this rule will prevent extra empty lines in the block description.
πŸ”§ no-blank-blocks Reports and optionally removes blocks with whitespace only
βœ”οΈ πŸ”§ no-defaults This rule reports defaults being used on the relevant portion of @param or @default
no-missing-syntax This rule lets you report if certain always expected comment structures are missing.
βœ”οΈ πŸ”§ no-multi-asterisks Prevents use of multiple asterisks at the beginning of lines
no-restricted-syntax Reports when certain comment structures are present
On in TS πŸ”§ no-types Prohibits types on @param or @returns (redundant with TypeScript)
βœ”οΈ (off in TS and TS flavor) no-undefined-types Besides some expected built-in types, prohibits any types not specified as globals or within @typedef
πŸ”§ require-asterisk-prefix Requires that each JSDoc line starts with an *
require-description Requires that all functions (and potentially other contexts) have a description.
πŸ”§ require-description-complete-sentence Requires that block description, explicit @description, and @param/@returns tag descriptions are written in complete sentences
πŸ”§ require-example Requires that all functions (and potentially other contexts) have examples.
require-file-overview By default, requires a single @file tag at the beginning of each linted file
πŸ”§ require-hyphen-before-param-description Requires a hyphen before @param descriptions (and optionally before @property descriptions)
βœ”οΈ πŸ”§ require-jsdoc Checks for presence of jsdoc comments, on functions and potentially other contexts (optionally limited to exports).
βœ”οΈ πŸ”§ require-param Requires that all function parameters are documented with a @param tag.
βœ”οΈ require-param-description Requires that each @param tag has a description value.
βœ”οΈ require-param-name Requires that all @param tags have names.
βœ”οΈ (off in TS) require-param-type Requires that each @param tag has a type value (within curly brackets).
βœ”οΈ πŸ”§ require-property Requires that all @typedef and @namespace tags have @property tags when their type is a plain object, Object, or PlainObject.
βœ”οΈ require-property-description Requires that each @property tag has a description value.
βœ”οΈ require-property-name Requires that all @property tags have names.
βœ”οΈ (off in TS) require-property-type Requires that each @property tag has a type value (within curly brackets).
βœ”οΈ require-returns Requires that return statements are documented.
βœ”οΈ require-returns-check Requires a return statement be present in a function body if a @returns tag is specified in the jsdoc comment block (and reports if multiple @returns tags are present).
βœ”οΈ require-returns-description Requires that the @returns tag has a description value (not including void/undefined type returns).
βœ”οΈ (off in TS) require-returns-type Requires that @returns tag has a type value (in curly brackets).
require-throws Requires that throw statements are documented
βœ”οΈ require-yields Requires that yields are documented
βœ”οΈ require-yields-check Ensures that if a @yields is present that a yield (or yield with a value) is present in the function body (or that if a @next is present that there is a yield with a return value present)
sort-tags Sorts tags by a specified sequence according to tag name, optionally adding line breaks between tag groups
βœ”οΈ πŸ”§ tag-lines Enforces lines (or no lines) between tags
πŸ”§ text-escaping This rule can auto-escape certain characters that are input within block and tag descriptions
βœ”οΈ valid-types Requires all types/namepaths to be valid JSDoc, Closure compiler, or TypeScript types (configurable in settings)

More Repositories

1

react-css-modules

Seamless mapping of class names to CSS modules inside of React components.
JavaScript
5,232
star
2

slonik

A Node.js PostgreSQL client with runtime and build time type safety, and composable SQL.
TypeScript
4,550
star
3

swing

A swipeable cards interface. The swipe-left/swipe-right for yes/no input. As seen in apps like Jelly and Tinder.
JavaScript
2,618
star
4

babel-plugin-react-css-modules

Transforms styleName to className using compile time CSS module resolution.
JavaScript
2,044
star
5

redux-immutable

redux-immutable is used to create an equivalent function of Redux combineReducers that works with Immutable.js state.
TypeScript
1,880
star
6

eslint-plugin-flowtype

Flow type linting rules for ESLint.
JavaScript
1,078
star
7

roarr

JSON logger for Node.js and browser.
TypeScript
1,062
star
8

prepack-webpack-plugin

A webpack plugin for prepack.
JavaScript
1,039
star
9

turbowatch

Extremely fast file change detector and task orchestrator for Node.js.
TypeScript
938
star
10

table

Formats data into a string table.
TypeScript
897
star
11

usus

Webpage pre-rendering service. ⚑️
JavaScript
805
star
12

flow-runtime

A runtime type system for JavaScript with full Flow compatibility.
JavaScript
802
star
13

surgeon

Declarative DOM extraction expression evaluator. πŸ‘¨β€βš•οΈ
JavaScript
693
star
14

liqe

Lightweight and performant Lucene-like parser, serializer and search engine.
TypeScript
636
star
15

eslint-config-canonical

The most comprehensive ES code style guide.
JavaScript
536
star
16

write-file-webpack-plugin

Forces webpack-dev-server to write bundle files to the file system.
JavaScript
528
star
17

lightship

Abstracts readiness, liveness and startup checks and graceful shutdown of Node.js services running in Kubernetes.
TypeScript
518
star
18

gitdown

GitHub markdown preprocessor.
JavaScript
445
star
19

xhprof.io

GUI to analyze the profiling data collected using XHProf – A Hierarchical Profiler for PHP.
PHP
429
star
20

contents

Table of contents generator.
JavaScript
416
star
21

brim

View (minimal-ui) manager for iOS 8.
JavaScript
391
star
22

global-agent

Global HTTP/HTTPS proxy agent configurable using environment variables.
TypeScript
360
star
23

youtube-player

YouTube iframe API abstraction.
JavaScript
340
star
24

react-aux

A self-eradicating component for rendering multiple elements.
JavaScript
329
star
25

http-terminator

Gracefully terminates HTTP(S) server.
TypeScript
324
star
26

isomorphic-webpack

Abstracts universal consumption of application code base using webpack.
JavaScript
291
star
27

scream

Dynamic viewport management for mobile. Manage viewport in different states of device orientation. Scale document to fit viewport. Calculate the dimensions of the "minimal" iOS 8 view relative to your viewport width.
JavaScript
289
star
28

graphql-deduplicator

A GraphQL response deduplicator. Removes duplicate entities from the GraphQL response.
JavaScript
279
star
29

create-index

Creates ES6 ./index.js file in target directories that imports and exports all sibling files and directories.
JavaScript
279
star
30

gajus.com-blog

The contents of the http://gajus.com/blog/.
JavaScript
226
star
31

wholly

jQuery plugin used to select the entire table row and column in response to mouseenter and mouseleave events. Wholly supports table layouts that utilize colspan and rowspan.
JavaScript
204
star
32

puppeteer-proxy

Proxies Puppeteer Page requests.
JavaScript
203
star
33

canonical-reducer-composition

Spec for Canonical Reducer Composition design pattern.
188
star
34

angular-swing

AngularJS directive for Swing: A swipeable cards interface. The swipe-left/swipe-right for yes/no input. As seen in apps like Jelly and Tinder, and many others.
JavaScript
183
star
35

dindent

HTML indentation library for development and testing.
PHP
177
star
36

babel-plugin-graphql-tag

Compiles GraphQL tagged template strings using graphql-tag.
JavaScript
172
star
37

eslint-plugin-canonical

ESLint rules for Canonical ruleset.
TypeScript
121
star
38

vlad

Input validation library promoting succinct syntax with extendable validators and multilingual support.
PHP
104
star
39

babel-plugin-log-deprecated

Adds a console.warn statement to the functions annotated with @deprecated tag.
JavaScript
103
star
40

redux-immutable-examples

A complete application showing use of redux-immutable.
JavaScript
103
star
41

babel-preset-es2015-webpack

Babel preset for all es2015 plugins except babel-plugin-transform-es2015-modules-commonjs.
JavaScript
97
star
42

scalpel

A CSS selector parser.
JavaScript
95
star
43

eslint-plugin-sql

SQL linting rules for ESLint.
TypeScript
93
star
44

graphql-lazyloader

GraphQL directive that adds Object-level data resolvers.
TypeScript
89
star
45

pg-formatter

A PostgreSQL SQL syntax beautifier.
TypeScript
80
star
46

orientationchangeend

The orientationchangeend event is fired when the orientation of the device has changed and the associated rotation animation has been complete.
JavaScript
78
star
47

bugger

Bugger is a collection of functions for debugging PHP code.
CSS
77
star
48

planton

Database-agnostic task scheduler.
TypeScript
77
star
49

dora

Input generation library for value resolution, data persistence, templates, CSRF and protection from XSS.
CSS
73
star
50

react-css-modules-examples

Usage examples for react-css-modules.
JavaScript
72
star
51

format-graphql

Formats GraphQL schema definition language (SDL) document.
JavaScript
71
star
52

to-string-loader

to-string loader for webpack
JavaScript
64
star
53

extract-email-address

Extracts email address from an arbitrary text input.
TypeScript
62
star
54

interdependent-interactive-histograms

This is a helper function that utilises d3.js and Crossfilter to create interdependent interactive histograms.
JavaScript
60
star
55

babel-plugin-transform-function-composition

Syntactic sugar 🍧🍨🍦 for easy to read function composition. πŸ¦„
JavaScript
58
star
56

preoom

Retrieves & observes Kubernetes Pod resource (CPU, memory) utilisation.
JavaScript
55
star
57

fuss

The Facebook SDK for PHP provides an interface to the Graph API.
PHP
53
star
58

postloader

A scaffolding tool for projects using DataLoader, Flow and PostgreSQL.
JavaScript
51
star
59

moa

MOA implements dynamically generated Active Record database abstraction.
PHP
50
star
60

extract-date

Extracts date from an arbitrary text input.
JavaScript
49
star
61

gitinfo

Gets information about a Git repository.
JavaScript
47
star
62

sister

Foundation for your emitter implementation. 202 reasons to not write your own implementation of event emitter.
JavaScript
45
star
63

react-outside-event

A higher order React component that attaches an event listener for events that occur outside of the component element.
JavaScript
44
star
64

babel-plugin-annotate-console-log

Annotates console.log call expression with information about the invocation context.
JavaScript
42
star
65

react-youtube-player

React component that encapsulates YouTube IFrame Player API and exposes player controls using the component properties.
JavaScript
40
star
66

bundle-dependencies

Generates bundledDependencies package.json value using values of the dependencies property. Updates package.json definition using the generated bundledDependencies value.
JavaScript
39
star
67

facebook-friend-rank

PHP class that can calculate who are the best user's friends. Data accuracy depends on the user activity and granted permissions.
PHP
39
star
68

waitehr

Waits for HTTP response and retries request until the expected response is received.
TypeScript
37
star
69

doll

Extended PDO with inline type hinting, deferred connection support, logging and benchmarking.
PHP
36
star
70

pie-chart

This is a helper function that utilises d3.js to create pie charts.
JavaScript
36
star
71

sguid

Signed Globally Unique Identifier (SGUID) generator.
JavaScript
34
star
72

slonik-utilities

Utilities for manipulating data in PostgreSQL database using Slonik.
TypeScript
32
star
73

prepack-loader

A webpack loader for prepack.
JavaScript
31
star
74

seeql

Real-time SQL profiler.
JavaScript
30
star
75

react-strict-prop-types

A higher order component that raises an error if component is used with an unknown property.
JavaScript
29
star
76

postgres-bridge

postgres/pg compatibility layer
TypeScript
29
star
77

crack-json

Extracts all JSON objects from an arbitrary text document.
JavaScript
29
star
78

roarr-cli

A CLI program for processing Roarr logs.
TypeScript
28
star
79

paggern

Pattern interpreter for generating random strings.
PHP
28
star
80

roarr-browser-log-writer

Roarr log writer for use in a web browser.
TypeScript
27
star
81

cluster-map

Abstracts execution of tasks in parallel using Node.js cluster.
JavaScript
27
star
82

database-types

A generic type generator for various databases.
JavaScript
26
star
83

iapetus

Prometheus metrics server.
TypeScript
25
star
84

require-new

Requires a new module object.
JavaScript
23
star
85

tmdb

The Movie Database (TMDb) SDK.
JavaScript
23
star
86

pan

Touch enabled implementation of WHATWG drag and drop mechanism.
JavaScript
23
star
87

eslint-plugin-zod

Zod linting rules for ESLint.
TypeScript
21
star
88

pragmatist

A collection of tasks to standardize builds.
JavaScript
21
star
89

pianola

A declarative function composition and evaluation engine.
JavaScript
20
star
90

approximate-now

Approximate (fast) current UNIX time.
TypeScript
20
star
91

babel-plugin-transform-export-default-name

Babel plugin that transforms default exports to named exports.
JavaScript
20
star
92

xfetch

A light-weight HTTP client for Node.js.
JavaScript
19
star
93

extract-time

Extracts time from an arbitrary text input.
JavaScript
19
star
94

override-require

Overrides Node.js module resolution logic.
JavaScript
18
star
95

fastify-webpack-hot

A Fastify plugin for serving files emitted by Webpack with Hot Module Replacement (HMR).
TypeScript
18
star
96

canonical

Canonical code style linter and formatter for JavaScript, SCSS, CSS and JSON.
JavaScript
18
star
97

babel-plugin-lodash-modularize

Babel plugin that replaces lodash library import statement to individual module imports.
JavaScript
18
star
98

semantic-url-parser

Extracts content information from known URL patterns.
TypeScript
17
star
99

extract-price

Extracts prices from an arbitrary text input.
JavaScript
17
star
100

express-tus

Express middleware for tus protocol.
JavaScript
16
star