UNPKG

@shopify/shop-minis-react

Version:

React component library for Shopify Shop Minis with Tailwind CSS v4 support (source-only, requires TypeScript)

115 lines (107 loc) 3.78 kB
/* eslint-disable import/extensions */ /** * ESLint config for projects using @shopify/shop-minis-react * @fileoverview Recommended ESLint configuration for Shop Minis apps * * This config uses ESLint flat config format (supported in ESLint 8.57+) */ // Import the plugin directly so consumers don't need to install it separately const compatPlugin = require('eslint-plugin-compat') const reactPlugin = require('eslint-plugin-react') const shopMinisPlugin = require('./index.cjs') module.exports = { files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], ignores: ['.minis-cache/**/*', 'node_modules/**/*'], languageOptions: { parser: require('@typescript-eslint/parser'), ecmaVersion: 'latest', sourceType: 'module', parserOptions: { ecmaFeatures: { jsx: true, }, }, }, plugins: { 'shop-minis': shopMinisPlugin, react: reactPlugin, compat: compatPlugin, }, rules: { // Console usage 'no-console': 'warn', // React security 'react/no-danger': 'error', // Shop Minis custom rules 'shop-minis/no-dynamic-asset-paths': 'warn', 'shop-minis/no-env-without-fallback': 'error', 'shop-minis/no-hardcoded-asset-paths': 'error', 'shop-minis/no-internal-imports': 'error', 'shop-minis/no-javascript-files': 'error', 'shop-minis/no-secrets': ['error'], 'shop-minis/prefer-sdk-components': 'warn', 'shop-minis/prefer-sdk-hooks': 'warn', 'shop-minis/validate-manifest': 'error', // Unsafe code execution (built-in ESLint rules) 'no-eval': 'error', 'no-implied-eval': 'error', 'no-new-func': 'error', 'no-script-url': 'error', // WebAssembly restrictions (built-in ESLint rules) 'no-restricted-globals': [ 'error', { name: 'WebAssembly', message: 'WebAssembly is not supported in the Shop Minis environment. Consider using alternative JavaScript implementations.', }, ], 'no-restricted-syntax': [ 'error', // WebAssembly restrictions { selector: "MemberExpression[object.name='WebAssembly']", message: 'WebAssembly is not supported in the Shop Minis environment. Consider using alternative JavaScript implementations.', }, { selector: "NewExpression[callee.object.name='WebAssembly']", message: 'WebAssembly is not supported in the Shop Minis environment. Consider using alternative JavaScript implementations.', }, // window.open restriction { selector: "CallExpression[callee.object.name='window'][callee.property.name='open']", message: 'window.open is not allowed in the Shop Minis environment. Use the appropriate SDK navigation methods instead.', }, // Navigator API restrictions { selector: "MemberExpression[object.name='navigator'][property.name='clipboard']", message: 'navigator.clipboard is not available in the Shop Minis environment.', }, { selector: "MemberExpression[object.name='navigator'][property.name='credentials']", message: 'navigator.credentials is not available in the Shop Minis environment.', }, { selector: "MemberExpression[object.name='navigator'][property.name='geolocation']", message: 'navigator.geolocation is not available in the Shop Minis environment.', }, { selector: "MemberExpression[object.name='navigator'][property.name='share']", message: 'navigator.share is not available in the Shop Minis environment. Use the SDK share functionality instead.', }, ], 'compat/compat': 'error', }, }