UNPKG

yoastseo

Version:

Yoast client-side content analysis

65 lines (62 loc) 2.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _assessor = _interopRequireDefault(require("./assessor.js")); var _configuration = _interopRequireDefault(require("../assessments/inclusiveLanguage/configuration")); var _InclusiveLanguageAssessment = _interopRequireDefault(require("../assessments/inclusiveLanguage/InclusiveLanguageAssessment.js")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * Default options for the Inclusive language assessor. * The infoLinks object includes the shortlinks to be used in WordPress. * * @type {{infoLinks: {}}} */ const defaultOptions = { infoLinks: {} }; /** * The InclusiveLanguageAssessor assesses a paper for potentially non-inclusive language. */ class InclusiveLanguageAssessor extends _assessor.default { /** * Creates a new InclusiveLanguageAssessor instance. * @param {Researcher} researcher The researcher to use. * @param {Object} [options] The assessor options. */ constructor(researcher, options = {}) { super(researcher, options); this.type = "inclusiveLanguageAssessor"; // Assign the options, fall back to a default value for options that are not set. // The "options" object will be populated with shortlinks for Shopify in the Shopify repository. this._options = Object.assign({}, defaultOptions, options); const infoLinks = this._options.infoLinks; this._assessments = _configuration.default.map(config => { // The if statement is a safety check to assure that the infoLinks object includes keys for all assessments. // If the category keys match the config categories, the infoLinks shortlinks are saved as the learnMoreURL of the config. if (infoLinks[config.category]) { config.learnMoreUrl = infoLinks[config.category]; } return new _InclusiveLanguageAssessment.default(config); }); } /** * Calculates the overall score. * * @returns {number} The overall score. */ calculateOverallScore() { const results = this.getValidResults(); const improvementResults = results.filter(result => result.getScore() === 6); const problemResults = results.filter(result => result.getScore() === 3); if (problemResults.length >= 1) { return 30; } else if (improvementResults.length >= 1) { return 60; } return 90; } } exports.default = InclusiveLanguageAssessor; //# sourceMappingURL=inclusiveLanguageAssessor.js.map