diff --git a/package.json b/package.json index 666d8f768..ec2478c54 100644 --- a/package.json +++ b/package.json @@ -22,14 +22,14 @@ "@babel/preset-env": "^7.12.11", "@babel/register": "^7.12.10", "@hkdobrev/run-if-changed": "^0.3.1", - "@typescript-eslint/parser": "^4.10.0", + "@typescript-eslint/parser": "^4.11.1", "babel-eslint": "^10.1.0", "babel-plugin-add-module-exports": "^1.0.4", "babel-plugin-istanbul": "^6.0.0", "chai": "^4.2.0", "cross-env": "^7.0.3", - "eslint": "7.16.0", - "eslint-config-canonical": "^24.4.4", + "eslint": "7.17.0", + "eslint-config-canonical": "^25.0.0", "gitdown": "^3.1.3", "glob": "^7.1.6", "husky": "^4.3.6", @@ -37,7 +37,7 @@ "mocha": "^8.2.1", "nyc": "^15.1.0", "rimraf": "^3.0.2", - "semantic-release": "^17.3.0", + "semantic-release": "^17.3.1", "typescript": "^4.1.3" }, "engines": { diff --git a/src/exportParser.js b/src/exportParser.js index 94a40ec20..77346978c 100644 --- a/src/exportParser.js +++ b/src/exportParser.js @@ -322,10 +322,11 @@ const findNode = function (node, block, cache) { blockCache = blockCache.slice(); blockCache.push(block); - if (block.type === 'object' || block.type === 'MethodDefinition') { - if (block.value === node) { - return true; - } + if ( + (block.type === 'object' || block.type === 'MethodDefinition') && + block.value === node + ) { + return true; } const {props = block.body} = block; @@ -367,10 +368,8 @@ const findExportedNode = function (block, node, cache) { const {props} = block; for (const propval of Object.values(props)) { blockCache.push(propval); - if (propval.exported) { - if (node === propval.value || findNode(node, propval.value)) { - return true; - } + if (propval.exported && (node === propval.value || findNode(node, propval.value))) { + return true; } // No need to check `propval` for exported nodes as ESM @@ -381,16 +380,15 @@ const findExportedNode = function (block, node, cache) { }; const isNodeExported = function (node, globals, opt) { - if (opt.initModuleExports && globals.props.module && globals.props.module.props.exports) { - if (findNode(node, globals.props.module.props.exports)) { - return true; - } + if ( + opt.initModuleExports && globals.props.module && globals.props.module.props.exports && + findNode(node, globals.props.module.props.exports) + ) { + return true; } - if (opt.initWindow && globals.props.window) { - if (findNode(node, globals.props.window)) { - return true; - } + if (opt.initWindow && globals.props.window && findNode(node, globals.props.window)) { + return true; } if (opt.esm && findExportedNode(globals, node)) { @@ -402,10 +400,8 @@ const isNodeExported = function (node, globals, opt) { const parseRecursive = function (node, globalVars, opts) { // Iterate from top using recursion - stop at first processed node from top - if (node.parent) { - if (parseRecursive(node.parent, globalVars, opts)) { - return true; - } + if (node.parent && parseRecursive(node.parent, globalVars, opts)) { + return true; } return mapVariables(node, globalVars, opts); diff --git a/src/rules/checkValues.js b/src/rules/checkValues.js index f6e543d0d..c401e142a 100644 --- a/src/rules/checkValues.js +++ b/src/rules/checkValues.js @@ -85,14 +85,12 @@ export default iterateJsdoc(({ null, jsdocParameter, ); - } else if (allowedAuthors) { - if (!allowedAuthors.includes(author)) { - report( - `Invalid JSDoc @${targetTagName}: "${jsdocParameter.description}"; expected one of ${allowedAuthors.join(', ')}.`, - null, - jsdocParameter, - ); - } + } else if (allowedAuthors && !allowedAuthors.includes(author)) { + report( + `Invalid JSDoc @${targetTagName}: "${jsdocParameter.description}"; expected one of ${allowedAuthors.join(', ')}.`, + null, + jsdocParameter, + ); } }); }, {