Skip to content

Commit

Permalink
Prettier trailing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Knights committed Sep 7, 2024
1 parent 35c0bef commit c51ebc3
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const addInherited = require('jsdoc/augment').addInherited; // eslint-disable-li
const config = env.conf.typescript;
if (!config) {
throw new Error(
'Configuration "typescript" for jsdoc-plugin-typescript missing.'
'Configuration "typescript" for jsdoc-plugin-typescript missing.',
);
}
if (!('moduleRoot' in config)) {
throw new Error(
'Configuration "typescript.moduleRoot" for jsdoc-plugin-typescript missing.'
'Configuration "typescript.moduleRoot" for jsdoc-plugin-typescript missing.',
);
}
const moduleRoot = config.moduleRoot;
Expand All @@ -21,7 +21,7 @@ if (!fs.existsSync(moduleRootAbsolute)) {
throw new Error(
'Directory "' +
moduleRootAbsolute +
'" does not exist. Check the "typescript.moduleRoot" config option for jsdoc-plugin-typescript'
'" does not exist. Check the "typescript.moduleRoot" config option for jsdoc-plugin-typescript',
);
}

Expand All @@ -47,7 +47,7 @@ function getModuleInfo(moduleId, extension, parser) {
const absolutePath = path.join(
process.cwd(),
moduleRoot,
moduleId + extension
moduleId + extension,
);
if (!fs.existsSync(absolutePath)) {
return null;
Expand Down Expand Up @@ -186,7 +186,7 @@ exports.defineTags = function (dictionary) {
// Bracket notation to dot notation
.replace(
/(\w+|>|\)|\])\[(?:'([^']+)'|"([^"]+)")\]/g,
'$1.$2$3'
'$1.$2$3',
);

return head + replaced + tail;
Expand Down Expand Up @@ -293,10 +293,10 @@ exports.astNodeVisitor = {
if (
leadingComments.length === 0 ||
(leadingComments[leadingComments.length - 1].value.indexOf(
'@classdesc'
'@classdesc',
) === -1 &&
noClassdescRegEx.test(
leadingComments[leadingComments.length - 1].value
leadingComments[leadingComments.length - 1].value,
))
) {
// Create a suitable comment node if we don't have one on the class yet
Expand All @@ -314,7 +314,7 @@ exports.astNodeVisitor = {
if (node.superClass) {
// Remove the `@extends` tag because JSDoc does not does not handle generic type. (`@extends {Base<Type>}`)
const extendsIndex = lines.findIndex((line) =>
line.includes('@extends')
line.includes('@extends'),
);
if (extendsIndex !== -1) {
lines.splice(extendsIndex, 1);
Expand All @@ -326,7 +326,7 @@ exports.astNodeVisitor = {
if (identifier) {
const absolutePath = path.resolve(
path.dirname(currentSourceName),
identifier.value
identifier.value,
);
// default to js extension since .js extention is assumed implicitly
const extension = getExtension(absolutePath);
Expand Down Expand Up @@ -359,7 +359,7 @@ exports.astNodeVisitor = {
// Replace typeof Foo with Class<Foo>
comment.value = comment.value.replace(
/typeof ([^,\|\}\>]*)([,\|\}\>])/g,
'Class<$1>$2'
'Class<$1>$2',
);

// Remove `@override` annotations to avoid JSDoc breaking the inheritance chain
Expand Down Expand Up @@ -387,7 +387,7 @@ exports.astNodeVisitor = {
if (replaceAttempt > 100) {
// infinite loop protection
throw new Error(
`Invalid docstring ${comment.value} in ${currentSourceName}.`
`Invalid docstring ${comment.value} in ${currentSourceName}.`,
);
}
} else {
Expand All @@ -396,7 +396,7 @@ exports.astNodeVisitor = {
lastImportPath = importExpression;
const rel = path.resolve(
path.dirname(currentSourceName),
importSource
importSource,
);
// default to js extension since .js extention is assumed implicitly
const extension = getExtension(rel);
Expand All @@ -420,7 +420,7 @@ exports.astNodeVisitor = {
if (replacement) {
comment.value = comment.value.replace(
importExpression,
replacement + remainder
replacement + remainder,
);
}
}
Expand All @@ -441,13 +441,13 @@ exports.astNodeVisitor = {
Object.keys(identifiers).forEach((key) => {
const eventRegex = new RegExp(
`@(event |fires )${key}([^A-Za-z])`,
'g'
'g',
);
replace(eventRegex);

const typeRegex = new RegExp(
`@(.*[{<|,(!?:]\\s*)${key}([^A-Za-z].*?\}|\})`,
'g'
'g',
);
replace(typeRegex);

Expand All @@ -456,7 +456,7 @@ exports.astNodeVisitor = {
const identifier = identifiers[key];
const absolutePath = path.resolve(
path.dirname(currentSourceName),
identifier.value
identifier.value,
);
// default to js extension since .js extention is assumed implicitly
const extension = getExtension(absolutePath);
Expand All @@ -472,11 +472,11 @@ exports.astNodeVisitor = {
: getDelimiter(moduleId, exportName, parser);
const replacement = `module:${moduleId.replace(
slashRegEx,
'/'
'/',
)}${exportName ? delimiter + exportName : ''}`;
comment.value = comment.value.replace(
regex,
'@$1' + replacement + '$2'
'@$1' + replacement + '$2',
);
}
}
Expand Down

0 comments on commit c51ebc3

Please sign in to comment.