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

tools: add JSDoc ESLint plugin #38288

Closed
wants to merge 3 commits into from
Closed
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
17 changes: 16 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ModuleFindPath = Module._findPath;
const hacks = [
'eslint-plugin-node-core',
'eslint-plugin-markdown',
'eslint-plugin-jsdoc',
'@babel/eslint-parser',
'@babel/plugin-syntax-class-properties',
'@babel/plugin-syntax-top-level-await',
Expand All @@ -38,7 +39,7 @@ Module._findPath = (request, paths, isMain) => {

module.exports = {
root: true,
plugins: ['markdown', 'node-core'],
plugins: ['markdown', 'node-core', 'jsdoc'],
parser: '@babel/eslint-parser',
parserOptions: {
babelOptions: {
Expand All @@ -50,6 +51,16 @@ module.exports = {
requireConfigFile: false,
sourceType: 'script',
},
settings: {
jsdoc: {
// For the @template tag.
mode: 'typescript',
tagNamePreference: {
class: 'constructor',
file: 'fileoverview',
},
},
},
overrides: [
{
files: [
Expand Down Expand Up @@ -313,6 +324,10 @@ module.exports = {
// Custom rules from eslint-plugin-node-core
'node-core/no-unescaped-regexp-dot': 'error',
'node-core/no-duplicate-requires': 'error',

// JSDoc rules
// https://github.com/gajus/eslint-plugin-jsdoc
'jsdoc/check-tag-names': 'error',
},
globals: {
AbortController: 'readable',
Expand Down
2 changes: 1 addition & 1 deletion benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function getUrlData(withBase) {
* @param {number} e The repetition of the data, as exponent of 2
* @param {boolean} withBase Whether to include a base URL
* @param {boolean} asUrl Whether to return the results as URL objects
* @return {string[] | string[][] | URL[]}
* @returns {string[] | string[][] | URL[]}
*/
function bakeUrlData(type, e = 0, withBase = false, asUrl = false) {
let result = [];
Expand Down
18 changes: 9 additions & 9 deletions lib/internal/source_map/source_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,21 @@ class StringCharIterator {
}

/**
* @return {string}
* @returns {string}
*/
next() {
return StringPrototypeCharAt(this._string, this._position++);
}

/**
* @return {string}
* @returns {string}
*/
peek() {
return StringPrototypeCharAt(this._string, this._position);
}

/**
* @return {boolean}
* @returns {boolean}
*/
hasNext() {
return this._position < this._string.length;
Expand Down Expand Up @@ -148,7 +148,7 @@ class SourceMap {
}

/**
* @return {Object} raw source map v3 payload.
* @returns {Object} raw source map v3 payload.
*/
get payload() {
return cloneSourceMapV3(this.#payload);
Expand Down Expand Up @@ -179,7 +179,7 @@ class SourceMap {
/**
* @param {number} lineNumber in compiled resource
* @param {number} columnNumber in compiled resource
* @return {?Array}
* @returns {?Array}
*/
findEntry(lineNumber, columnNumber) {
let first = 0;
Expand Down Expand Up @@ -280,15 +280,15 @@ class SourceMap {

/**
* @param {string} char
* @return {boolean}
* @returns {boolean}
*/
function isSeparator(char) {
return char === ',' || char === ';';
}

/**
* @param {SourceMap.StringCharIterator} stringCharIterator
* @return {number}
* @returns {number}
*/
function decodeVLQ(stringCharIterator) {
// Read unsigned value.
Expand Down Expand Up @@ -320,7 +320,7 @@ function decodeVLQ(stringCharIterator) {

/**
* @param {SourceMapV3} payload
* @return {SourceMapV3}
* @returns {SourceMapV3}
*/
function cloneSourceMapV3(payload) {
if (typeof payload !== 'object') {
Expand All @@ -340,7 +340,7 @@ function cloneSourceMapV3(payload) {
* @param {Array} entry1 source map entry [lineNumber, columnNumber, sourceURL,
* sourceLineNumber, sourceColumnNumber]
* @param {Array} entry2 source map entry.
* @return {number}
* @returns {number}
*/
function compareSourceMapEntry(entry1, entry2) {
const { 0: lineNumber1, 1: columnNumber1 } = entry1;
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint-rules/non-ascii-character.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @fileOverview Any non-ASCII characters in lib/ will increase the size
* @fileoverview Any non-ASCII characters in lib/ will increase the size
* of the compiled node binary. This linter rule ensures that
* any such character is reported.
* @author Sarat Addepalli <sarat.addepalli@gmail.com>
Expand Down
21 changes: 0 additions & 21 deletions tools/node_modules/eslint-plugin-markdown/LICENSE

This file was deleted.

Loading