diff --git a/.gitignore b/.gitignore index 300d879a..9995fa14 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,37 @@ node_modules .directory .idea dist/ +/venv/ + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +tests/scratch +docs/_build diff --git a/bids/tsvParser.js b/bids/tsvParser.js index 5cde3776..7e1e79b5 100644 --- a/bids/tsvParser.js +++ b/bids/tsvParser.js @@ -12,7 +12,7 @@ const isContentfulRow = (row) => row && !/^\s*$/.test(row) * Parse a TSV file. * * @param {string} contents The contents of a TSV file. - * @return {{headers: string[], rows: string[][]}} The parsed contents of the TSV file. + * @returns {{headers: string[], rows: string[][]}} The parsed contents of the TSV file. */ function parseTSV(contents) { const content = { diff --git a/bids/types.js b/bids/types.js index 0d710a5d..e3e19246 100644 --- a/bids/types.js +++ b/bids/types.js @@ -318,7 +318,7 @@ export class BidsIssue { /** * Whether this issue is an error. - * @return {boolean} + * @returns {boolean} */ isError() { return bidsHedErrorCodes.has(this.code) diff --git a/bids/utils.js b/bids/utils.js index c69887f9..cf5341b8 100644 --- a/bids/utils.js +++ b/bids/utils.js @@ -2,7 +2,7 @@ * Determine whether a sidecar value has HED data. * * @param {object} sidecarValue A BIDS sidecar value. - * @return {boolean} Whether the sidecar value has HED data. + * @returns {boolean} Whether the sidecar value has HED data. */ export const sidecarValueHasHed = function (sidecarValue) { return sidecarValue !== null && typeof sidecarValue === 'object' && sidecarValue.HED !== undefined diff --git a/bids/validate.js b/bids/validate.js index e7b3bb4e..053bc367 100644 --- a/bids/validate.js +++ b/bids/validate.js @@ -9,7 +9,7 @@ import { generateIssue, Issue, IssueError } from '../common/issues/issues' * * @param {BidsDataset} dataset The BIDS dataset. * @param {object} schemaDefinition The version spec for the schema to be loaded. - * @return {Promise} Any issues found. + * @returns {Promise} Any issues found. */ export function validateBidsDataset(dataset, schemaDefinition) { return buildBidsSchemas(dataset, schemaDefinition).then( @@ -29,7 +29,7 @@ export function validateBidsDataset(dataset, schemaDefinition) { * * @param {BidsDataset} dataset A BIDS dataset. * @param {Schemas} hedSchemas A HED schema collection. - * @return {Promise|Promise} Any issues found. + * @returns {Promise|Promise} Any issues found. */ function validateFullDataset(dataset, hedSchemas) { try { @@ -52,7 +52,7 @@ function validateFullDataset(dataset, hedSchemas) { * * @param {BidsTsvFile} tsvFileData A BIDS TSV file. * @param {Schemas} hedSchemas A HED schema collection. - * @return {BidsIssue[]} Any issues found. + * @returns {BidsIssue[]} Any issues found. */ function validateBidsTsvFile(tsvFileData, hedSchemas) { const [hedStrings, tsvIssues] = parseTsvHed(tsvFileData) @@ -69,7 +69,7 @@ function validateBidsTsvFile(tsvFileData, hedSchemas) { * * @param {BidsSidecar[]} sidecarData A collection of BIDS sidecars. * @param {Schemas} hedSchemas A HED schema collection. - * @return {[boolean, BidsHedIssue[]]} Whether errors (as opposed to warnings) were founds, and all issues found. + * @returns {[boolean, BidsHedIssue[]]} Whether errors (as opposed to warnings) were founds, and all issues found. */ function validateSidecars(sidecarData, hedSchemas) { const issues = [] @@ -94,7 +94,7 @@ function validateSidecars(sidecarData, hedSchemas) { * * @param {BidsEventFile[]} eventData A collection of BIDS event TSV files. * @param {Schemas} hedSchemas A HED schema collection. - * @return {[boolean, BidsHedIssue[]]} Whether errors (as opposed to warnings) were founds, and all issues found. + * @returns {[boolean, BidsHedIssue[]]} Whether errors (as opposed to warnings) were founds, and all issues found. */ function validateHedColumn(eventData, hedSchemas) { const issues = eventData.flatMap((eventFileData) => { @@ -111,7 +111,7 @@ function validateHedColumn(eventData, hedSchemas) { * Combine the BIDS sidecar HED data into a BIDS TSV file's HED data. * * @param {BidsTsvFile} tsvFileData A BIDS TSV file. - * @return {[string[], BidsIssue[]]} The combined HED strings for this BIDS TSV file, and all issues found during the combination. + * @returns {[string[], BidsIssue[]]} The combined HED strings for this BIDS TSV file, and all issues found during the combination. */ function parseTsvHed(tsvFileData) { const hedStrings = [] @@ -177,7 +177,7 @@ function parseTsvHed(tsvFileData) { * @param {string[]} hedStrings The HED strings in the data collection. * @param {Schemas} hedSchemas The HED schema collection to validate against. * @param {BidsTsvFile} tsvFileData The BIDS event TSV file being validated. - * @return {BidsHedIssue[]} Any issues found. + * @returns {BidsHedIssue[]} Any issues found. */ function validateCombinedDataset(hedStrings, hedSchemas, tsvFileData) { const [, hedIssues] = validateHedDatasetWithContext(hedStrings, tsvFileData.mergedSidecar.hedStrings, hedSchemas, { @@ -194,7 +194,7 @@ function validateCombinedDataset(hedStrings, hedSchemas, tsvFileData) { * @param {Schemas} hedSchemas The HED schema collection to validate against. * @param {Object} fileObject A BIDS-format file object used to generate {@link BidsHedIssue} objects. * @param {Object} settings Options to pass to {@link validateHedString}. - * @return {BidsHedIssue[]} Any issues found. + * @returns {BidsHedIssue[]} Any issues found. */ function validateStrings(hedStrings, hedSchemas, fileObject, settings) { const issues = [] @@ -218,7 +218,7 @@ function validateStrings(hedStrings, hedSchemas, fileObject, settings) { * * @param {IssueError|Issue[]} hedIssues One or more HED-format issues. * @param {Object} file A BIDS-format file object used to generate {@link BidsHedIssue} objects. - * @return {BidsHedIssue[]} The passed issue(s) in BIDS-compatible format. + * @returns {BidsHedIssue[]} The passed issue(s) in BIDS-compatible format. */ function convertHedIssuesToBidsIssues(hedIssues, file) { if (hedIssues instanceof IssueError) { diff --git a/common/issues/issues.js b/common/issues/issues.js index e87a6046..96e48cd2 100644 --- a/common/issues/issues.js +++ b/common/issues/issues.js @@ -71,7 +71,7 @@ export class Issue { /** * Override of {@link Object.prototype.toString}. * - * @return {string} This issue's message. + * @returns {string} This issue's message. */ toString() { return this.message @@ -87,7 +87,7 @@ export class Issue { * * @param {string} internalCode The internal error code. * @param {Object} parameters The error string parameters. - * @return {Issue} An object representing the issue. + * @returns {Issue} An object representing the issue. */ export const generateIssue = function (internalCode, parameters) { const issueCodeData = issueData[internalCode] ?? issueData.genericError diff --git a/common/schema/loader.js b/common/schema/loader.js index eb00df6f..c34b532e 100644 --- a/common/schema/loader.js +++ b/common/schema/loader.js @@ -14,7 +14,7 @@ import { fallbackFilePath, localSchemaList } from './config' * @param {SchemaSpec} schemaDef The description of which schema to use. * @param {boolean} useFallback Whether to use a bundled fallback schema if the requested schema cannot be loaded. * @param {boolean} reportNoFallbackError Whether to report an error on a failed schema load when no fallback was used. - * @return {Promise|Promise<[object, Issue[]]>} The schema XML data or an error. + * @returns {Promise|Promise<[object, Issue[]]>} The schema XML data or an error. */ export const loadSchema = function (schemaDef = null, useFallback = true, reportNoFallbackError = true) { const schemaPromise = loadPromise(schemaDef) @@ -52,7 +52,7 @@ export const loadSchema = function (schemaDef = null, useFallback = true, report * @todo Rename to {@link loadSchema} in 4.0.0. * * @param {SchemaSpec} schemaDef The description of which schema to use. - * @return {Promise|Promise<[object, Issue[]]>} The schema XML data or an error. + * @returns {Promise|Promise<[object, Issue[]]>} The schema XML data or an error. */ export const loadSchemaFromSpec = function (schemaDef = null) { const schemaPromise = loadPromise(schemaDef) @@ -66,7 +66,7 @@ export const loadSchemaFromSpec = function (schemaDef = null) { * Choose the schema Promise from a schema version or path description. * * @param {SchemaSpec} schemaDef The description of which schema to use. - * @return {Promise} The schema XML data or an error. + * @returns {Promise} The schema XML data or an error. */ const loadPromise = function (schemaDef) { if (schemaDef === null) { @@ -87,7 +87,7 @@ const loadPromise = function (schemaDef) { * Load schema XML data from the HED GitHub repository. * * @param {SchemaSpec} schemaDef The standard schema version to load. - * @return {Promise} The schema XML data. + * @returns {Promise} The schema XML data. */ const loadRemoteSchema = function (schemaDef) { let url @@ -103,7 +103,7 @@ const loadRemoteSchema = function (schemaDef) { * Load schema XML data from a local file. * * @param {string} path The path to the schema XML data. - * @return {Promise} The schema XML data. + * @returns {Promise} The schema XML data. */ const loadLocalSchema = function (path) { return loadSchemaFile(files.readFile(path), 'localSchemaLoadFailed', { path: path }) @@ -113,7 +113,7 @@ const loadLocalSchema = function (path) { * Load schema XML data from a bundled file. * * @param {SchemaSpec} schemaDef The description of which schema to use. - * @return {Promise} The schema XML data. + * @returns {Promise} The schema XML data. */ const loadBundledSchema = function (schemaDef) { return parseSchemaXML(localSchemaList.get(schemaDef.localName)).catch((error) => { @@ -128,7 +128,7 @@ const loadBundledSchema = function (schemaDef) { * @param {Promise} xmlDataPromise The Promise containing the unparsed XML data. * @param {string} issueCode The issue code. * @param {Object} issueArgs The issue arguments passed from the calling function. - * @return {Promise} The parsed schema XML data. + * @returns {Promise} The parsed schema XML data. */ const loadSchemaFile = function (xmlDataPromise, issueCode, issueArgs) { return xmlDataPromise.then(parseSchemaXML).catch((error) => { @@ -141,7 +141,7 @@ const loadSchemaFile = function (xmlDataPromise, issueCode, issueArgs) { * Parse the schema XML data. * * @param {string} data The XML data. - * @return {Promise} The schema XML data. + * @returns {Promise} The schema XML data. */ const parseSchemaXML = function (data) { return xml2js.parseStringPromise(data, { explicitCharkey: true }) diff --git a/common/schema/types.js b/common/schema/types.js index 61ab51ab..68e259b4 100644 --- a/common/schema/types.js +++ b/common/schema/types.js @@ -54,7 +54,7 @@ export class Schema { * * @param {string} tag The HED tag to check. * @param {string} tagAttribute The attribute to check for. - * @return {boolean} Whether this tag has this attribute. + * @returns {boolean} Whether this tag has this attribute. * @abstract */ // eslint-disable-next-line no-unused-vars @@ -84,7 +84,7 @@ export class Hed2Schema extends Schema { * * @param {string} tag The HED tag to check. * @param {string} tagAttribute The attribute to check for. - * @return {boolean} Whether this tag has this attribute. + * @returns {boolean} Whether this tag has this attribute. */ tagHasAttribute(tag, tagAttribute) { return this.attributes.tagHasAttribute(tag, tagAttribute) @@ -121,7 +121,7 @@ export class Hed3Schema extends Schema { * * @param {string} tag The HED tag to check. * @param {string} tagAttribute The attribute to check for. - * @return {boolean} Whether this tag has this attribute. + * @returns {boolean} Whether this tag has this attribute. */ tagHasAttribute(tag, tagAttribute) { return this.entries.tagHasAttribute(tag, tagAttribute) @@ -235,7 +235,7 @@ export class Schemas { /** * Whether this schema collection is for syntactic validation only. - * @return {boolean} + * @returns {boolean} */ get isSyntaxOnly() { return this.generation === 0 @@ -243,7 +243,7 @@ export class Schemas { /** * Whether this schema collection comprises HED 3 schemas. - * @return {boolean} + * @returns {boolean} */ get isHed3() { return this.generation === 3 diff --git a/converter/__tests__/converter.spec.js b/converter/__tests__/converter.spec.js index e3035f19..fda27d6c 100644 --- a/converter/__tests__/converter.spec.js +++ b/converter/__tests__/converter.spec.js @@ -23,7 +23,7 @@ describe('HED string conversion', () => { * @param {Object} expectedResults The expected results. * @param {Object} expectedIssues The expected issues. * @param {function (Schema, string, string, number): [string, Issue[]]} testFunction The test function. - * @return {Promise} + * @returns {Promise} */ const validatorBase = function (testStrings, expectedResults, expectedIssues, testFunction) { return hedSchemaPromise.then(([hedSchemas, issues]) => { @@ -588,7 +588,7 @@ describe('HED string conversion', () => { * @param {Object} expectedResults The expected results. * @param {Object} expectedIssues The expected issues. * @param {function (Schemas, string): [string, Issue[]]} testFunction The test function. - * @return {Promise} + * @returns {Promise} */ const validatorBase = function (testStrings, expectedResults, expectedIssues, testFunction) { return hedSchemaPromise.then(([hedSchemas, issues]) => { diff --git a/converter/converter.js b/converter/converter.js index 72091d08..61d5f0a1 100644 --- a/converter/converter.js +++ b/converter/converter.js @@ -9,7 +9,7 @@ const doubleSlashPattern = /[\s/]*\/+[\s/]*/g * Remove extra slashes and spaces from a HED string. * * @param {string} hedString The HED string to clean. - * @return {string} The cleaned HED string. + * @returns {string} The cleaned HED string. */ export const removeSlashesAndSpaces = function (hedString) { return hedString.replace(doubleSlashPattern, '/') @@ -26,7 +26,7 @@ export const removeSlashesAndSpaces = function (hedString) { * @param {string} hedTag The HED tag to convert. * @param {string} hedString The full HED string (for error messages). * @param {number} offset The offset of this tag within the HED string. - * @return {[string, Issue[]]} The long-form tag and any issues. + * @returns {[string, Issue[]]} The long-form tag and any issues. */ export const convertTagToLong = function (schema, hedTag, hedString, offset) { const mapping = schema.mapping @@ -127,7 +127,7 @@ export const convertTagToLong = function (schema, hedTag, hedString, offset) { * @param {string} hedTag The HED tag to convert. * @param {string} hedString The full HED string (for error messages). * @param {number} offset The offset of this tag within the HED string. - * @return {[string, Issue[]]} The short-form tag and any issues. + * @returns {[string, Issue[]]} The short-form tag and any issues. */ export const convertTagToShort = function (schema, hedTag, hedString, offset) { const mapping = schema.mapping @@ -198,7 +198,7 @@ export const convertTagToShort = function (schema, hedTag, hedString, offset) { * @param {string} partialHedString The partial HED string to convert to long form. * @param {string} fullHedString The full HED string. * @param {number} offset The offset of the partial HED string within the full string. - * @return {[string, Issue[]]} The converted string and any issues. + * @returns {[string, Issue[]]} The converted string and any issues. */ export const convertPartialHedStringToLong = function (schema, partialHedString, fullHedString, offset) { let issues = [] @@ -233,7 +233,7 @@ export const convertPartialHedStringToLong = function (schema, partialHedString, * @param {Schema} schema The schema object containing a short-to-long mapping. * @param {string} hedString The HED tag to convert. * @param {function (Schema, string, string, number): [string, Issue[]]} conversionFn The conversion function for a tag. - * @return {[string, Issue[]]} The converted string and any issues. + * @returns {[string, Issue[]]} The converted string and any issues. */ const convertHedString = function (schema, hedString, conversionFn) { let issues = [] @@ -267,7 +267,7 @@ const convertHedString = function (schema, hedString, conversionFn) { * * @param {Schemas} schemas The schema container object containing short-to-long mappings. * @param {string} hedString The HED tag to convert. - * @return {[string, Issue[]]} The long-form string and any issues. + * @returns {[string, Issue[]]} The long-form string and any issues. * @deprecated */ export const convertHedStringToLong = function (schemas, hedString) { @@ -279,7 +279,7 @@ export const convertHedStringToLong = function (schemas, hedString) { * * @param {Schemas} schemas The schema container object containing short-to-long mappings. * @param {string} hedString The HED tag to convert. - * @return {[string, Issue[]]} The short-form string and any issues. + * @returns {[string, Issue[]]} The short-form string and any issues. * @deprecated */ export const convertHedStringToShort = function (schemas, hedString) { diff --git a/converter/issues.js b/converter/issues.js index 76e60ef4..736cf17d 100644 --- a/converter/issues.js +++ b/converter/issues.js @@ -10,7 +10,7 @@ import { generateIssue } from '../common/issues/issues' * @param {string} hedString The source HED string. * @param {object} parameters The parameters to the format string. * @param {number[]} bounds The bounds of the problem tag. - * @return {Issue} The issue object. + * @returns {Issue} The issue object. */ export default function (code, hedString, parameters = {}, bounds = []) { parameters.tag = hedString.slice(bounds[0], bounds[1]) diff --git a/converter/schema.js b/converter/schema.js index 952e6a89..3a6abad6 100644 --- a/converter/schema.js +++ b/converter/schema.js @@ -9,7 +9,7 @@ import { generateIssue, IssueError } from '../common/issues/issues' * Build a short-long mapping object from schema XML data. * * @param {SchemaEntries} entries The schema XML data. - * @return {Mapping} The mapping object. + * @returns {Mapping} The mapping object. */ export const buildMappingObject = function (entries) { /** @@ -48,7 +48,7 @@ export const buildMappingObject = function (entries) { * Build a schema container object containing a short-long mapping from a base schema version or path description. * * @param {{path: string?, version: string?}} schemaDef The description of which schema to use. - * @return {Promise|Promise} The schema container object or an error. + * @returns {Promise|Promise} The schema container object or an error. * @deprecated */ export const buildSchema = (schemaDef) => validatorBuildSchema(schemaDef) diff --git a/converter/splitHedString.js b/converter/splitHedString.js index 17ad34c2..3993e86d 100644 --- a/converter/splitHedString.js +++ b/converter/splitHedString.js @@ -4,7 +4,7 @@ const tagDelimiters = new Set([',', '(', ')', '~']) * Split a HED string into delimiters and tags. * * @param {string} hedString The HED string to split. - * @return {Array[]} A list of string parts. The boolean is true if the part is + * @returns {Array[]} A list of string parts. The boolean is true if the part is * a tag and false if it is a delimiter. The numbers are the bounds of the part. */ export default function splitHedString(hedString) { diff --git a/readthedocs.yml b/readthedocs.yml index 1da6f63f..88c876e6 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -5,15 +5,15 @@ formats: - pdf build: - os: ubuntu-22.04 + os: 'ubuntu-22.04' tools: python: '3.7' nodejs: '18' jobs: post_install: + - pip install sphinx-js - npm ci - npm install -g jsdoc - - npm run generate-docs # Build documentation in the docs/ directory with Sphinx sphinx: diff --git a/tests/bids.spec.js b/tests/bids.spec.js index a385101f..9d0bccb0 100644 --- a/tests/bids.spec.js +++ b/tests/bids.spec.js @@ -749,7 +749,7 @@ describe('BIDS datasets', () => { * @param {Object} testDatasets The datasets to test with. * @param {Object} expectedIssues The expected issues. * @param {SchemasSpec} versionSpec The schema version to test with. - * @return {Promise} + * @returns {Promise} */ const validator = (testDatasets, expectedIssues, versionSpec) => { return Promise.all( diff --git a/utils/array.js b/utils/array.js index b47a3e4d..11ed80ff 100644 --- a/utils/array.js +++ b/utils/array.js @@ -20,7 +20,7 @@ export const getElementCount = function (array, elementToCount) { * * @template T * @param {T|T[]} array An array or scalar. - * @return {T[]} The original array or a singleton array of the scalar. + * @returns {T[]} The original array or a singleton array of the scalar. */ export const asArray = function (array) { return Array.isArray(array) ? array : [array] diff --git a/utils/files.js b/utils/files.js index 7e827e6b..eb0adde2 100644 --- a/utils/files.js +++ b/utils/files.js @@ -5,7 +5,7 @@ import request from 'then-request' * Read a local file. * * @param {string} fileName The file path. - * @return {Promise} A promise with the file contents. + * @returns {Promise} A promise with the file contents. */ export const readFile = function (fileName) { return new Promise((resolve) => { @@ -19,7 +19,7 @@ export const readFile = function (fileName) { * Read a remote file using HTTPS. * * @param {string} url The remote URL. - * @return {Promise} A promise with the file contents. + * @returns {Promise} A promise with the file contents. */ export const readHTTPSFile = function (url) { return request('GET', url).then((res) => res.getBody()) diff --git a/utils/hedData.js b/utils/hedData.js index 94aef646..0e7427c9 100644 --- a/utils/hedData.js +++ b/utils/hedData.js @@ -6,7 +6,7 @@ import { ParsedHed3Tag } from '../validator/parser/parsedHedTag' * Determine the HED generation for a base schema version number. * * @param {string} version A HED base schema version number. - * @return {number} The HED generation the base schema belongs to. + * @returns {number} The HED generation the base schema belongs to. */ export const getGenerationForSchemaVersion = function (version) { if (lt(version, '4.0.0')) { @@ -29,7 +29,7 @@ export const mergeParsingIssues = function (previousIssues, currentIssues) { * * @param {Schemas} hedSchemas The HED schema collection. * @param {string} shortTag A short-form HED 3 tag. - * @return {Map} A Map mapping a {@link Schema} to a {@link ParsedHedTag} object representing the full tag. + * @returns {Map} A Map mapping a {@link Schema} to a {@link ParsedHedTag} object representing the full tag. */ export const getParsedParentTags = function (hedSchemas, shortTag) { const parentTags = new Map() diff --git a/utils/hedStrings.js b/utils/hedStrings.js index 8f6318d3..f09aaad2 100644 --- a/utils/hedStrings.js +++ b/utils/hedStrings.js @@ -29,7 +29,7 @@ const getTagSlashIndices = function (tag) { * Get the levels of a tag. * * @param {string} tag A HED tag string. - * @return {string[]} The levels of this tag. + * @returns {string[]} The levels of this tag. */ export const getTagLevels = function (tag) { const tagSlashIndices = getTagSlashIndices(tag) @@ -41,7 +41,7 @@ export const getTagLevels = function (tag) { * * @param {string} tag A HED tag * @param {string} character The character to use as a separator. - * @return {string} The last part of the tag using the given separator. + * @returns {string} The last part of the tag using the given separator. */ export const getTagName = function (tag, character = '/') { const lastSlashIndex = tag.lastIndexOf(character) diff --git a/utils/map.js b/utils/map.js index 31cc7bf8..91a761e5 100644 --- a/utils/map.js +++ b/utils/map.js @@ -6,7 +6,7 @@ import isEqual from 'lodash/isEqual' * @template K,V * @param {[K,V][]} list A list of key-value pairs. * @param {function(V, V): boolean} equalityFunction An equality function for the value data. - * @return {[Map, [K,V][]]} A map and any non-equal duplicate keys found. + * @returns {[Map, [K,V][]]} A map and any non-equal duplicate keys found. */ export const filterNonEqualDuplicates = function (list, equalityFunction = isEqual) { const map = new Map() diff --git a/utils/string.js b/utils/string.js index f9ddd923..443d91d2 100644 --- a/utils/string.js +++ b/utils/string.js @@ -39,7 +39,7 @@ export const capitalizeString = function (string) { * Determine if a string is a valid clock face time. * * @param {string} timeString The string to check. - * @return {boolean} Whether the string is a valid clock face time. + * @returns {boolean} Whether the string is a valid clock face time. */ export const isClockFaceTime = function (timeString) { return date.isValid(timeString, 'HH:mm') || date.isValid(timeString, 'HH:mm:ss') @@ -49,7 +49,7 @@ export const isClockFaceTime = function (timeString) { * Determine if a string is a valid date-time. * * @param {string} dateTimeString The string to check. - * @return {boolean} Whether the string is a valid date-time. + * @returns {boolean} Whether the string is a valid date-time. */ export const isDateTime = function (dateTimeString) { return dateIsValid(parseISO(dateTimeString)) && rfc3339ish.test(dateTimeString) @@ -59,7 +59,7 @@ export const isDateTime = function (dateTimeString) { * Determine if a string is a valid number. * * @param {string} numericString The string to check. - * @return {boolean} Whether the string is a valid number. + * @returns {boolean} Whether the string is a valid number. */ export const isNumber = function (numericString) { return digitExpression.test(numericString) @@ -72,7 +72,7 @@ export const isNumber = function (numericString) { * * @param {string[]} strings The literal parts of the template string. * @param {(number|string)} keys The keys of the closure arguments. - * @return {function(...[*]): string} A closure to fill the string template. + * @returns {function(...[*]): string} A closure to fill the string template. */ export const stringTemplate = function (strings, ...keys) { return function (...values) { diff --git a/utils/types.js b/utils/types.js index cef2076a..58394024 100644 --- a/utils/types.js +++ b/utils/types.js @@ -16,7 +16,7 @@ export const MemoizerMixin = (Base) => { * @template T * @param {string} propertyName The property name * @param {function() : T} valueComputer A function to compute the value. - * @return {T} The computed value. + * @returns {T} The computed value. * @protected */ _memoize(propertyName, valueComputer) { diff --git a/utils/xpath.js b/utils/xpath.js index 4e242573..4cdb41d7 100644 --- a/utils/xpath.js +++ b/utils/xpath.js @@ -18,7 +18,7 @@ const childToParent = { * * @param {object} element An xml2js element. * @param {string} query An XPath query. - * @return {object[]} An array of xml2js elements matching the query. + * @returns {object[]} An array of xml2js elements matching the query. */ export const find = function (element, query) { const { elementName, attributeName } = parseXPath(query) @@ -38,7 +38,7 @@ export const find = function (element, query) { * This is a minimal parser only suitable for this package. * * @param {string} query An XPath query. - * @return {object} The parsed search parameters. + * @returns {object} The parsed search parameters. */ const parseXPath = function (query) { const nodeQuery = /^\/\/(\w+)$/ @@ -66,7 +66,7 @@ const parseXPath = function (query) { * @param {object} element An xml2js element. * @param {string} elementName The element name. * @param {string} attributeName The attribute name. - * @return {object[]} An array of xml2js elements with the given name and attribute. + * @returns {object[]} An array of xml2js elements with the given name and attribute. */ const search = function (element, elementName, attributeName) { let result = [] diff --git a/validator/dataset.js b/validator/dataset.js index 22536df5..15285420 100644 --- a/validator/dataset.js +++ b/validator/dataset.js @@ -9,7 +9,7 @@ import { filterNonEqualDuplicates } from '../utils/map' * Parse the dataset's definitions and evaluate labels in the dataset. * * @param {ParsedHedString[]} parsedHedStrings The dataset's parsed HED strings. - * @return {[Map, Issue[]]} The definition map and any issues found. + * @returns {[Map, Issue[]]} The definition map and any issues found. */ export const parseDefinitions = function (parsedHedStrings) { const issues = [] @@ -66,7 +66,7 @@ const checkGroupForTemporalOrder = (parsedGroup, activeScopes) => { * * @param {ParsedHedString[]} hedStrings The dataset's HED strings. * @param {Schemas} hedSchemas The HED schema container object. - * @return {Issue[]} Any issues found. + * @returns {Issue[]} Any issues found. */ export const validateTemporalOrder = function (hedStrings, hedSchemas) { const issues = [] @@ -99,7 +99,7 @@ export const validateTemporalOrder = function (hedStrings, hedSchemas) { * @param {Definitions} definitions The parsed dataset definitions. * @param {ParsedHedString[]} hedStrings The dataset's HED strings. * @param {Schemas} hedSchemas The HED schema container object. - * @return {Issue[]} Whether the HED dataset is valid and any issues found. + * @returns {Issue[]} Whether the HED dataset is valid and any issues found. */ export const validateDataset = function (definitions, hedStrings, hedSchemas) { // TODO: Implement diff --git a/validator/event/hed3.js b/validator/event/hed3.js index cc49bc30..74ca3b6b 100644 --- a/validator/event/hed3.js +++ b/validator/event/hed3.js @@ -278,7 +278,7 @@ export class Hed3Validator extends HedValidator { /** * Validate a unit and strip it from the value. * @param {ParsedHed3Tag} tag A HED tag. - * @return {[boolean, boolean, string]} Whether a unit was found, whether it was valid, and the stripped value. + * @returns {[boolean, boolean, string]} Whether a unit was found, whether it was valid, and the stripped value. */ validateUnits(tag) { const originalTagUnitValue = tag.originalTagName diff --git a/validator/event/init.js b/validator/event/init.js index 77a9dbef..c9e5544f 100644 --- a/validator/event/init.js +++ b/validator/event/init.js @@ -14,7 +14,7 @@ import { Issue } from '../../common/issues/issues' * @param {Schemas} hedSchemas The HED schemas to validate against. * @param {Object} options Any validation options passed in. * @param {Map?} definitions The definitions for this HED dataset. - * @return {[ParsedHedString, Issue[], HedValidator]} The parsed HED string, the actual HED schema collection to use, any issues found, and whether to perform semantic validation. + * @returns {[ParsedHedString, Issue[], HedValidator]} The parsed HED string, the actual HED schema collection to use, any issues found, and whether to perform semantic validation. */ const initiallyValidateHedString = function (hedString, hedSchemas, options, definitions = null) { const doSemanticValidation = hedSchemas instanceof Schemas diff --git a/validator/hed2/event/hed2Validator.js b/validator/hed2/event/hed2Validator.js index 4f2d1a2a..770f59f4 100644 --- a/validator/hed2/event/hed2Validator.js +++ b/validator/hed2/event/hed2Validator.js @@ -104,7 +104,7 @@ export class Hed2Validator extends HedValidator { * * @param {string} value The stripped value. * @param {boolean} isNumeric Whether the tag is numeric. - * @return {boolean} Whether the stripped value is valid. + * @returns {boolean} Whether the stripped value is valid. */ validateValue(value, isNumeric) { if (value === '#') { diff --git a/validator/hed2/event/units.js b/validator/hed2/event/units.js index 79bf0fd1..138cc5e6 100644 --- a/validator/hed2/event/units.js +++ b/validator/hed2/event/units.js @@ -13,7 +13,7 @@ const SIUnitSymbolModifierKey = 'SIUnitSymbolModifier' * @param {string} originalTagUnitValue The unformatted version of the value. * @param {string[]} tagUnitClassUnits The list of valid units for this tag. * @param {SchemaAttributes} hedSchemaAttributes The collection of schema attributes. - * @return {[boolean, boolean, string]} Whether a unit was found, whether it was valid, and the stripped value. + * @returns {[boolean, boolean, string]} Whether a unit was found, whether it was valid, and the stripped value. */ export const validateUnits = function (originalTagUnitValue, tagUnitClassUnits, hedSchemaAttributes) { const validUnits = getAllUnits(hedSchemaAttributes) @@ -64,7 +64,7 @@ export const validateUnits = function (originalTagUnitValue, tagUnitClassUnits, * * @param {string} unit A unit string. * @param {SchemaAttributes} hedSchemaAttributes The collection of schema attributes. - * @return {boolean} Whether the unit is a valid prefix unit. + * @returns {boolean} Whether the unit is a valid prefix unit. */ const isPrefixUnit = function (unit, hedSchemaAttributes) { if (unitPrefixType in hedSchemaAttributes.unitAttributes) { @@ -79,7 +79,7 @@ const isPrefixUnit = function (unit, hedSchemaAttributes) { * * @param {string} unit A unit string. * @param {SchemaAttributes} hedSchemaAttributes The collection of schema attributes. - * @return {string[]} The list of valid derivative units. + * @returns {string[]} The list of valid derivative units. */ const getValidDerivativeUnits = function (unit, hedSchemaAttributes) { const pluralUnits = [unit] diff --git a/validator/hed2/parser/parsedHed2Tag.js b/validator/hed2/parser/parsedHed2Tag.js index e487646b..abcca974 100644 --- a/validator/hed2/parser/parsedHed2Tag.js +++ b/validator/hed2/parser/parsedHed2Tag.js @@ -95,7 +95,7 @@ export class ParsedHed2Tag extends ParsedHedTag { /** * Get the legal units for a particular HED tag. - * @return {string[]} + * @returns {string[]} */ get validUnits() { return this._memoize('validUnits', () => { diff --git a/validator/hed2/schema/schemaAttributes.js b/validator/hed2/schema/schemaAttributes.js index 1e04646b..3edf4143 100644 --- a/validator/hed2/schema/schemaAttributes.js +++ b/validator/hed2/schema/schemaAttributes.js @@ -69,7 +69,7 @@ export class SchemaAttributes { * * @param {string} tag The HED tag to check. * @param {string} tagAttribute The attribute to check for. - * @return {boolean|null} Whether this tag has this attribute, or null if the attribute doesn't exist. + * @returns {boolean|null} Whether this tag has this attribute, or null if the attribute doesn't exist. */ tagHasAttribute(tag, tagAttribute) { if (!(tagAttribute in this.tagAttributes)) { diff --git a/validator/parser/main.js b/validator/parser/main.js index f4daf6bd..740706f7 100644 --- a/validator/parser/main.js +++ b/validator/parser/main.js @@ -124,7 +124,7 @@ const findDelimiterIssuesInHedString = function (hedString) { * Validate the full unparsed HED string. * * @param {string} hedString The unparsed HED string. - * @return {Object} String substitution issues and other issues. + * @returns {Object} String substitution issues and other issues. */ const validateFullUnparsedHedString = function (hedString) { const [fixedHedString, substitutionIssues] = substituteCharacters(hedString) @@ -166,7 +166,7 @@ export const parseHedString = function (hedString, hedSchemas) { * * @param {string[]} hedStrings A set of HED strings. * @param {Schemas} hedSchemas The collection of HED schemas. - * @return {[ParsedHedString[], Object]} The parsed HED strings and any issues found. + * @returns {[ParsedHedString[], Object]} The parsed HED strings and any issues found. */ export const parseHedStrings = function (hedStrings, hedSchemas) { return hedStrings diff --git a/validator/parser/parsedHedGroup.js b/validator/parser/parsedHedGroup.js index e993398c..c2d9b1e4 100644 --- a/validator/parser/parsedHedGroup.js +++ b/validator/parser/parsedHedGroup.js @@ -66,7 +66,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { * @param {ParsedHedGroup} group The parsed HED tag group. * @param {Schemas} hedSchemas The collection of HED schemas. * @param {string} shortTag The short tag to search for. - * @return {null|ParsedHedTag[]} The tag(s) matching the short tag. + * @returns {null|ParsedHedTag[]} The tag(s) matching the short tag. */ static findGroupTags(group, hedSchemas, shortTag) { if (!hedSchemas.isHed3) { @@ -90,7 +90,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * The {@code Definition} tags associated with this HED tag group. - * @return {ParsedHedTag[]} + * @returns {ParsedHedTag[]} */ get definitionTags() { return this.specialTags.get('Definition') @@ -98,7 +98,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * The {@code Def} tags associated with this HED tag group. - * @return {ParsedHedTag[]} + * @returns {ParsedHedTag[]} */ get defTags() { return this.specialTags.get('Def') @@ -106,7 +106,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * The {@code Def-expand} tags associated with this HED tag group. - * @return {ParsedHedTag[]} + * @returns {ParsedHedTag[]} */ get defExpandTags() { return this.specialTags.get('Def-expand') @@ -114,7 +114,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group is a definition group. - * @return {boolean} + * @returns {boolean} */ get isDefinitionGroup() { return this.specialTags.has('Definition') @@ -122,7 +122,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group has a {@code Def} tag. - * @return {boolean} + * @returns {boolean} */ get isDefGroup() { return this.specialTags.has('Def') @@ -130,7 +130,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group has a {@code Def-expand} tag. - * @return {boolean} + * @returns {boolean} */ get isDefExpandGroup() { return this.specialTags.has('Def-expand') @@ -138,7 +138,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group is an onset group. - * @return {boolean} + * @returns {boolean} */ get isOnsetGroup() { return this.specialTags.has('Onset') @@ -146,7 +146,7 @@ export default class ParsedHedGroup extends ParsedHedSubstring { /** * Whether this HED tag group is an offset group. - * @return {boolean} + * @returns {boolean} */ get isOffsetGroup() { return this.specialTags.has('Offset') diff --git a/validator/parser/parsedHedSubstring.js b/validator/parser/parsedHedSubstring.js index d2c6d971..15913ce9 100644 --- a/validator/parser/parsedHedSubstring.js +++ b/validator/parser/parsedHedSubstring.js @@ -30,7 +30,7 @@ export default class ParsedHedSubstring extends Memoizer { /** * Override of {@link Object.prototype.toString}. * - * @return {string} The original form of this HED substring. + * @returns {string} The original form of this HED substring. */ toString() { return this.originalTag diff --git a/validator/parser/parsedHedTag.js b/validator/parser/parsedHedTag.js index e608178f..1287b1f7 100644 --- a/validator/parser/parsedHedTag.js +++ b/validator/parser/parsedHedTag.js @@ -48,7 +48,7 @@ export class ParsedHedTag extends ParsedHedSubstring { /** * Override of {@link Object.prototype.toString}. * - * @return {string} The original form of this HED tag. + * @returns {string} The original form of this HED tag. */ toString() { if (this.schema?.prefix) { @@ -104,7 +104,7 @@ export class ParsedHedTag extends ParsedHedSubstring { * Get the last part of a HED tag. * * @param {string} tagString A HED tag. - * @return {string} The last part of the tag using the given separator. + * @returns {string} The last part of the tag using the given separator. */ static getTagName(tagString) { const lastSlashIndex = tagString.lastIndexOf('/') @@ -342,7 +342,7 @@ export class ParsedHed3Tag extends ParsedHedTag { /** * Get the legal units for a particular HED tag. - * @return {Set} + * @returns {Set} */ get validUnits() { return this._memoize('validUnits', () => { @@ -361,7 +361,7 @@ export class ParsedHed3Tag extends ParsedHedTag { /** * Get the schema tag object for this tag's value-taking form. * - * @return {SchemaTag} + * @returns {SchemaTag} */ get takesValueTag() { return this._memoize('takesValueTag', () => { diff --git a/validator/parser/splitHedString.js b/validator/parser/splitHedString.js index e217ae63..6dfb6b71 100644 --- a/validator/parser/splitHedString.js +++ b/validator/parser/splitHedString.js @@ -70,7 +70,7 @@ class HedStringTokenizer { /** * Split the HED string into delimiters and tags. * - * @return {[TagSpec[], GroupSpec, Object]} The tag specifications, group bounds, and any issues found. + * @returns {[TagSpec[], GroupSpec, Object]} The tag specifications, group bounds, and any issues found. */ tokenize() { this.initializeTokenizer() @@ -205,7 +205,7 @@ class HedStringTokenizer { * * @param {string} hedString The HED string to be split. * @param {TagSpec[]} tagSpecs The tag specifications. - * @return {Object} Any issues found. + * @returns {Object} Any issues found. */ const checkForInvalidCharacters = function (hedString, tagSpecs) { const syntaxIssues = [] @@ -260,7 +260,7 @@ const checkTagForInvalidCharacters = function (hedString, tagSpec, tag, invalidS * @param {Schemas} hedSchemas The collection of HED schemas. * @param {TagSpec[]} tagSpecs The tag specifications. * @param {GroupSpec} groupSpecs The bounds of the tag groups. - * @return {[ParsedHedSubstring[], Object]} The parsed HED string data and any issues found. + * @returns {[ParsedHedSubstring[], Object]} The parsed HED string data and any issues found. */ const createParsedTags = function (hedString, hedSchemas, tagSpecs, groupSpecs) { const conversionIssues = [] @@ -304,7 +304,7 @@ const createParsedTags = function (hedString, hedSchemas, tagSpecs, groupSpecs) * * @param {string} hedString The HED string to be split. * @param {Schemas} hedSchemas The collection of HED schemas. - * @return {[ParsedHedSubstring[], Object]} The parsed HED string data and any issues found. + * @returns {[ParsedHedSubstring[], Object]} The parsed HED string data and any issues found. */ export default function splitHedString(hedString, hedSchemas) { const [tagSpecs, groupBounds, splitIssues] = new HedStringTokenizer(hedString).tokenize() diff --git a/validator/schema/init.js b/validator/schema/init.js index a850c015..4171ebec 100644 --- a/validator/schema/init.js +++ b/validator/schema/init.js @@ -23,7 +23,7 @@ const isHed3Schema = function (xmlData) { * Build a schema attributes object from schema XML data. * * @param {object} xmlData The schema XML data. - * @return {SchemaAttributes|SchemaEntries} The schema attributes object. + * @returns {SchemaAttributes|SchemaEntries} The schema attributes object. */ export const buildSchemaAttributesObject = function (xmlData) { const rootElement = xmlData.HED @@ -56,7 +56,7 @@ const buildSchemaObject = function (xmlData) { * * @param {{path: string?, version: string?, libraries: Object?}} schemaDef The description of which schemas to use. * @param {boolean} useFallback Whether to use a bundled fallback schema if the requested schema cannot be loaded. - * @return {Promise|Promise} The schema container object or an error. + * @returns {Promise|Promise} The schema container object or an error. * @deprecated */ export const buildSchema = function (schemaDef = {}, useFallback = true) { @@ -84,7 +84,7 @@ export const buildSchema = function (schemaDef = {}, useFallback = true) { * Build a schema collection object from a schema specification. * * @param {Map|SchemasSpec} schemaSpecs The description of which schemas to use. - * @return {Promise|Promise<[Schemas, Issue[]]>} The schema container object and any issues found. + * @returns {Promise|Promise<[Schemas, Issue[]]>} The schema container object and any issues found. */ export const buildSchemas = function (schemaSpecs) { if (schemaSpecs instanceof SchemasSpec) { diff --git a/validator/schema/types.js b/validator/schema/types.js index ddd81f0f..481bfe05 100644 --- a/validator/schema/types.js +++ b/validator/schema/types.js @@ -35,7 +35,7 @@ export class SchemaEntries extends Memoizer { /** * Get the schema's unit classes. - * @return {SchemaEntryManager} + * @returns {SchemaEntryManager} */ get unitClassMap() { return this.definitions.get('unitClasses') @@ -57,7 +57,7 @@ export class SchemaEntries extends Memoizer { /** * Get the schema's SI unit modifiers. - * @return {Map} + * @returns {Map} */ get SIUnitModifiers() { const unitModifiers = this.definitions.get('unitModifiers') @@ -66,7 +66,7 @@ export class SchemaEntries extends Memoizer { /** * Get the schema's SI unit symbol modifiers. - * @return {Map} + * @returns {Map} */ get SIUnitSymbolModifiers() { const unitModifiers = this.definitions.get('unitModifiers') @@ -78,7 +78,7 @@ export class SchemaEntries extends Memoizer { * * @param {string} tag The HED tag to check. * @param {string} tagAttribute The attribute to check for. - * @return {boolean} Whether this tag has this attribute. + * @returns {boolean} Whether this tag has this attribute. */ tagHasAttribute(tag, tagAttribute) { if (!this.definitions.get('tags').hasEntry(tag)) { @@ -115,7 +115,7 @@ export class SchemaEntryManager extends Memoizer { /** * Iterator over the entry manager's entries. * - * @return {IterableIterator<[string, T]>} + * @returns {IterableIterator<[string, T]>} */ [Symbol.iterator]() { return this._definitions.entries() @@ -124,7 +124,7 @@ export class SchemaEntryManager extends Memoizer { /** * Iterator over the entry manager's keys. * - * @return {IterableIterator} + * @returns {IterableIterator} */ keys() { return this._definitions.keys() @@ -133,7 +133,7 @@ export class SchemaEntryManager extends Memoizer { /** * Iterator over the entry manager's keys. * - * @return {IterableIterator} + * @returns {IterableIterator} */ values() { return this._definitions.values() @@ -178,7 +178,7 @@ export class SchemaEntry { /** * The name of this schema entry. - * @return {string} + * @returns {string} */ get name() { return this._name @@ -190,7 +190,7 @@ export class SchemaEntry { * This method is a stub to be overridden in {@link SchemaEntryWithAttributes}. * * @param {string} attributeName The attribute to check for. - * @return {boolean} Whether this schema entry has this attribute. + * @returns {boolean} Whether this schema entry has this attribute. */ // eslint-disable-next-line no-unused-vars hasAttributeName(attributeName) { @@ -217,7 +217,7 @@ export class SchemaProperty extends SchemaEntry { /** * Whether this property describes a schema category. - * @return {boolean} + * @returns {boolean} */ get isCategoryProperty() { return this._propertyType === categoryProperty @@ -225,7 +225,7 @@ export class SchemaProperty extends SchemaEntry { /** * Whether this property describes a data type. - * @return {boolean} + * @returns {boolean} */ get isTypeProperty() { return this._propertyType === typeProperty @@ -233,7 +233,7 @@ export class SchemaProperty extends SchemaEntry { /** * Whether this property describes a role. - * @return {boolean} + * @returns {boolean} */ get isRoleProperty() { return this._propertyType === roleProperty @@ -286,7 +286,7 @@ export class SchemaAttribute extends SchemaEntry { /** * The categories of elements this schema attribute applies to. - * @return {Set|SchemaProperty|undefined} + * @returns {Set|SchemaProperty|undefined} */ get categoryProperty() { switch (this._categoryProperties.size) { @@ -301,7 +301,7 @@ export class SchemaAttribute extends SchemaEntry { /** * The data type property of this schema attribute. - * @return {SchemaProperty} + * @returns {SchemaProperty} */ get typeProperty() { return this._typeProperty @@ -309,7 +309,7 @@ export class SchemaAttribute extends SchemaEntry { /** * The set of role properties for this schema attribute. - * @return {Set} + * @returns {Set} */ get roleProperties() { return new Set(this._roleProperties) @@ -357,7 +357,7 @@ class SchemaEntryWithAttributes extends SchemaEntry { /** * Whether this schema entry has this attribute. * @param {SchemaAttribute} attribute The attribute to check for. - * @return {boolean} Whether this schema entry has this attribute. + * @returns {boolean} Whether this schema entry has this attribute. */ hasAttribute(attribute) { return this.booleanAttributes.has(attribute) @@ -367,7 +367,7 @@ class SchemaEntryWithAttributes extends SchemaEntry { * Retrieve the value of an attribute on this schema entry. * @param {SchemaAttribute} attribute The attribute whose value should be returned. * @param {boolean} alwaysReturnArray Whether to return a singleton array instead of a scalar value. - * @return {*} The value of the attribute. + * @returns {*} The value of the attribute. */ getAttributeValue(attribute, alwaysReturnArray = false) { return SchemaEntryWithAttributes._getMapArrayValue(this.valueAttributes, attribute, alwaysReturnArray) @@ -376,7 +376,7 @@ class SchemaEntryWithAttributes extends SchemaEntry { /** * Whether this schema entry has this attribute (by name). * @param {string} attributeName The attribute to check for. - * @return {boolean} Whether this schema entry has this attribute. + * @returns {boolean} Whether this schema entry has this attribute. */ hasAttributeName(attributeName) { return this.booleanAttributeNames.has(attributeName) @@ -386,7 +386,7 @@ class SchemaEntryWithAttributes extends SchemaEntry { * Retrieve the value of an attribute (by name) on this schema entry. * @param {string} attributeName The attribute whose value should be returned. * @param {boolean} alwaysReturnArray Whether to return a singleton array instead of a scalar value. - * @return {*} The value of the attribute. + * @returns {*} The value of the attribute. */ getNamedAttributeValue(attributeName, alwaysReturnArray = false) { return SchemaEntryWithAttributes._getMapArrayValue(this.valueAttributeNames, attributeName, alwaysReturnArray)