mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
113 lines
2.8 KiB
JavaScript
113 lines
2.8 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = warnRemovedSettings;
|
|
|
|
var _WarnSettings = _interopRequireDefault(require("./WarnSettings"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const warnSettings = (0, _WarnSettings.default)();
|
|
/**
|
|
* @typedef {(
|
|
* "require-jsdoc"
|
|
* | "require-returns"
|
|
* | "valid-types"
|
|
* | "require-example"
|
|
* | "check-examples"
|
|
* )} RulesWithMovedSettings
|
|
*/
|
|
|
|
/**
|
|
* @param {object} obj
|
|
* @param {string} property
|
|
* @returns {boolean}
|
|
*/
|
|
|
|
const has = (obj, property) => {
|
|
return Object.prototype.hasOwnProperty.call(obj, property);
|
|
};
|
|
/**
|
|
*
|
|
* @param {RulesWithMovedSettings} ruleName
|
|
* @returns {string[]}
|
|
*/
|
|
|
|
|
|
const getMovedSettings = ruleName => {
|
|
switch (ruleName) {
|
|
case 'require-jsdoc':
|
|
return ['exemptEmptyFunctions'];
|
|
|
|
case 'require-returns':
|
|
return ['forceRequireReturn'];
|
|
|
|
case 'valid-types':
|
|
return ['allowEmptyNamepaths', 'checkSeesForNamepaths'];
|
|
|
|
case 'require-example':
|
|
return ['avoidExampleOnConstructors'];
|
|
|
|
case 'check-examples':
|
|
return ['captionRequired', 'exampleCodeRegex', 'rejectExampleCodeRegex', 'allowInlineConfig', 'noDefaultExampleRules', 'matchingFileName', 'configFile', // The old name for `checkEslintrc`
|
|
'eslintrcForExamples', 'baseConfig', 'reportUnusedDisableDirectives'];
|
|
}
|
|
/* istanbul ignore next */
|
|
|
|
|
|
return [];
|
|
};
|
|
/**
|
|
* @param {object} context
|
|
* @param {RulesWithMovedSettings} ruleName
|
|
*/
|
|
|
|
|
|
function warnRemovedSettings(context, ruleName) {
|
|
const movedSettings = getMovedSettings(ruleName);
|
|
|
|
if (!context.settings || !context.settings.jsdoc) {
|
|
return;
|
|
}
|
|
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
|
|
try {
|
|
for (var _iterator = movedSettings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
const setting = _step.value;
|
|
|
|
if (has(context.settings.jsdoc, setting) && !warnSettings.hasBeenWarned(context, setting)) {
|
|
context.report({
|
|
loc: {
|
|
start: {
|
|
column: 1,
|
|
line: 1
|
|
}
|
|
},
|
|
message: `\`settings.jsdoc.${setting}\` has been removed, ` + `use options in the rule \`${ruleName}\` instead.`
|
|
});
|
|
warnSettings.markSettingAsWarned(context, setting);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
_iterator.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=warnRemovedSettings.js.map
|