Skip to content

Commit f72ac1a

Browse files
committed
fix(no-undefined-types): avoid param and property tags from being treated as type-defining
Also: - chore: update devDeps.
1 parent c3cc145 commit f72ac1a

File tree

8 files changed

+82
-55
lines changed

8 files changed

+82
-55
lines changed

docs/rules/no-undefined-types.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,5 +1047,24 @@ function a (b, c) {}
10471047

10481048
/** @type {SomeType} */
10491049
// "jsdoc/no-undefined-types": ["error"|"warn", {"checkUsedTypedefs":true}]
1050+
1051+
/** @typedef {string} MyOwnType */
1052+
1053+
/**
1054+
* @template T
1055+
* @param {<T extends unknown>(element: MyOwnType) => T} cb
1056+
* @returns {void}
1057+
*/
1058+
const getValue = () => {};
1059+
1060+
/** @typedef {string} MyOwnType */
1061+
/** @typedef {new () => void} CustomElementConstructor */
1062+
1063+
/**
1064+
* @param {`${MyOwnType}-${string}`} tagName
1065+
* @param {CustomElementConstructor} component
1066+
*/
1067+
const defineCustomElement = (tagName, component) => {
1068+
};
10501069
````
10511070

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"@babel/plugin-syntax-class-properties": "^7.12.13",
2828
"@babel/plugin-transform-flow-strip-types": "^7.27.1",
2929
"@babel/preset-env": "^7.28.3",
30-
"@es-joy/escodegen": "^3.5.1",
31-
"@es-joy/jsdoc-eslint-parser": "^0.23.0",
30+
"@es-joy/escodegen": "^4.0.3",
31+
"@es-joy/jsdoc-eslint-parser": "^0.24.0",
3232
"@eslint/core": "^0.16.0",
3333
"@hkdobrev/run-if-changed": "^0.6.3",
3434
"@semantic-release/commit-analyzer": "^13.0.1",
@@ -50,15 +50,15 @@
5050
"babel-plugin-transform-import-meta": "^2.3.3",
5151
"c8": "^10.1.3",
5252
"camelcase": "^8.0.0",
53-
"chai": "^6.0.1",
53+
"chai": "^6.2.0",
5454
"decamelize": "^6.0.1",
5555
"eslint": "9.36.0",
5656
"eslint-config-canonical": "^45.0.0",
5757
"gitdown": "^4.1.1",
5858
"glob": "^11.0.3",
5959
"globals": "^16.4.0",
6060
"husky": "^9.1.7",
61-
"jsdoc-type-pratt-parser": "^5.9.1",
61+
"jsdoc-type-pratt-parser": "^5.9.2",
6262
"json-schema": "^0.4.0",
6363
"json-schema-to-typescript": "^15.0.4",
6464
"lint-staged": "^16.2.1",

pnpm-lock.yaml

Lines changed: 27 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index-esm.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
export default index;
1717
// END REPLACE
1818

19-
/* eslint-disable jsdoc/valid-types -- Bug */
2019
/**
2120
* @type {((
2221
* cfg?: import('eslint').Linter.Config & {
@@ -54,7 +53,6 @@ export default index;
5453
* ) => import('eslint').Linter.Config)}
5554
*/
5655
export const jsdoc = function (cfg) {
57-
/* eslint-enable jsdoc/valid-types -- Bug */
5856
/** @type {import('eslint').Linter.Config} */
5957
let outputConfig = {
6058
plugins: {

src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ index.configs['flat/recommended-mixed'] = [
706706

707707
export default index;
708708

709-
/* eslint-disable jsdoc/valid-types -- Bug */
710709
/**
711710
* @type {((
712711
* cfg?: import('eslint').Linter.Config & {
@@ -744,7 +743,6 @@ export default index;
744743
* ) => import('eslint').Linter.Config)}
745744
*/
746745
export const jsdoc = function (cfg) {
747-
/* eslint-enable jsdoc/valid-types -- Bug */
748746
/** @type {import('eslint').Linter.Config} */
749747
let outputConfig = {
750748
plugins: {

src/rules/noUndefinedTypes.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ export default iterateJsdoc(({
139139
return doc.tags.filter(({
140140
tag,
141141
}) => {
142-
return utils.isNamepathDefiningTag(tag);
142+
return utils.isNamepathDefiningTag(tag) && ![
143+
'arg',
144+
'argument',
145+
'param',
146+
'prop',
147+
'property',
148+
].includes(tag);
143149
});
144150
});
145151

test/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ describe('jsdoc()', () => {
8282
});
8383

8484
it('Builds simple plugins config with rules', () => {
85-
/* eslint-disable jsdoc/valid-types -- Bug */
8685
const rules = /** @type {{[key in keyof import('../src/rules.d.ts').Rules]?: import('eslint').Linter.RuleEntry<import('../src/rules.d.ts').Rules[key]>}} */ ({
87-
/* eslint-enable jsdoc/valid-types -- Bug */
8886
'jsdoc/check-alignment': [
8987
'error',
9088
{

test/rules/assertions/noUndefinedTypes.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,5 +1801,30 @@ export default /** @type {import('../index.js').TestCases} */ ({
18011801
},
18021802
],
18031803
},
1804+
{
1805+
code: `
1806+
/** @typedef {string} MyOwnType */
1807+
1808+
/**
1809+
* @template T
1810+
* @param {<T extends unknown>(element: MyOwnType) => T} cb
1811+
* @returns {void}
1812+
*/
1813+
const getValue = () => {};
1814+
`,
1815+
},
1816+
{
1817+
code: `
1818+
/** @typedef {string} MyOwnType */
1819+
/** @typedef {new () => void} CustomElementConstructor */
1820+
1821+
/**
1822+
* @param {\`\${MyOwnType}-\${string}\`} tagName
1823+
* @param {CustomElementConstructor} component
1824+
*/
1825+
const defineCustomElement = (tagName, component) => {
1826+
};
1827+
`,
1828+
},
18041829
],
18051830
});

0 commit comments

Comments
 (0)