Skip to content

Commit

Permalink
fix(valid-types): parse name paths as permissive.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock authored and brettz9 committed Jun 19, 2021
1 parent 88cc18c commit 657c67c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/rules/validTypes.js
Expand Up @@ -17,13 +17,9 @@ export default iterateJsdoc(({
} = context.options[0] || {};
const {mode} = settings;

const tryParseIgnoreError = (path) => {
const tryParsePathIgnoreError = (path) => {
try {
if (mode === 'permissive') {
tryParse(path);
} else {
parse(path, mode);
}
tryParse(path);

return true;
} catch {
Expand All @@ -36,7 +32,7 @@ export default iterateJsdoc(({
// eslint-disable-next-line complexity
jsdoc.tags.forEach((tag) => {
const validNamepathParsing = function (namepath, tagName) {
if (tryParseIgnoreError(namepath)) {
if (tryParsePathIgnoreError(namepath)) {
return true;
}
let handled = false;
Expand All @@ -45,21 +41,21 @@ export default iterateJsdoc(({
switch (tagName) {
case 'module': {
if (!namepath.startsWith('module:')) {
handled = tryParseIgnoreError(`module:${namepath}`);
handled = tryParsePathIgnoreError(`module:${namepath}`);
}
break;
}
case 'memberof': case 'memberof!': {
const endChar = namepath.slice(-1);
if (['#', '.', '~'].includes(endChar)) {
handled = tryParseIgnoreError(namepath.slice(0, -1));
handled = tryParsePathIgnoreError(namepath.slice(0, -1));
}
break;
}
case 'borrows': {
const startChar = namepath.charAt();
if (['#', '.', '~'].includes(startChar)) {
handled = tryParseIgnoreError(namepath.slice(1));
handled = tryParsePathIgnoreError(namepath.slice(1));
}
}
}
Expand Down

0 comments on commit 657c67c

Please sign in to comment.