/**
 * ESLint rule to prevent importing from internal directories
 * @fileoverview Disallow importing from @shopify/shop-minis-react/internal
 */

module.exports = {
  meta: {
    type: 'problem',
    docs: {
      description:
        'Disallow importing from internal directories of @shopify/shop-minis-react',
      category: 'Best Practices',
      recommended: true,
    },
    messages: {
      noInternalImports:
        'Do not import from "{{importPath}}". Internal APIs are not part of the public API and may change without notice. Use the public exports from @shopify/shop-minis-react instead.',
    },
    schema: [],
  },

  create(context) {
    return {
      ImportDeclaration(node) {
        const importPath = node.source.value

        // Check if importing from internal directory
        if (
          importPath.includes('@shopify/shop-minis-react/internal') ||
          importPath.includes('@shopify/shop-minis-react/src/internal')
        ) {
          context.report({
            node: node.source,
            messageId: 'noInternalImports',
            data: {
              importPath,
            },
          })
        }
      },
    }
  },
}
