HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/design.system/node_modules/eslint-plugin-storybook/dist/rules/meta-inline-properties.js
"use strict";
/**
 * @fileoverview Meta should have inline properties
 * @author Yann Braga
 */
const utils_1 = require("../utils");
const constants_1 = require("../utils/constants");
const create_storybook_rule_1 = require("../utils/create-storybook-rule");
module.exports = (0, create_storybook_rule_1.createStorybookRule)({
    name: 'meta-inline-properties',
    defaultOptions: [{ csfVersion: 3 }],
    meta: {
        type: 'problem',
        severity: 'error',
        docs: {
            description: 'Meta should only have inline properties',
            categories: [constants_1.CategoryId.CSF, constants_1.CategoryId.RECOMMENDED],
            excludeFromConfig: true,
        },
        messages: {
            metaShouldHaveInlineProperties: 'Meta should only have inline properties: {{property}}',
        },
        schema: [
            {
                type: 'object',
                properties: {
                    csfVersion: {
                        type: 'number',
                    },
                },
                additionalProperties: false,
            },
        ],
    },
    create(context) {
        // variables should be defined here
        // In case we need to get options defined in the rule schema
        // const options = context.options[0] || {}
        // const csfVersion = options.csfVersion
        //----------------------------------------------------------------------
        // Helpers
        //----------------------------------------------------------------------
        const isInline = (node) => {
            if (!(node && typeof node === 'object' && 'value' in node)) {
                return false;
            }
            return (node.value.type === 'ObjectExpression' ||
                node.value.type === 'Literal' ||
                node.value.type === 'ArrayExpression');
        };
        // any helper functions should go here or else delete this section
        //----------------------------------------------------------------------
        // Public
        //----------------------------------------------------------------------
        return {
            ExportDefaultDeclaration(node) {
                const meta = (0, utils_1.getMetaObjectExpression)(node, context);
                if (!meta) {
                    return null;
                }
                const ruleProperties = ['title', 'args'];
                const dynamicProperties = [];
                const metaNodes = meta.properties.filter((prop) => 'key' in prop && 'name' in prop.key && ruleProperties.includes(prop.key.name));
                metaNodes.forEach((metaNode) => {
                    if (!isInline(metaNode)) {
                        dynamicProperties.push(metaNode);
                    }
                });
                if (dynamicProperties.length > 0) {
                    dynamicProperties.forEach((propertyNode) => {
                        var _a;
                        context.report({
                            node: propertyNode,
                            messageId: 'metaShouldHaveInlineProperties',
                            data: {
                                property: (_a = propertyNode.key) === null || _a === void 0 ? void 0 : _a.name,
                            },
                        });
                    });
                }
            },
        };
    },
});