1 /**
2 * The flat-config plugin namespace under which all of this plugin's rules
3 * are exposed to consumers (e.g. `"@medusajs/no-async-workflow-constructor"`).
4 *
5 * Consumers register the plugin under this key:
6 * plugins: { [PLUGIN_NAMESPACE]: plugin }
7 *
8 * Rule modules themselves are stored in `plugin.rules` under their bare
9 * names (e.g. `"no-async-workflow-constructor"`) — ESLint joins the plugin
10 * key with the bare rule key to form the fully-qualified id.
11 */
12 export const PLUGIN_NAMESPACE = "@medusajs"
13
14 /** The npm package name; also used as `meta.name` on the plugin object. */
15 export const PLUGIN_NAME = `${PLUGIN_NAMESPACE}/eslint-plugin`
16
17 /** Build the fully-qualified rule id a consumer would use in their config. */
18 export const ruleId = (name: string): string => `${PLUGIN_NAMESPACE}/${name}`
19
20 /** Public entry-point sources that rules inspect imports from. */
21 export const FRAMEWORK_UTILS_SOURCE = "@medusajs/framework/utils"
22 export const WORKFLOWS_SDK_SOURCE = "@medusajs/framework/workflows-sdk"
23 export const FRAMEWORK_TYPES_SOURCE = "@medusajs/framework/types"
24 export const FRAMEWORK_HTTP_SOURCE = "@medusajs/framework/http"
25 export const LEGACY_TYPES_SOURCE = "@medusajs/types"
26 export const ADMIN_SDK_SOURCE = "@medusajs/admin-sdk"
27
28 /** All sources that expose Medusa type declarations. */
29 export const TYPES_SOURCES: ReadonlySet<string> = new Set([
30 FRAMEWORK_TYPES_SOURCE,
31 LEGACY_TYPES_SOURCE,
32 ])
33
34 /**
35 * First Medusa version that ships the `allowFields` middleware from
36 * `@medusajs/framework/http`. Rules quote it in their messages because the
37 * plugin version and the project's Medusa version can differ.
38 */
39 export const ALLOW_FIELDS_MIN_MEDUSA_VERSION = "2.21.0"
40
41 /** The name of the `Modules` enum as imported from `@medusajs/framework/utils`. */
42 export const MODULES_ENUM = "Modules"
43
44 /**
45 * Map of known `Modules.*` string values → enum member name.
46 * Sourced from `packages/core/utils/src/modules-sdk/definition.ts`.
47 *
48 * Used by any rule that wants to recognize a built-in module string value and
49 * suggest the corresponding `Modules.*` enum member (e.g.
50 * `link-create-keys-modules-enum`, `prefer-modules-enum`).
51 */
52 export const MODULES_BY_VALUE: Record<string, string> = {
53 analytics: "ANALYTICS",
54 auth: "AUTH",
55 cache: "CACHE",
56 cart: "CART",
57 customer: "CUSTOMER",
58 event_bus: "EVENT_BUS",
59 inventory: "INVENTORY",
60 link_modules: "LINK",
61 payment: "PAYMENT",
62 pricing: "PRICING",
63 product: "PRODUCT",
64 promotion: "PROMOTION",
65 sales_channel: "SALES_CHANNEL",
66 tax: "TAX",
67 fulfillment: "FULFILLMENT",
68 stock_location: "STOCK_LOCATION",
69 user: "USER",
70 workflows: "WORKFLOW_ENGINE",
71 region: "REGION",
72 order: "ORDER",
73 api_key: "API_KEY",
74 store: "STORE",
75 currency: "CURRENCY",
76 file: "FILE",
77 notification: "NOTIFICATION",
78 index: "INDEX",
79 locking: "LOCKING",
80 settings: "SETTINGS",
81 caching: "CACHING",
82 translation: "TRANSLATION",
83 rbac: "RBAC",
84 }