@stripe/extensibility-eslint-plugin 0.15.6 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/configs/async-with-egress.cjs +11 -7
  2. package/dist/configs/async-with-egress.js +11 -7
  3. package/dist/configs/billing.bill.discount_calculation.cjs +11 -7
  4. package/dist/configs/billing.bill.discount_calculation.js +11 -7
  5. package/dist/configs/billing.customer_balance_application.cjs +11 -7
  6. package/dist/configs/billing.customer_balance_application.js +11 -7
  7. package/dist/configs/{billing.invoice_collection_setting.cjs → billing.invoice_collection_options.cjs} +19 -15
  8. package/dist/configs/{billing.invoice_collection_setting.d.ts → billing.invoice_collection_options.d.ts} +2 -2
  9. package/dist/configs/billing.invoice_collection_options.d.ts.map +1 -0
  10. package/dist/configs/{billing.invoice_collection_setting.js → billing.invoice_collection_options.js} +15 -11
  11. package/dist/configs/billing.prorations.cjs +11 -7
  12. package/dist/configs/billing.prorations.js +11 -7
  13. package/dist/configs/billing.recurring_billing_item_handling.cjs +11 -7
  14. package/dist/configs/billing.recurring_billing_item_handling.js +11 -7
  15. package/dist/configs/core.workflows.custom_action.cjs +11 -7
  16. package/dist/configs/core.workflows.custom_action.js +11 -7
  17. package/dist/configs/custom-objects.cjs +11 -7
  18. package/dist/configs/custom-objects.js +11 -7
  19. package/dist/configs/extend.objects.custom_objects.cjs +11 -7
  20. package/dist/configs/extend.objects.custom_objects.js +11 -7
  21. package/dist/configs/extend.workflows.custom_action.cjs +11 -7
  22. package/dist/configs/extend.workflows.custom_action.js +11 -7
  23. package/dist/configs/runtime-core.cjs +11 -7
  24. package/dist/configs/runtime-core.js +11 -7
  25. package/dist/configs/sync-no-egress.cjs +11 -7
  26. package/dist/configs/sync-no-egress.js +11 -7
  27. package/dist/dsl-rules/index.d.ts +1 -0
  28. package/dist/dsl-rules/index.d.ts.map +1 -1
  29. package/dist/dsl-rules/no-module-scoped-mutable-const.d.ts +4 -0
  30. package/dist/dsl-rules/no-module-scoped-mutable-const.d.ts.map +1 -0
  31. package/dist/index.cjs +543 -36
  32. package/dist/index.js +543 -36
  33. package/dist/internal/analysis/eslint/module-scope.d.ts +10 -0
  34. package/dist/internal/analysis/eslint/module-scope.d.ts.map +1 -1
  35. package/dist/security-rules/valid-extension-interface.d.ts.map +1 -1
  36. package/dist/tsconfig.build.tsbuildinfo +1 -1
  37. package/package.json +7 -7
  38. package/dist/api-surface.d.ts.map +0 -1
  39. package/dist/configs/billing.invoice_collection_setting.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -3264,7 +3264,7 @@ var require_RuleCreator = __commonJS({
3264
3264
  exports2.RuleCreator = RuleCreator;
3265
3265
  var applyDefault_1 = require_applyDefault();
3266
3266
  function RuleCreator(urlCreator) {
3267
- return function createNamedRule({ meta: meta2, name, ...rule19 }) {
3267
+ return function createNamedRule({ meta: meta2, name, ...rule20 }) {
3268
3268
  const ruleWithDocs = createRule23({
3269
3269
  meta: {
3270
3270
  ...meta2,
@@ -3274,7 +3274,7 @@ var require_RuleCreator = __commonJS({
3274
3274
  }
3275
3275
  },
3276
3276
  name,
3277
- ...rule19
3277
+ ...rule20
3278
3278
  });
3279
3279
  return ruleWithDocs;
3280
3280
  };
@@ -35899,9 +35899,73 @@ var customObjectRules = {
35899
35899
  };
35900
35900
 
35901
35901
  // src/internal/analysis/eslint/module-scope.ts
35902
+ var TO_CONST_MODULE = "@stripe/extensibility-sdk";
35903
+ var KNOWN_GLOBAL_PRIMITIVES = /* @__PURE__ */ new Set(["undefined", "Infinity", "NaN"]);
35904
+ var COMPARISON_OPERATORS = /* @__PURE__ */ new Set([
35905
+ "==",
35906
+ "!=",
35907
+ "===",
35908
+ "!==",
35909
+ "<",
35910
+ "<=",
35911
+ ">",
35912
+ ">=",
35913
+ "in",
35914
+ "instanceof"
35915
+ ]);
35916
+ var ARITHMETIC_OPERATORS = /* @__PURE__ */ new Set([
35917
+ "+",
35918
+ "-",
35919
+ "*",
35920
+ "/",
35921
+ "%",
35922
+ "**",
35923
+ "|",
35924
+ "&",
35925
+ "^",
35926
+ "<<",
35927
+ ">>",
35928
+ ">>>"
35929
+ ]);
35930
+ function isIdentifier10(node) {
35931
+ return isNodeLike(node) && node.type === "Identifier";
35932
+ }
35933
+ function isNodeLike(value) {
35934
+ return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
35935
+ }
35936
+ function isTransparentExpressionLike(node) {
35937
+ return (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSTypeAssertion" || node.type === "TSNonNullExpression" || node.type === "ParenthesizedExpression") && "expression" in node;
35938
+ }
35939
+ function isTemplateLiteralLike(node) {
35940
+ return node.type === "TemplateLiteral" && "expressions" in node && Array.isArray(node.expressions);
35941
+ }
35942
+ function isUnaryExpressionLike(node) {
35943
+ return node.type === "UnaryExpression" && "operator" in node && typeof node.operator === "string" && "argument" in node;
35944
+ }
35945
+ function isBinaryExpressionLike(node) {
35946
+ return node.type === "BinaryExpression" && "operator" in node && typeof node.operator === "string" && "left" in node && "right" in node;
35947
+ }
35948
+ function isLogicalExpressionLike(node) {
35949
+ return node.type === "LogicalExpression" && "left" in node && "right" in node;
35950
+ }
35951
+ function isConditionalExpressionLike(node) {
35952
+ return node.type === "ConditionalExpression" && "consequent" in node && "alternate" in node;
35953
+ }
35954
+ function isSequenceExpressionLike(node) {
35955
+ return node.type === "SequenceExpression" && "expressions" in node && Array.isArray(node.expressions);
35956
+ }
35957
+ function isMemberExpressionLike2(node) {
35958
+ return node.type === "MemberExpression" && "object" in node && "property" in node && "computed" in node && typeof node.computed === "boolean";
35959
+ }
35902
35960
  function isTopLevelExport(node) {
35903
35961
  return node?.type === "ExportNamedDeclaration" && node.parent?.type === "Program";
35904
35962
  }
35963
+ function isProgramLike2(value) {
35964
+ return isNodeLike(value) && value.type === "Program" && "body" in value && Array.isArray(value.body);
35965
+ }
35966
+ function isCallExpressionLike2(node) {
35967
+ return node?.type === "CallExpression" && "callee" in node && isNodeLike(node.callee);
35968
+ }
35905
35969
  function isVarScopeBoundary(node) {
35906
35970
  return node?.type === "FunctionDeclaration" || node?.type === "FunctionExpression" || node?.type === "ArrowFunctionExpression" || node?.type === "StaticBlock";
35907
35971
  }
@@ -35936,6 +36000,290 @@ function isModuleScopedVariableKind(node, kind) {
35936
36000
  }
35937
36001
  return kind === "var" ? isVarHoistedToModuleScope(node) : isModuleScopedVariableDeclaration(node);
35938
36002
  }
36003
+ function unwrapTransparentExpression(node) {
36004
+ if (!isNodeLike(node)) {
36005
+ return void 0;
36006
+ }
36007
+ if (isTransparentExpressionLike(node)) {
36008
+ return unwrapTransparentExpression(node.expression);
36009
+ }
36010
+ return node;
36011
+ }
36012
+ function isPrimitiveLiteral(node) {
36013
+ return node.type === "Literal" && "value" in node && (node.value === null || typeof node.value === "string" || typeof node.value === "number" || typeof node.value === "boolean" || typeof node.value === "bigint");
36014
+ }
36015
+ function isScopeReferenceToIdentifier(scope, node) {
36016
+ let current = scope;
36017
+ while (current) {
36018
+ for (const reference of current.references ?? []) {
36019
+ if (reference.identifier === node) {
36020
+ return reference;
36021
+ }
36022
+ }
36023
+ for (const reference of current.through ?? []) {
36024
+ if (reference.identifier === node) {
36025
+ return reference;
36026
+ }
36027
+ }
36028
+ current = current.upper ?? void 0;
36029
+ }
36030
+ return void 0;
36031
+ }
36032
+ function isKnownGlobalPrimitiveIdentifier(sourceCode, node) {
36033
+ if (!KNOWN_GLOBAL_PRIMITIVES.has(node.name)) {
36034
+ return false;
36035
+ }
36036
+ const reference = isScopeReferenceToIdentifier(sourceCode.getScope(node), node);
36037
+ if (!reference) {
36038
+ return false;
36039
+ }
36040
+ return !reference.resolved || (reference.resolved.defs?.length ?? 0) === 0;
36041
+ }
36042
+ function isPrimitiveValueExpression(sourceCode, node) {
36043
+ const expression = unwrapTransparentExpression(node);
36044
+ if (!expression) {
36045
+ return false;
36046
+ }
36047
+ if (isPrimitiveLiteral(expression)) {
36048
+ return true;
36049
+ }
36050
+ if (isIdentifier10(expression)) {
36051
+ return isKnownGlobalPrimitiveIdentifier(sourceCode, expression);
36052
+ }
36053
+ if (isTemplateLiteralLike(expression)) {
36054
+ return expression.expressions.every(
36055
+ (part) => isPrimitiveValueExpression(sourceCode, part)
36056
+ );
36057
+ }
36058
+ if (isUnaryExpressionLike(expression)) {
36059
+ if (expression.operator === "void" || expression.operator === "typeof" || expression.operator === "!") {
36060
+ return true;
36061
+ }
36062
+ return (expression.operator === "+" || expression.operator === "-" || expression.operator === "~") && isPrimitiveValueExpression(sourceCode, expression.argument);
36063
+ }
36064
+ if (isBinaryExpressionLike(expression)) {
36065
+ if (COMPARISON_OPERATORS.has(expression.operator)) {
36066
+ return true;
36067
+ }
36068
+ return ARITHMETIC_OPERATORS.has(expression.operator) && isPrimitiveValueExpression(sourceCode, expression.left) && isPrimitiveValueExpression(sourceCode, expression.right);
36069
+ }
36070
+ if (isLogicalExpressionLike(expression)) {
36071
+ return isPrimitiveValueExpression(sourceCode, expression.left) && isPrimitiveValueExpression(sourceCode, expression.right);
36072
+ }
36073
+ if (isConditionalExpressionLike(expression)) {
36074
+ return isPrimitiveValueExpression(sourceCode, expression.consequent) && isPrimitiveValueExpression(sourceCode, expression.alternate);
36075
+ }
36076
+ if (isSequenceExpressionLike(expression)) {
36077
+ const finalExpression = expression.expressions.at(-1);
36078
+ return isPrimitiveValueExpression(sourceCode, finalExpression);
36079
+ }
36080
+ return false;
36081
+ }
36082
+ function isImportDeclarationLike2(node) {
36083
+ return node.type === "ImportDeclaration";
36084
+ }
36085
+ function isRuntimeImportDeclaration(node) {
36086
+ return node.importKind !== "type";
36087
+ }
36088
+ function isToConstNamedSpecifier(specifier) {
36089
+ return specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && isIdentifier10(specifier.imported) && specifier.imported.name === "toConst" && isIdentifier10(specifier.local);
36090
+ }
36091
+ function getToConstNamedLocalName(specifier) {
36092
+ return isToConstNamedSpecifier(specifier) ? specifier.local?.name : void 0;
36093
+ }
36094
+ function createToConstImportAnalysis(namedLocalNames, namespaceLocalNames, importToAugment) {
36095
+ return importToAugment ? {
36096
+ namedLocalNames,
36097
+ namespaceLocalNames,
36098
+ importToAugment
36099
+ } : {
36100
+ namedLocalNames,
36101
+ namespaceLocalNames
36102
+ };
36103
+ }
36104
+ function analyzeToConstImports(program) {
36105
+ const namedLocalNames = /* @__PURE__ */ new Set();
36106
+ const namespaceLocalNames = /* @__PURE__ */ new Set();
36107
+ let importToAugment;
36108
+ if (!isProgramLike2(program)) {
36109
+ return createToConstImportAnalysis(namedLocalNames, namespaceLocalNames);
36110
+ }
36111
+ for (const statement of program.body) {
36112
+ if (!isImportDeclarationLike2(statement)) {
36113
+ continue;
36114
+ }
36115
+ if (statement.source.value !== TO_CONST_MODULE) {
36116
+ continue;
36117
+ }
36118
+ for (const specifier of statement.specifiers) {
36119
+ if (specifier.type === "ImportNamespaceSpecifier" && isRuntimeImportDeclaration(statement) && isIdentifier10(specifier.local)) {
36120
+ namespaceLocalNames.add(specifier.local.name);
36121
+ }
36122
+ const toConstLocalName = getToConstNamedLocalName(specifier);
36123
+ if (toConstLocalName) {
36124
+ namedLocalNames.add(toConstLocalName);
36125
+ }
36126
+ }
36127
+ if (!importToAugment && isRuntimeImportDeclaration(statement) && !statement.specifiers.some(
36128
+ (specifier) => specifier.type === "ImportNamespaceSpecifier"
36129
+ )) {
36130
+ importToAugment = statement;
36131
+ }
36132
+ }
36133
+ return createToConstImportAnalysis(
36134
+ namedLocalNames,
36135
+ namespaceLocalNames,
36136
+ importToAugment
36137
+ );
36138
+ }
36139
+ function isToConstMemberAccess(callee, namespaceLocalNames) {
36140
+ if (!isMemberExpressionLike2(callee) || !isNodeLike(callee.object) || !isIdentifier10(callee.object) || !namespaceLocalNames.has(callee.object.name)) {
36141
+ return false;
36142
+ }
36143
+ return callee.computed ? isLiteralLike(callee.property) && callee.property.value === "toConst" : isNodeLike(callee.property) && isIdentifier10(callee.property) && callee.property.name === "toConst";
36144
+ }
36145
+ function isLiteralLike(node) {
36146
+ return isNodeLike(node) && node.type === "Literal";
36147
+ }
36148
+ function isCanonicalToConstCall(node, analysis) {
36149
+ const expression = unwrapTransparentExpression(node);
36150
+ if (!expression || !isCallExpressionLike2(expression)) {
36151
+ return false;
36152
+ }
36153
+ if (isIdentifier10(expression.callee) && analysis.namedLocalNames.has(expression.callee.name)) {
36154
+ return true;
36155
+ }
36156
+ return isToConstMemberAccess(expression.callee, analysis.namespaceLocalNames);
36157
+ }
36158
+ function isFixableMutableConst(node) {
36159
+ const expression = unwrapTransparentExpression(node);
36160
+ return expression?.type === "ObjectExpression" || expression?.type === "ArrayExpression";
36161
+ }
36162
+ function classifyModuleScopedConstInitializer(sourceCode, node, analysis) {
36163
+ if (isPrimitiveValueExpression(sourceCode, node)) {
36164
+ return "primitive";
36165
+ }
36166
+ if (isCanonicalToConstCall(node, analysis)) {
36167
+ return "wrapped-to-const";
36168
+ }
36169
+ if (isFixableMutableConst(node)) {
36170
+ return "fixable-mutable-literal";
36171
+ }
36172
+ return "other";
36173
+ }
36174
+ function getModuleScopeBindingNames(sourceCode) {
36175
+ const bindingNames = /* @__PURE__ */ new Set();
36176
+ if (!isProgramLike2(sourceCode.ast)) {
36177
+ return bindingNames;
36178
+ }
36179
+ for (const statement of sourceCode.ast.body) {
36180
+ collectModuleScopeBindingNames(statement, bindingNames);
36181
+ }
36182
+ return bindingNames;
36183
+ }
36184
+ function collectModuleScopeBindingNames(node, bindingNames) {
36185
+ if (!isNodeLike(node)) {
36186
+ return;
36187
+ }
36188
+ if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") {
36189
+ if ("declaration" in node) {
36190
+ collectModuleScopeBindingNames(node.declaration, bindingNames);
36191
+ }
36192
+ return;
36193
+ }
36194
+ if (node.type === "ImportDeclaration" && "specifiers" in node && Array.isArray(node.specifiers)) {
36195
+ for (const specifier of node.specifiers) {
36196
+ const local = isNodeLike(specifier) && "local" in specifier ? specifier.local : void 0;
36197
+ if (isIdentifier10(local)) {
36198
+ bindingNames.add(local.name);
36199
+ }
36200
+ }
36201
+ return;
36202
+ }
36203
+ if (node.type === "VariableDeclaration" && "declarations" in node && Array.isArray(node.declarations)) {
36204
+ for (const declaration of node.declarations) {
36205
+ if (isNodeLike(declaration) && "id" in declaration) {
36206
+ collectPatternBindingNames(declaration.id, bindingNames);
36207
+ }
36208
+ }
36209
+ return;
36210
+ }
36211
+ if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") {
36212
+ const declarationId = "id" in node ? node.id : void 0;
36213
+ if (isIdentifier10(declarationId)) {
36214
+ bindingNames.add(declarationId.name);
36215
+ }
36216
+ }
36217
+ }
36218
+ function collectPatternBindingNames(node, bindingNames) {
36219
+ if (!node || !isNodeLike(node)) {
36220
+ return;
36221
+ }
36222
+ if (isIdentifier10(node)) {
36223
+ bindingNames.add(node.name);
36224
+ return;
36225
+ }
36226
+ if (node.type === "RestElement" && "argument" in node) {
36227
+ collectPatternBindingNames(node.argument, bindingNames);
36228
+ return;
36229
+ }
36230
+ if (node.type === "AssignmentPattern" && "left" in node) {
36231
+ collectPatternBindingNames(node.left, bindingNames);
36232
+ return;
36233
+ }
36234
+ if (node.type === "ArrayPattern" && "elements" in node && Array.isArray(node.elements)) {
36235
+ for (const element of node.elements) {
36236
+ collectPatternBindingNames(element, bindingNames);
36237
+ }
36238
+ return;
36239
+ }
36240
+ if (node.type === "ObjectPattern" && "properties" in node && Array.isArray(node.properties)) {
36241
+ for (const property of node.properties) {
36242
+ if (!isNodeLike(property)) {
36243
+ continue;
36244
+ }
36245
+ if (property.type === "Property" && "value" in property) {
36246
+ collectPatternBindingNames(property.value, bindingNames);
36247
+ continue;
36248
+ }
36249
+ if (property.type === "RestElement" && "argument" in property) {
36250
+ collectPatternBindingNames(property.argument, bindingNames);
36251
+ }
36252
+ }
36253
+ }
36254
+ }
36255
+ function getUniqueBindingName(bindingNames, preferredName) {
36256
+ if (!bindingNames.has(preferredName)) {
36257
+ return preferredName;
36258
+ }
36259
+ let suffix = 1;
36260
+ let candidate = `${preferredName}${String(suffix)}`;
36261
+ while (bindingNames.has(candidate)) {
36262
+ suffix += 1;
36263
+ candidate = `${preferredName}${String(suffix)}`;
36264
+ }
36265
+ return candidate;
36266
+ }
36267
+ function getToConstImportLocalName(sourceCode, analysis) {
36268
+ if (analysis.namedLocalNames.size > 0 || analysis.namespaceLocalNames.size > 0) {
36269
+ return void 0;
36270
+ }
36271
+ return getUniqueBindingName(getModuleScopeBindingNames(sourceCode), "toConst");
36272
+ }
36273
+ function getToConstCallText(analysis) {
36274
+ const [namespaceName] = analysis.namespaceLocalNames;
36275
+ if (namespaceName) {
36276
+ return `${namespaceName}.toConst`;
36277
+ }
36278
+ const [localName] = analysis.namedLocalNames;
36279
+ return localName ?? "toConst";
36280
+ }
36281
+ function getRuntimeImportStatements(program) {
36282
+ if (!isProgramLike2(program)) {
36283
+ return [];
36284
+ }
36285
+ return program.body.filter(isImportDeclarationLike2);
36286
+ }
35939
36287
 
35940
36288
  // src/dsl-rules/no-module-scoped-let.ts
35941
36289
  function isAmbientDeclaration(node) {
@@ -35971,11 +36319,165 @@ var rule8 = {
35971
36319
  };
35972
36320
  var no_module_scoped_let_default = rule8;
35973
36321
 
35974
- // src/dsl-rules/no-module-scoped-var.ts
36322
+ // src/dsl-rules/no-module-scoped-mutable-const.ts
35975
36323
  function isAmbientDeclaration2(node) {
35976
36324
  return "declare" in node && node.declare;
35977
36325
  }
36326
+ function isSourceCodeLike(value) {
36327
+ return typeof value === "object" && value !== null && "ast" in value && "getText" in value && typeof value.getText === "function" && "getScope" in value && typeof value.getScope === "function";
36328
+ }
36329
+ function isVariableDeclaratorLike(node) {
36330
+ return typeof node === "object" && node !== null && "type" in node && node.type === "VariableDeclarator";
36331
+ }
36332
+ function getVariableDeclarators(node) {
36333
+ if (!("declarations" in node) || !Array.isArray(node.declarations)) {
36334
+ return [];
36335
+ }
36336
+ return node.declarations.filter(isVariableDeclaratorLike);
36337
+ }
36338
+ function hasRange(value) {
36339
+ return typeof value === "object" && value !== null && "range" in value && Array.isArray(value.range) && value.range.length === 2 && typeof value.range[0] === "number" && typeof value.range[1] === "number";
36340
+ }
36341
+ function buildToConstImportFix(fixer, sourceCode, analysis, localName) {
36342
+ const importSpecifier = localName === "toConst" ? "toConst" : `toConst as ${localName}`;
36343
+ const runtimeImports = getRuntimeImportStatements(sourceCode.ast);
36344
+ const importToAugment = analysis.importToAugment;
36345
+ if (importToAugment) {
36346
+ const namedSpecifiers = importToAugment.specifiers.filter(
36347
+ (specifier) => specifier.type === "ImportSpecifier"
36348
+ );
36349
+ if (namedSpecifiers.length > 0) {
36350
+ const lastNamedSpecifier = namedSpecifiers.at(-1);
36351
+ if (lastNamedSpecifier && hasRange(lastNamedSpecifier)) {
36352
+ return fixer.insertTextAfterRange(
36353
+ [lastNamedSpecifier.range[0], lastNamedSpecifier.range[1]],
36354
+ `, ${importSpecifier}`
36355
+ );
36356
+ }
36357
+ }
36358
+ const defaultSpecifier = importToAugment.specifiers.find(
36359
+ (specifier) => specifier.type === "ImportDefaultSpecifier"
36360
+ );
36361
+ if (defaultSpecifier && hasRange(defaultSpecifier)) {
36362
+ return fixer.insertTextAfterRange(
36363
+ [defaultSpecifier.range[0], defaultSpecifier.range[1]],
36364
+ `, { ${importSpecifier} }`
36365
+ );
36366
+ }
36367
+ }
36368
+ const importStatement = `import { ${importSpecifier} } from '${TO_CONST_MODULE}';
36369
+ `;
36370
+ const lastImport = runtimeImports.at(-1);
36371
+ if (lastImport && hasRange(lastImport)) {
36372
+ return fixer.insertTextAfterRange(
36373
+ [lastImport.range[0], lastImport.range[1]],
36374
+ `
36375
+ ${importStatement}`
36376
+ );
36377
+ }
36378
+ if (isProgramLike2(sourceCode.ast)) {
36379
+ const firstStatement = sourceCode.ast.body[0];
36380
+ if (firstStatement && hasRange(firstStatement)) {
36381
+ return fixer.insertTextBeforeRange(
36382
+ [firstStatement.range[0], firstStatement.range[0]],
36383
+ importStatement
36384
+ );
36385
+ }
36386
+ }
36387
+ return fixer.insertTextAfterRange([0, 0], importStatement);
36388
+ }
35978
36389
  var rule9 = {
36390
+ meta: {
36391
+ type: "problem",
36392
+ docs: {
36393
+ description: "Require module-scoped mutable const values in runtime DSL author source files to use the canonical toConst helper."
36394
+ },
36395
+ schema: [],
36396
+ fixable: "code",
36397
+ messages: {
36398
+ noModuleScopedMutableConst: "Module-scoped non-primitive `const` values must use `toConst(...)` so they are deeply immutable across invocations.",
36399
+ noModuleScopedMutableConstNoFix: "Module-scoped non-primitive `const` values must use `toConst(...)` or be refactored away from module scope."
36400
+ }
36401
+ },
36402
+ create(context) {
36403
+ const filename = context.filename;
36404
+ if (filename.endsWith(".d.ts") || !isRuntimeDslAuthorSourceFile(filename)) {
36405
+ return {};
36406
+ }
36407
+ const sourceCode = context.sourceCode;
36408
+ if (!isSourceCodeLike(sourceCode)) {
36409
+ return {};
36410
+ }
36411
+ const analysis = analyzeToConstImports(sourceCode.ast);
36412
+ const toConstImportLocalName = getToConstImportLocalName(sourceCode, analysis);
36413
+ const toConstCallText = toConstImportLocalName ?? getToConstCallText(analysis);
36414
+ return {
36415
+ VariableDeclaration(node) {
36416
+ if (isAmbientDeclaration2(node) || !isModuleScopedVariableKind(node, "const")) {
36417
+ return;
36418
+ }
36419
+ for (const declarator of getVariableDeclarators(node)) {
36420
+ const init = declarator.init;
36421
+ if (!init) {
36422
+ continue;
36423
+ }
36424
+ const initializerKind = classifyModuleScopedConstInitializer(
36425
+ sourceCode,
36426
+ init,
36427
+ analysis
36428
+ );
36429
+ if (initializerKind === "primitive" || initializerKind === "wrapped-to-const") {
36430
+ continue;
36431
+ }
36432
+ if (initializerKind === "fixable-mutable-literal") {
36433
+ context.report({
36434
+ node: declarator,
36435
+ messageId: "noModuleScopedMutableConst",
36436
+ fix(fixer) {
36437
+ if (!hasRange(init)) {
36438
+ return null;
36439
+ }
36440
+ const initializerText = context.sourceCode.text.slice(
36441
+ init.range[0],
36442
+ init.range[1]
36443
+ );
36444
+ const fixes = [
36445
+ fixer.replaceTextRange(
36446
+ [init.range[0], init.range[1]],
36447
+ `${toConstCallText}(${initializerText})`
36448
+ )
36449
+ ];
36450
+ if (toConstImportLocalName) {
36451
+ fixes.push(
36452
+ buildToConstImportFix(
36453
+ fixer,
36454
+ sourceCode,
36455
+ analysis,
36456
+ toConstImportLocalName
36457
+ )
36458
+ );
36459
+ }
36460
+ return fixes;
36461
+ }
36462
+ });
36463
+ continue;
36464
+ }
36465
+ context.report({
36466
+ node: declarator,
36467
+ messageId: "noModuleScopedMutableConstNoFix"
36468
+ });
36469
+ }
36470
+ }
36471
+ };
36472
+ }
36473
+ };
36474
+ var no_module_scoped_mutable_const_default = rule9;
36475
+
36476
+ // src/dsl-rules/no-module-scoped-var.ts
36477
+ function isAmbientDeclaration3(node) {
36478
+ return "declare" in node && node.declare;
36479
+ }
36480
+ var rule10 = {
35979
36481
  meta: {
35980
36482
  type: "problem",
35981
36483
  docs: {
@@ -35993,7 +36495,7 @@ var rule9 = {
35993
36495
  }
35994
36496
  return {
35995
36497
  VariableDeclaration(node) {
35996
- if (!isAmbientDeclaration2(node) && isModuleScopedVariableKind(node, "var")) {
36498
+ if (!isAmbientDeclaration3(node) && isModuleScopedVariableKind(node, "var")) {
35997
36499
  context.report({
35998
36500
  node,
35999
36501
  messageId: "noModuleScopedVar"
@@ -36003,7 +36505,7 @@ var rule9 = {
36003
36505
  };
36004
36506
  }
36005
36507
  };
36006
- var no_module_scoped_var_default = rule9;
36508
+ var no_module_scoped_var_default = rule10;
36007
36509
 
36008
36510
  // src/dsl-rules/no-non-public-instance-fields.ts
36009
36511
  var import_typescript16 = __toESM(require("typescript"), 1);
@@ -36066,7 +36568,7 @@ function getRuntimeManagedClassNode(checker, sourceFile, fileName) {
36066
36568
  }
36067
36569
  return void 0;
36068
36570
  }
36069
- var rule10 = {
36571
+ var rule11 = {
36070
36572
  meta: {
36071
36573
  type: "problem",
36072
36574
  docs: {
@@ -36108,11 +36610,12 @@ var rule10 = {
36108
36610
  };
36109
36611
  }
36110
36612
  };
36111
- var no_non_public_instance_fields_default = rule10;
36613
+ var no_non_public_instance_fields_default = rule11;
36112
36614
 
36113
36615
  // src/dsl-rules/index.ts
36114
36616
  var dslRules = {
36115
36617
  "no-module-scoped-let": no_module_scoped_let_default,
36618
+ "no-module-scoped-mutable-const": no_module_scoped_mutable_const_default,
36116
36619
  "no-module-scoped-var": no_module_scoped_var_default,
36117
36620
  "no-non-public-instance-fields": no_non_public_instance_fields_default
36118
36621
  };
@@ -36143,7 +36646,7 @@ function getConstructors(node) {
36143
36646
  (member) => import_typescript17.default.isConstructorDeclaration(member) && member.body !== void 0
36144
36647
  );
36145
36648
  }
36146
- var rule11 = {
36649
+ var rule12 = {
36147
36650
  meta: {
36148
36651
  type: "problem",
36149
36652
  docs: {
@@ -36193,7 +36696,7 @@ var rule11 = {
36193
36696
  };
36194
36697
  }
36195
36698
  };
36196
- var no_custom_constructor_default = rule11;
36699
+ var no_custom_constructor_default = rule12;
36197
36700
 
36198
36701
  // src/extensibility-rules/no-extra-type-params.ts
36199
36702
  var import_typescript18 = __toESM(require("typescript"), 1);
@@ -36228,7 +36731,7 @@ function isSoleTypeParameterUsedForFieldsType(checker, node) {
36228
36731
  const fieldsTypeSymbol = getTypeSymbol(getBaseObjectFieldsType(checker, node)?.type);
36229
36732
  return typeParameterSymbol !== void 0 && fieldsTypeSymbol === typeParameterSymbol;
36230
36733
  }
36231
- var rule12 = {
36734
+ var rule13 = {
36232
36735
  meta: {
36233
36736
  type: "problem",
36234
36737
  docs: {
@@ -36306,7 +36809,7 @@ var rule12 = {
36306
36809
  };
36307
36810
  }
36308
36811
  };
36309
- var no_extra_type_params_default = rule12;
36812
+ var no_extra_type_params_default = rule13;
36310
36813
 
36311
36814
  // src/extensibility-rules/no-public-instance-fields.ts
36312
36815
  var import_typescript19 = __toESM(require("typescript"), 1);
@@ -36340,7 +36843,7 @@ function getConstructors2(node) {
36340
36843
  (member) => import_typescript19.default.isConstructorDeclaration(member) && member.body !== void 0
36341
36844
  );
36342
36845
  }
36343
- var rule13 = {
36846
+ var rule14 = {
36344
36847
  meta: {
36345
36848
  type: "problem",
36346
36849
  docs: {
@@ -36409,7 +36912,7 @@ var rule13 = {
36409
36912
  };
36410
36913
  }
36411
36914
  };
36412
- var no_public_instance_fields_default = rule13;
36915
+ var no_public_instance_fields_default = rule14;
36413
36916
 
36414
36917
  // src/extensibility-rules/prefer-es-private.ts
36415
36918
  var import_typescript20 = __toESM(require("typescript"), 1);
@@ -36518,7 +37021,7 @@ function getAutofix(method, classNode) {
36518
37021
  ];
36519
37022
  };
36520
37023
  }
36521
- var rule14 = {
37024
+ var rule15 = {
36522
37025
  meta: {
36523
37026
  type: "suggestion",
36524
37027
  fixable: "code",
@@ -36576,7 +37079,7 @@ var rule14 = {
36576
37079
  };
36577
37080
  }
36578
37081
  };
36579
- var prefer_es_private_default = rule14;
37082
+ var prefer_es_private_default = rule15;
36580
37083
 
36581
37084
  // src/extensibility-rules/index.ts
36582
37085
  var extensibilityRules = {
@@ -36814,7 +37317,7 @@ function reportExplicitApiNameIssues(context, node) {
36814
37317
  });
36815
37318
  }
36816
37319
  }
36817
- var rule15 = {
37320
+ var rule16 = {
36818
37321
  meta: {
36819
37322
  type: "problem",
36820
37323
  docs: {
@@ -36859,7 +37362,7 @@ var rule15 = {
36859
37362
  };
36860
37363
  }
36861
37364
  };
36862
- var valid_api_name_default = rule15;
37365
+ var valid_api_name_default = rule16;
36863
37366
 
36864
37367
  // src/naming-rules/index.ts
36865
37368
  var namingRules = {
@@ -36882,7 +37385,7 @@ var noSecretsOptions = {
36882
37385
  "Stripe Webhook Secret": "whsec_[a-zA-Z0-9+/=]{20,}"
36883
37386
  }
36884
37387
  };
36885
- var rule16 = {
37388
+ var rule17 = {
36886
37389
  ...originalRule,
36887
37390
  meta: {
36888
37391
  ...originalRule.meta,
@@ -36892,7 +37395,7 @@ var rule16 = {
36892
37395
  }
36893
37396
  }
36894
37397
  };
36895
- var no_secrets_default = rule16;
37398
+ var no_secrets_default = rule17;
36896
37399
 
36897
37400
  // src/internal/analysis/apps/manifest-tools.ts
36898
37401
  var import_yaml2 = require("yaml");
@@ -36980,7 +37483,7 @@ function isObjectExpression(node) {
36980
37483
  function isProperty(node) {
36981
37484
  return node.type === "Property";
36982
37485
  }
36983
- function isIdentifier10(node) {
37486
+ function isIdentifier11(node) {
36984
37487
  return node.type === "Identifier";
36985
37488
  }
36986
37489
  function isLiteral(node) {
@@ -36997,7 +37500,7 @@ function getStringProperty(obj, name, sourceCode, scopeNode) {
36997
37500
  if (!isProperty(prop)) {
36998
37501
  continue;
36999
37502
  }
37000
- const keyName = isIdentifier10(prop.key) && prop.key.name || isLiteral(prop.key) && prop.key.value;
37503
+ const keyName = isIdentifier11(prop.key) && prop.key.name || isLiteral(prop.key) && prop.key.value;
37001
37504
  if (keyName !== name) {
37002
37505
  continue;
37003
37506
  }
@@ -37007,7 +37510,7 @@ function getStringProperty(obj, name, sourceCode, scopeNode) {
37007
37510
  node: prop.value
37008
37511
  };
37009
37512
  }
37010
- if (isIdentifier10(prop.value)) {
37513
+ if (isIdentifier11(prop.value)) {
37011
37514
  const varName = prop.value.name;
37012
37515
  let scope = sourceCode.getScope(scopeNode);
37013
37516
  while (scope) {
@@ -37026,7 +37529,7 @@ function getStringProperty(obj, name, sourceCode, scopeNode) {
37026
37529
  }
37027
37530
  return void 0;
37028
37531
  }
37029
- var rule17 = {
37532
+ var rule18 = {
37030
37533
  meta: {
37031
37534
  type: "problem",
37032
37535
  docs: {
@@ -37068,7 +37571,7 @@ var rule17 = {
37068
37571
  };
37069
37572
  }
37070
37573
  };
37071
- var valid_endpoint_id_default = rule17;
37574
+ var valid_endpoint_id_default = rule18;
37072
37575
 
37073
37576
  // src/security-rules/valid-extension-interface.ts
37074
37577
  var path4 = __toESM(require("path"), 1);
@@ -37112,7 +37615,7 @@ function resolveExtensionTarget(context) {
37112
37615
  }
37113
37616
  return { interfaceId: extensionForFile.interface_id, expectedInterfaceName };
37114
37617
  }
37115
- var rule18 = {
37618
+ var rule19 = {
37116
37619
  meta: {
37117
37620
  type: "problem",
37118
37621
  docs: {
@@ -37142,9 +37645,9 @@ var rule18 = {
37142
37645
  if (!sourceFile) {
37143
37646
  return;
37144
37647
  }
37648
+ const sourceCode = context.sourceCode;
37145
37649
  const classDeclaration = getDefaultExportedClassDeclaration(sourceFile);
37146
37650
  if (!classDeclaration) {
37147
- const sourceCode = context.sourceCode;
37148
37651
  const firstToken = sourceCode.getFirstToken(sourceCode.ast);
37149
37652
  context.report({
37150
37653
  node: firstToken ?? sourceCode.ast,
@@ -37162,21 +37665,25 @@ var rule18 = {
37162
37665
  ({ interfaceSymbol }) => symbolMatchesExtensionInterface(checker, interfaceSymbol)
37163
37666
  );
37164
37667
  if (sdkInterfaces.length === 0) {
37668
+ const highlightNode = classDeclaration.name ?? implementedTypes[0]?.heritageType.expression;
37165
37669
  context.report({
37166
- loc: toReportLoc(classDeclaration),
37670
+ ...highlightNode ? { loc: toReportLoc(highlightNode) } : { node: sourceCode.getFirstToken(sourceCode.ast) ?? sourceCode.ast },
37167
37671
  messageId: "MISSING_SDK_INTERFACE",
37168
37672
  data: { expectedInterfaceName, interfaceId }
37169
37673
  });
37170
37674
  return;
37171
37675
  }
37172
- const matchesExpected = sdkInterfaces.some(({ interfaceSymbol }) => {
37173
- const resolvedName = interfaceSymbol?.getName();
37174
- return resolvedName === expectedInterfaceName;
37175
- });
37676
+ const matchesExpected = sdkInterfaces.some(
37677
+ ({ interfaceSymbol }) => interfaceSymbol?.getName().startsWith(expectedInterfaceName) ?? false
37678
+ );
37176
37679
  if (!matchesExpected) {
37680
+ const firstMismatch = sdkInterfaces[0];
37681
+ if (!firstMismatch) {
37682
+ return;
37683
+ }
37177
37684
  const actualNames = sdkInterfaces.map(({ interfaceSymbol }) => interfaceSymbol?.getName() ?? "(unknown)").join(", ");
37178
37685
  context.report({
37179
- loc: toReportLoc(classDeclaration),
37686
+ loc: toReportLoc(firstMismatch.heritageType.expression),
37180
37687
  messageId: "WRONG_INTERFACE",
37181
37688
  data: {
37182
37689
  actualName: actualNames,
@@ -37192,16 +37699,16 @@ var rule18 = {
37192
37699
  };
37193
37700
  }
37194
37701
  };
37195
- var valid_extension_interface_default = rule18;
37702
+ var valid_extension_interface_default = rule19;
37196
37703
 
37197
37704
  // src/security-rules/index.ts
37198
37705
  var security = require_eslint_plugin_security();
37199
37706
  function requireRule(rules2, name, pluginName) {
37200
- const rule19 = rules2[name];
37201
- if (!rule19) {
37707
+ const rule20 = rules2[name];
37708
+ if (!rule20) {
37202
37709
  throw new Error(`Expected rule '${name}' not found in ${pluginName}`);
37203
37710
  }
37204
- return rule19;
37711
+ return rule20;
37205
37712
  }
37206
37713
  var securityRules = {
37207
37714
  "detect-bidi-characters": requireRule(