tools/internal-rules/consistent-docs-url.js
function checkMetaDocsUrl(context, exportsNode) {
    if (exportsNode.type !== "ObjectExpression") {

        // if the exported node is not the correct format, "internal-no-invalid-meta" will already report this.
        return;
    }

    const metaProperty = getPropertyFromObject("meta", exportsNode);
    const metaDocs = metaProperty && getPropertyFromObject("docs", metaProperty.value);
    const metaDocsUrl = metaDocs && getPropertyFromObject("url", metaDocs.value);

    if (!metaDocs) {
        context.report({
            node: metaProperty,
            message: "Rule is missing a meta.docs property"
        });
        return;
    }

    if (!metaDocsUrl) {
        context.report({
            node: metaDocs,
            message: "Rule is missing a meta.docs.url property"
        });
        return;
    }

    const ruleId = path.basename(context.getFilename().replace(/.js$/u, ""));
    const expected = `https://eslint.org/docs/rules/${ruleId}`;
    const url = metaDocsUrl.value.value;

    if (url !== expected) {
        context.report({
            node: metaDocsUrl.value,
            message: `Incorrect url. Expected "${expected}" but got "${url}"`
        });
    }

}
function checkMetaDocsUrl(context, exportsNode) {
    if (exportsNode.type !== "ObjectExpression") {

        // if the exported node is not the correct format, "internal-no-invalid-meta" will already report this.
        return;
    }

    const metaProperty = getPropertyFromObject("meta", exportsNode);
    const metaDocs = metaProperty && getPropertyFromObject("docs", metaProperty.value);
    const metaDocsUrl = metaDocs && getPropertyFromObject("url", metaDocs.value);

    if (!metaDocs) {
        context.report({
            node: metaProperty,
            message: "Rule is missing a meta.docs property"
        });
        return;
    }

    if (!metaDocsUrl) {
        context.report({
            node: metaDocs,
            message: "Rule is missing a meta.docs.url property"
        });
        return;
    }

    const ruleId = path.basename(context.getFilename().replace(/.js$/u, ""));
    const expected = `https://eslint.org/docs/rules/${ruleId}`;
    const url = metaDocsUrl.value.value;

    if (url !== expected) {
        context.report({
            node: metaDocsUrl.value,
            message: `Incorrect url. Expected "${expected}" but got "${url}"`
        });
    }

}
function checkMetaDocsUrl ( context , exportsNode ) { if ( exportsNode . type !== "ObjectExpression" ) { // if the exported node is not the correct format, "internal-no-invalid-meta" will already report this. return ; } const metaProperty = getPropertyFromObject ( "meta" , exportsNode ) ; const metaDocs = metaProperty && getPropertyFromObject ( "docs" , metaProperty . value ) ; const metaDocsUrl = metaDocs && getPropertyFromObject ( "url" , metaDocs . value ) ; if ( ! metaDocs ) { context . report ( { node : metaProperty , message : "Rule is missing a meta.docs property" } ) ; return ; } if ( ! metaDocsUrl ) { context . report ( { node : metaDocs , message : "Rule is missing a meta.docs.url property" } ) ; return ; } const ruleId = path . basename ( context . getFilename ( ) . replace ( / .js$ / u , "" ) ) ; const expected = ` ${ ruleId } ` ; const url = metaDocsUrl . value . value ; if ( url !== expected ) { context . report ( { node : metaDocsUrl . value , message : ` ${ expected } ${ url } ` } ) ; } }
Verifies that the meta.docs.url property is present and has the correct value.

@param {RuleContext} context The ESLint rule context.
@param {ASTNode} exportsNode ObjectExpression node that the rule exports.
@returns {void}
Verifies that the meta . docs . url property is present and has the correct value .