Skip to content
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
28 changes: 13 additions & 15 deletions src/bin/generateRuleTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@ for (const [
ruleName,
rule,
] of Object.entries(index.rules)) {
if (rule.meta?.schema?.[0]) {
str += ` /** ${rule.meta.docs.description} */\n`;
str += ` "jsdoc/${ruleName}": `;
const ts = await compile({
items: rule.meta.schema,
type: 'array',
}, 'Test', {
bannerComment: '',
});
str += ` /** ${rule.meta.docs.description} */\n`;
str += ` "jsdoc/${ruleName}": `;
const ts = await compile({
items: rule.meta.schema ?? [],
type: 'array',
}, 'Test', {
bannerComment: '',
});

str += ts
.replace(/^export type Test = ?/v, '')
.replace(/^export interface Test /v, '')
.replaceAll('\n', '\n ').trimEnd().replace(/;$/v, '') +
';\n\n';
}
str += ts
.replace(/^export type Test = ?/v, '')
.replace(/^export interface Test /v, '')
.replaceAll('\n', '\n ').trimEnd().replace(/;$/v, '') +
';\n\n';
}

str = str.replace(/\n$/v, '') + '}\n';
Expand Down
36 changes: 36 additions & 0 deletions src/rules.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export interface Rules {
/** Checks that `@access` tags have a valid value. */
"jsdoc/check-access": [];

/** Reports invalid alignment of JSDoc block asterisks. */
"jsdoc/check-alignment":
| []
Expand Down Expand Up @@ -90,6 +93,9 @@ export interface Rules {
}
];

/** Reports against syntax not valid for the mode (e.g., Google Closure Compiler in non-Closure mode). */
"jsdoc/check-syntax": [];

/** Reports invalid block tag names. */
"jsdoc/check-tag-names":
| []
Expand All @@ -102,6 +108,9 @@ export interface Rules {
}
];

/** Checks that any `@template` names are actually used in the connected `@typedef` or type alias. */
"jsdoc/check-template-names": [];

/** Reports invalid types. */
"jsdoc/check-types":
| []
Expand Down Expand Up @@ -188,6 +197,9 @@ export interface Rules {
}
];

/** Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies` */
"jsdoc/imports-as-dependencies": [];

/** This rule reports doc comments that only restate their attached name. */
"jsdoc/informative-docs":
| []
Expand Down Expand Up @@ -300,6 +312,9 @@ export interface Rules {
}
];

/** Detects and removes extra lines of a blank block description */
"jsdoc/no-blank-block-descriptions": [];

/** Removes empty blocks with nothing but possibly line breaks */
"jsdoc/no-blank-blocks":
| []
Expand Down Expand Up @@ -542,6 +557,9 @@ export interface Rules {
}
];

/** Requires a type for @next tags */
"jsdoc/require-next-type": [];

/** Requires that all function parameters are documented. */
"jsdoc/require-param":
| []
Expand Down Expand Up @@ -621,6 +639,18 @@ export interface Rules {
}
];

/** Requires that all `@typedef` and `@namespace` tags have `@property` when their type is a plain `object`, `Object`, or `PlainObject`. */
"jsdoc/require-property": [];

/** Requires that each `@property` tag has a `description` value. */
"jsdoc/require-property-description": [];

/** Requires that all function `@property` tags have names. */
"jsdoc/require-property-name": [];

/** Requires that each `@property` tag has a `type` value. */
"jsdoc/require-property-type": [];

/** Requires that returns are documented. */
"jsdoc/require-returns":
| []
Expand Down Expand Up @@ -718,6 +748,9 @@ export interface Rules {
}
];

/** Requires a type for @throws tags */
"jsdoc/require-throws-type": [];

/** Requires yields are documented. */
"jsdoc/require-yields":
| []
Expand Down Expand Up @@ -757,6 +790,9 @@ export interface Rules {
}
];

/** Requires a type for @yields tags */
"jsdoc/require-yields-type": [];

/** Sorts tags by a specified sequence according to tag name. */
"jsdoc/sort-tags":
| []
Expand Down
44 changes: 22 additions & 22 deletions src/rules/checkTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,28 @@ const getMessage = (upperCase) => {
'`' + (upperCase ? 'O' : 'o') + 'bject`, e.g., `{[key: string]: string}`';
};

/**
* @type {{
* message: string,
* replacement: false
* }}
*/
const info = {
message: getMessage(),
replacement: false,
};

/**
* @type {{
* message: string,
* replacement: false
* }}
*/
const infoUC = {
message: getMessage(true),
replacement: false,
};

export default iterateJsdoc(({
context,
jsdocNode,
Expand Down Expand Up @@ -120,28 +142,6 @@ export default iterateJsdoc(({
'Object.<>' in preferredTypesOriginal ||
'object<>' in preferredTypesOriginal);

/**
* @type {{
* message: string,
* replacement: false
* }}
*/
const info = {
message: getMessage(),
replacement: false,
};

/**
* @type {{
* message: string,
* replacement: false
* }}
*/
const infoUC = {
message: getMessage(true),
replacement: false,
};

/** @type {import('../iterateJsdoc.js').PreferredTypes} */
const typeToInject = mode === 'typescript' ?
{
Expand Down
Loading