@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.js CHANGED
@@ -3268,7 +3268,7 @@ var require_RuleCreator = __commonJS({
3268
3268
  exports.RuleCreator = RuleCreator;
3269
3269
  var applyDefault_1 = require_applyDefault();
3270
3270
  function RuleCreator(urlCreator) {
3271
- return function createNamedRule({ meta: meta2, name, ...rule19 }) {
3271
+ return function createNamedRule({ meta: meta2, name, ...rule20 }) {
3272
3272
  const ruleWithDocs = createRule23({
3273
3273
  meta: {
3274
3274
  ...meta2,
@@ -3278,7 +3278,7 @@ var require_RuleCreator = __commonJS({
3278
3278
  }
3279
3279
  },
3280
3280
  name,
3281
- ...rule19
3281
+ ...rule20
3282
3282
  });
3283
3283
  return ruleWithDocs;
3284
3284
  };
@@ -35887,9 +35887,73 @@ var customObjectRules = {
35887
35887
  };
35888
35888
 
35889
35889
  // src/internal/analysis/eslint/module-scope.ts
35890
+ var TO_CONST_MODULE = "@stripe/extensibility-sdk";
35891
+ var KNOWN_GLOBAL_PRIMITIVES = /* @__PURE__ */ new Set(["undefined", "Infinity", "NaN"]);
35892
+ var COMPARISON_OPERATORS = /* @__PURE__ */ new Set([
35893
+ "==",
35894
+ "!=",
35895
+ "===",
35896
+ "!==",
35897
+ "<",
35898
+ "<=",
35899
+ ">",
35900
+ ">=",
35901
+ "in",
35902
+ "instanceof"
35903
+ ]);
35904
+ var ARITHMETIC_OPERATORS = /* @__PURE__ */ new Set([
35905
+ "+",
35906
+ "-",
35907
+ "*",
35908
+ "/",
35909
+ "%",
35910
+ "**",
35911
+ "|",
35912
+ "&",
35913
+ "^",
35914
+ "<<",
35915
+ ">>",
35916
+ ">>>"
35917
+ ]);
35918
+ function isIdentifier10(node) {
35919
+ return isNodeLike(node) && node.type === "Identifier";
35920
+ }
35921
+ function isNodeLike(value) {
35922
+ return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
35923
+ }
35924
+ function isTransparentExpressionLike(node) {
35925
+ return (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSTypeAssertion" || node.type === "TSNonNullExpression" || node.type === "ParenthesizedExpression") && "expression" in node;
35926
+ }
35927
+ function isTemplateLiteralLike(node) {
35928
+ return node.type === "TemplateLiteral" && "expressions" in node && Array.isArray(node.expressions);
35929
+ }
35930
+ function isUnaryExpressionLike(node) {
35931
+ return node.type === "UnaryExpression" && "operator" in node && typeof node.operator === "string" && "argument" in node;
35932
+ }
35933
+ function isBinaryExpressionLike(node) {
35934
+ return node.type === "BinaryExpression" && "operator" in node && typeof node.operator === "string" && "left" in node && "right" in node;
35935
+ }
35936
+ function isLogicalExpressionLike(node) {
35937
+ return node.type === "LogicalExpression" && "left" in node && "right" in node;
35938
+ }
35939
+ function isConditionalExpressionLike(node) {
35940
+ return node.type === "ConditionalExpression" && "consequent" in node && "alternate" in node;
35941
+ }
35942
+ function isSequenceExpressionLike(node) {
35943
+ return node.type === "SequenceExpression" && "expressions" in node && Array.isArray(node.expressions);
35944
+ }
35945
+ function isMemberExpressionLike2(node) {
35946
+ return node.type === "MemberExpression" && "object" in node && "property" in node && "computed" in node && typeof node.computed === "boolean";
35947
+ }
35890
35948
  function isTopLevelExport(node) {
35891
35949
  return node?.type === "ExportNamedDeclaration" && node.parent?.type === "Program";
35892
35950
  }
35951
+ function isProgramLike2(value) {
35952
+ return isNodeLike(value) && value.type === "Program" && "body" in value && Array.isArray(value.body);
35953
+ }
35954
+ function isCallExpressionLike2(node) {
35955
+ return node?.type === "CallExpression" && "callee" in node && isNodeLike(node.callee);
35956
+ }
35893
35957
  function isVarScopeBoundary(node) {
35894
35958
  return node?.type === "FunctionDeclaration" || node?.type === "FunctionExpression" || node?.type === "ArrowFunctionExpression" || node?.type === "StaticBlock";
35895
35959
  }
@@ -35924,6 +35988,290 @@ function isModuleScopedVariableKind(node, kind) {
35924
35988
  }
35925
35989
  return kind === "var" ? isVarHoistedToModuleScope(node) : isModuleScopedVariableDeclaration(node);
35926
35990
  }
35991
+ function unwrapTransparentExpression(node) {
35992
+ if (!isNodeLike(node)) {
35993
+ return void 0;
35994
+ }
35995
+ if (isTransparentExpressionLike(node)) {
35996
+ return unwrapTransparentExpression(node.expression);
35997
+ }
35998
+ return node;
35999
+ }
36000
+ function isPrimitiveLiteral(node) {
36001
+ 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");
36002
+ }
36003
+ function isScopeReferenceToIdentifier(scope, node) {
36004
+ let current = scope;
36005
+ while (current) {
36006
+ for (const reference of current.references ?? []) {
36007
+ if (reference.identifier === node) {
36008
+ return reference;
36009
+ }
36010
+ }
36011
+ for (const reference of current.through ?? []) {
36012
+ if (reference.identifier === node) {
36013
+ return reference;
36014
+ }
36015
+ }
36016
+ current = current.upper ?? void 0;
36017
+ }
36018
+ return void 0;
36019
+ }
36020
+ function isKnownGlobalPrimitiveIdentifier(sourceCode, node) {
36021
+ if (!KNOWN_GLOBAL_PRIMITIVES.has(node.name)) {
36022
+ return false;
36023
+ }
36024
+ const reference = isScopeReferenceToIdentifier(sourceCode.getScope(node), node);
36025
+ if (!reference) {
36026
+ return false;
36027
+ }
36028
+ return !reference.resolved || (reference.resolved.defs?.length ?? 0) === 0;
36029
+ }
36030
+ function isPrimitiveValueExpression(sourceCode, node) {
36031
+ const expression = unwrapTransparentExpression(node);
36032
+ if (!expression) {
36033
+ return false;
36034
+ }
36035
+ if (isPrimitiveLiteral(expression)) {
36036
+ return true;
36037
+ }
36038
+ if (isIdentifier10(expression)) {
36039
+ return isKnownGlobalPrimitiveIdentifier(sourceCode, expression);
36040
+ }
36041
+ if (isTemplateLiteralLike(expression)) {
36042
+ return expression.expressions.every(
36043
+ (part) => isPrimitiveValueExpression(sourceCode, part)
36044
+ );
36045
+ }
36046
+ if (isUnaryExpressionLike(expression)) {
36047
+ if (expression.operator === "void" || expression.operator === "typeof" || expression.operator === "!") {
36048
+ return true;
36049
+ }
36050
+ return (expression.operator === "+" || expression.operator === "-" || expression.operator === "~") && isPrimitiveValueExpression(sourceCode, expression.argument);
36051
+ }
36052
+ if (isBinaryExpressionLike(expression)) {
36053
+ if (COMPARISON_OPERATORS.has(expression.operator)) {
36054
+ return true;
36055
+ }
36056
+ return ARITHMETIC_OPERATORS.has(expression.operator) && isPrimitiveValueExpression(sourceCode, expression.left) && isPrimitiveValueExpression(sourceCode, expression.right);
36057
+ }
36058
+ if (isLogicalExpressionLike(expression)) {
36059
+ return isPrimitiveValueExpression(sourceCode, expression.left) && isPrimitiveValueExpression(sourceCode, expression.right);
36060
+ }
36061
+ if (isConditionalExpressionLike(expression)) {
36062
+ return isPrimitiveValueExpression(sourceCode, expression.consequent) && isPrimitiveValueExpression(sourceCode, expression.alternate);
36063
+ }
36064
+ if (isSequenceExpressionLike(expression)) {
36065
+ const finalExpression = expression.expressions.at(-1);
36066
+ return isPrimitiveValueExpression(sourceCode, finalExpression);
36067
+ }
36068
+ return false;
36069
+ }
36070
+ function isImportDeclarationLike2(node) {
36071
+ return node.type === "ImportDeclaration";
36072
+ }
36073
+ function isRuntimeImportDeclaration(node) {
36074
+ return node.importKind !== "type";
36075
+ }
36076
+ function isToConstNamedSpecifier(specifier) {
36077
+ return specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && isIdentifier10(specifier.imported) && specifier.imported.name === "toConst" && isIdentifier10(specifier.local);
36078
+ }
36079
+ function getToConstNamedLocalName(specifier) {
36080
+ return isToConstNamedSpecifier(specifier) ? specifier.local?.name : void 0;
36081
+ }
36082
+ function createToConstImportAnalysis(namedLocalNames, namespaceLocalNames, importToAugment) {
36083
+ return importToAugment ? {
36084
+ namedLocalNames,
36085
+ namespaceLocalNames,
36086
+ importToAugment
36087
+ } : {
36088
+ namedLocalNames,
36089
+ namespaceLocalNames
36090
+ };
36091
+ }
36092
+ function analyzeToConstImports(program) {
36093
+ const namedLocalNames = /* @__PURE__ */ new Set();
36094
+ const namespaceLocalNames = /* @__PURE__ */ new Set();
36095
+ let importToAugment;
36096
+ if (!isProgramLike2(program)) {
36097
+ return createToConstImportAnalysis(namedLocalNames, namespaceLocalNames);
36098
+ }
36099
+ for (const statement of program.body) {
36100
+ if (!isImportDeclarationLike2(statement)) {
36101
+ continue;
36102
+ }
36103
+ if (statement.source.value !== TO_CONST_MODULE) {
36104
+ continue;
36105
+ }
36106
+ for (const specifier of statement.specifiers) {
36107
+ if (specifier.type === "ImportNamespaceSpecifier" && isRuntimeImportDeclaration(statement) && isIdentifier10(specifier.local)) {
36108
+ namespaceLocalNames.add(specifier.local.name);
36109
+ }
36110
+ const toConstLocalName = getToConstNamedLocalName(specifier);
36111
+ if (toConstLocalName) {
36112
+ namedLocalNames.add(toConstLocalName);
36113
+ }
36114
+ }
36115
+ if (!importToAugment && isRuntimeImportDeclaration(statement) && !statement.specifiers.some(
36116
+ (specifier) => specifier.type === "ImportNamespaceSpecifier"
36117
+ )) {
36118
+ importToAugment = statement;
36119
+ }
36120
+ }
36121
+ return createToConstImportAnalysis(
36122
+ namedLocalNames,
36123
+ namespaceLocalNames,
36124
+ importToAugment
36125
+ );
36126
+ }
36127
+ function isToConstMemberAccess(callee, namespaceLocalNames) {
36128
+ if (!isMemberExpressionLike2(callee) || !isNodeLike(callee.object) || !isIdentifier10(callee.object) || !namespaceLocalNames.has(callee.object.name)) {
36129
+ return false;
36130
+ }
36131
+ return callee.computed ? isLiteralLike(callee.property) && callee.property.value === "toConst" : isNodeLike(callee.property) && isIdentifier10(callee.property) && callee.property.name === "toConst";
36132
+ }
36133
+ function isLiteralLike(node) {
36134
+ return isNodeLike(node) && node.type === "Literal";
36135
+ }
36136
+ function isCanonicalToConstCall(node, analysis) {
36137
+ const expression = unwrapTransparentExpression(node);
36138
+ if (!expression || !isCallExpressionLike2(expression)) {
36139
+ return false;
36140
+ }
36141
+ if (isIdentifier10(expression.callee) && analysis.namedLocalNames.has(expression.callee.name)) {
36142
+ return true;
36143
+ }
36144
+ return isToConstMemberAccess(expression.callee, analysis.namespaceLocalNames);
36145
+ }
36146
+ function isFixableMutableConst(node) {
36147
+ const expression = unwrapTransparentExpression(node);
36148
+ return expression?.type === "ObjectExpression" || expression?.type === "ArrayExpression";
36149
+ }
36150
+ function classifyModuleScopedConstInitializer(sourceCode, node, analysis) {
36151
+ if (isPrimitiveValueExpression(sourceCode, node)) {
36152
+ return "primitive";
36153
+ }
36154
+ if (isCanonicalToConstCall(node, analysis)) {
36155
+ return "wrapped-to-const";
36156
+ }
36157
+ if (isFixableMutableConst(node)) {
36158
+ return "fixable-mutable-literal";
36159
+ }
36160
+ return "other";
36161
+ }
36162
+ function getModuleScopeBindingNames(sourceCode) {
36163
+ const bindingNames = /* @__PURE__ */ new Set();
36164
+ if (!isProgramLike2(sourceCode.ast)) {
36165
+ return bindingNames;
36166
+ }
36167
+ for (const statement of sourceCode.ast.body) {
36168
+ collectModuleScopeBindingNames(statement, bindingNames);
36169
+ }
36170
+ return bindingNames;
36171
+ }
36172
+ function collectModuleScopeBindingNames(node, bindingNames) {
36173
+ if (!isNodeLike(node)) {
36174
+ return;
36175
+ }
36176
+ if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") {
36177
+ if ("declaration" in node) {
36178
+ collectModuleScopeBindingNames(node.declaration, bindingNames);
36179
+ }
36180
+ return;
36181
+ }
36182
+ if (node.type === "ImportDeclaration" && "specifiers" in node && Array.isArray(node.specifiers)) {
36183
+ for (const specifier of node.specifiers) {
36184
+ const local = isNodeLike(specifier) && "local" in specifier ? specifier.local : void 0;
36185
+ if (isIdentifier10(local)) {
36186
+ bindingNames.add(local.name);
36187
+ }
36188
+ }
36189
+ return;
36190
+ }
36191
+ if (node.type === "VariableDeclaration" && "declarations" in node && Array.isArray(node.declarations)) {
36192
+ for (const declaration of node.declarations) {
36193
+ if (isNodeLike(declaration) && "id" in declaration) {
36194
+ collectPatternBindingNames(declaration.id, bindingNames);
36195
+ }
36196
+ }
36197
+ return;
36198
+ }
36199
+ if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" || node.type === "TSEnumDeclaration") {
36200
+ const declarationId = "id" in node ? node.id : void 0;
36201
+ if (isIdentifier10(declarationId)) {
36202
+ bindingNames.add(declarationId.name);
36203
+ }
36204
+ }
36205
+ }
36206
+ function collectPatternBindingNames(node, bindingNames) {
36207
+ if (!node || !isNodeLike(node)) {
36208
+ return;
36209
+ }
36210
+ if (isIdentifier10(node)) {
36211
+ bindingNames.add(node.name);
36212
+ return;
36213
+ }
36214
+ if (node.type === "RestElement" && "argument" in node) {
36215
+ collectPatternBindingNames(node.argument, bindingNames);
36216
+ return;
36217
+ }
36218
+ if (node.type === "AssignmentPattern" && "left" in node) {
36219
+ collectPatternBindingNames(node.left, bindingNames);
36220
+ return;
36221
+ }
36222
+ if (node.type === "ArrayPattern" && "elements" in node && Array.isArray(node.elements)) {
36223
+ for (const element of node.elements) {
36224
+ collectPatternBindingNames(element, bindingNames);
36225
+ }
36226
+ return;
36227
+ }
36228
+ if (node.type === "ObjectPattern" && "properties" in node && Array.isArray(node.properties)) {
36229
+ for (const property of node.properties) {
36230
+ if (!isNodeLike(property)) {
36231
+ continue;
36232
+ }
36233
+ if (property.type === "Property" && "value" in property) {
36234
+ collectPatternBindingNames(property.value, bindingNames);
36235
+ continue;
36236
+ }
36237
+ if (property.type === "RestElement" && "argument" in property) {
36238
+ collectPatternBindingNames(property.argument, bindingNames);
36239
+ }
36240
+ }
36241
+ }
36242
+ }
36243
+ function getUniqueBindingName(bindingNames, preferredName) {
36244
+ if (!bindingNames.has(preferredName)) {
36245
+ return preferredName;
36246
+ }
36247
+ let suffix = 1;
36248
+ let candidate = `${preferredName}${String(suffix)}`;
36249
+ while (bindingNames.has(candidate)) {
36250
+ suffix += 1;
36251
+ candidate = `${preferredName}${String(suffix)}`;
36252
+ }
36253
+ return candidate;
36254
+ }
36255
+ function getToConstImportLocalName(sourceCode, analysis) {
36256
+ if (analysis.namedLocalNames.size > 0 || analysis.namespaceLocalNames.size > 0) {
36257
+ return void 0;
36258
+ }
36259
+ return getUniqueBindingName(getModuleScopeBindingNames(sourceCode), "toConst");
36260
+ }
36261
+ function getToConstCallText(analysis) {
36262
+ const [namespaceName] = analysis.namespaceLocalNames;
36263
+ if (namespaceName) {
36264
+ return `${namespaceName}.toConst`;
36265
+ }
36266
+ const [localName] = analysis.namedLocalNames;
36267
+ return localName ?? "toConst";
36268
+ }
36269
+ function getRuntimeImportStatements(program) {
36270
+ if (!isProgramLike2(program)) {
36271
+ return [];
36272
+ }
36273
+ return program.body.filter(isImportDeclarationLike2);
36274
+ }
35927
36275
 
35928
36276
  // src/dsl-rules/no-module-scoped-let.ts
35929
36277
  function isAmbientDeclaration(node) {
@@ -35959,11 +36307,165 @@ var rule8 = {
35959
36307
  };
35960
36308
  var no_module_scoped_let_default = rule8;
35961
36309
 
35962
- // src/dsl-rules/no-module-scoped-var.ts
36310
+ // src/dsl-rules/no-module-scoped-mutable-const.ts
35963
36311
  function isAmbientDeclaration2(node) {
35964
36312
  return "declare" in node && node.declare;
35965
36313
  }
36314
+ function isSourceCodeLike(value) {
36315
+ return typeof value === "object" && value !== null && "ast" in value && "getText" in value && typeof value.getText === "function" && "getScope" in value && typeof value.getScope === "function";
36316
+ }
36317
+ function isVariableDeclaratorLike(node) {
36318
+ return typeof node === "object" && node !== null && "type" in node && node.type === "VariableDeclarator";
36319
+ }
36320
+ function getVariableDeclarators(node) {
36321
+ if (!("declarations" in node) || !Array.isArray(node.declarations)) {
36322
+ return [];
36323
+ }
36324
+ return node.declarations.filter(isVariableDeclaratorLike);
36325
+ }
36326
+ function hasRange(value) {
36327
+ 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";
36328
+ }
36329
+ function buildToConstImportFix(fixer, sourceCode, analysis, localName) {
36330
+ const importSpecifier = localName === "toConst" ? "toConst" : `toConst as ${localName}`;
36331
+ const runtimeImports = getRuntimeImportStatements(sourceCode.ast);
36332
+ const importToAugment = analysis.importToAugment;
36333
+ if (importToAugment) {
36334
+ const namedSpecifiers = importToAugment.specifiers.filter(
36335
+ (specifier) => specifier.type === "ImportSpecifier"
36336
+ );
36337
+ if (namedSpecifiers.length > 0) {
36338
+ const lastNamedSpecifier = namedSpecifiers.at(-1);
36339
+ if (lastNamedSpecifier && hasRange(lastNamedSpecifier)) {
36340
+ return fixer.insertTextAfterRange(
36341
+ [lastNamedSpecifier.range[0], lastNamedSpecifier.range[1]],
36342
+ `, ${importSpecifier}`
36343
+ );
36344
+ }
36345
+ }
36346
+ const defaultSpecifier = importToAugment.specifiers.find(
36347
+ (specifier) => specifier.type === "ImportDefaultSpecifier"
36348
+ );
36349
+ if (defaultSpecifier && hasRange(defaultSpecifier)) {
36350
+ return fixer.insertTextAfterRange(
36351
+ [defaultSpecifier.range[0], defaultSpecifier.range[1]],
36352
+ `, { ${importSpecifier} }`
36353
+ );
36354
+ }
36355
+ }
36356
+ const importStatement = `import { ${importSpecifier} } from '${TO_CONST_MODULE}';
36357
+ `;
36358
+ const lastImport = runtimeImports.at(-1);
36359
+ if (lastImport && hasRange(lastImport)) {
36360
+ return fixer.insertTextAfterRange(
36361
+ [lastImport.range[0], lastImport.range[1]],
36362
+ `
36363
+ ${importStatement}`
36364
+ );
36365
+ }
36366
+ if (isProgramLike2(sourceCode.ast)) {
36367
+ const firstStatement = sourceCode.ast.body[0];
36368
+ if (firstStatement && hasRange(firstStatement)) {
36369
+ return fixer.insertTextBeforeRange(
36370
+ [firstStatement.range[0], firstStatement.range[0]],
36371
+ importStatement
36372
+ );
36373
+ }
36374
+ }
36375
+ return fixer.insertTextAfterRange([0, 0], importStatement);
36376
+ }
35966
36377
  var rule9 = {
36378
+ meta: {
36379
+ type: "problem",
36380
+ docs: {
36381
+ description: "Require module-scoped mutable const values in runtime DSL author source files to use the canonical toConst helper."
36382
+ },
36383
+ schema: [],
36384
+ fixable: "code",
36385
+ messages: {
36386
+ noModuleScopedMutableConst: "Module-scoped non-primitive `const` values must use `toConst(...)` so they are deeply immutable across invocations.",
36387
+ noModuleScopedMutableConstNoFix: "Module-scoped non-primitive `const` values must use `toConst(...)` or be refactored away from module scope."
36388
+ }
36389
+ },
36390
+ create(context) {
36391
+ const filename = context.filename;
36392
+ if (filename.endsWith(".d.ts") || !isRuntimeDslAuthorSourceFile(filename)) {
36393
+ return {};
36394
+ }
36395
+ const sourceCode = context.sourceCode;
36396
+ if (!isSourceCodeLike(sourceCode)) {
36397
+ return {};
36398
+ }
36399
+ const analysis = analyzeToConstImports(sourceCode.ast);
36400
+ const toConstImportLocalName = getToConstImportLocalName(sourceCode, analysis);
36401
+ const toConstCallText = toConstImportLocalName ?? getToConstCallText(analysis);
36402
+ return {
36403
+ VariableDeclaration(node) {
36404
+ if (isAmbientDeclaration2(node) || !isModuleScopedVariableKind(node, "const")) {
36405
+ return;
36406
+ }
36407
+ for (const declarator of getVariableDeclarators(node)) {
36408
+ const init = declarator.init;
36409
+ if (!init) {
36410
+ continue;
36411
+ }
36412
+ const initializerKind = classifyModuleScopedConstInitializer(
36413
+ sourceCode,
36414
+ init,
36415
+ analysis
36416
+ );
36417
+ if (initializerKind === "primitive" || initializerKind === "wrapped-to-const") {
36418
+ continue;
36419
+ }
36420
+ if (initializerKind === "fixable-mutable-literal") {
36421
+ context.report({
36422
+ node: declarator,
36423
+ messageId: "noModuleScopedMutableConst",
36424
+ fix(fixer) {
36425
+ if (!hasRange(init)) {
36426
+ return null;
36427
+ }
36428
+ const initializerText = context.sourceCode.text.slice(
36429
+ init.range[0],
36430
+ init.range[1]
36431
+ );
36432
+ const fixes = [
36433
+ fixer.replaceTextRange(
36434
+ [init.range[0], init.range[1]],
36435
+ `${toConstCallText}(${initializerText})`
36436
+ )
36437
+ ];
36438
+ if (toConstImportLocalName) {
36439
+ fixes.push(
36440
+ buildToConstImportFix(
36441
+ fixer,
36442
+ sourceCode,
36443
+ analysis,
36444
+ toConstImportLocalName
36445
+ )
36446
+ );
36447
+ }
36448
+ return fixes;
36449
+ }
36450
+ });
36451
+ continue;
36452
+ }
36453
+ context.report({
36454
+ node: declarator,
36455
+ messageId: "noModuleScopedMutableConstNoFix"
36456
+ });
36457
+ }
36458
+ }
36459
+ };
36460
+ }
36461
+ };
36462
+ var no_module_scoped_mutable_const_default = rule9;
36463
+
36464
+ // src/dsl-rules/no-module-scoped-var.ts
36465
+ function isAmbientDeclaration3(node) {
36466
+ return "declare" in node && node.declare;
36467
+ }
36468
+ var rule10 = {
35967
36469
  meta: {
35968
36470
  type: "problem",
35969
36471
  docs: {
@@ -35981,7 +36483,7 @@ var rule9 = {
35981
36483
  }
35982
36484
  return {
35983
36485
  VariableDeclaration(node) {
35984
- if (!isAmbientDeclaration2(node) && isModuleScopedVariableKind(node, "var")) {
36486
+ if (!isAmbientDeclaration3(node) && isModuleScopedVariableKind(node, "var")) {
35985
36487
  context.report({
35986
36488
  node,
35987
36489
  messageId: "noModuleScopedVar"
@@ -35991,7 +36493,7 @@ var rule9 = {
35991
36493
  };
35992
36494
  }
35993
36495
  };
35994
- var no_module_scoped_var_default = rule9;
36496
+ var no_module_scoped_var_default = rule10;
35995
36497
 
35996
36498
  // src/dsl-rules/no-non-public-instance-fields.ts
35997
36499
  import ts29 from "typescript";
@@ -36054,7 +36556,7 @@ function getRuntimeManagedClassNode(checker, sourceFile, fileName) {
36054
36556
  }
36055
36557
  return void 0;
36056
36558
  }
36057
- var rule10 = {
36559
+ var rule11 = {
36058
36560
  meta: {
36059
36561
  type: "problem",
36060
36562
  docs: {
@@ -36096,11 +36598,12 @@ var rule10 = {
36096
36598
  };
36097
36599
  }
36098
36600
  };
36099
- var no_non_public_instance_fields_default = rule10;
36601
+ var no_non_public_instance_fields_default = rule11;
36100
36602
 
36101
36603
  // src/dsl-rules/index.ts
36102
36604
  var dslRules = {
36103
36605
  "no-module-scoped-let": no_module_scoped_let_default,
36606
+ "no-module-scoped-mutable-const": no_module_scoped_mutable_const_default,
36104
36607
  "no-module-scoped-var": no_module_scoped_var_default,
36105
36608
  "no-non-public-instance-fields": no_non_public_instance_fields_default
36106
36609
  };
@@ -36131,7 +36634,7 @@ function getConstructors(node) {
36131
36634
  (member) => ts30.isConstructorDeclaration(member) && member.body !== void 0
36132
36635
  );
36133
36636
  }
36134
- var rule11 = {
36637
+ var rule12 = {
36135
36638
  meta: {
36136
36639
  type: "problem",
36137
36640
  docs: {
@@ -36181,7 +36684,7 @@ var rule11 = {
36181
36684
  };
36182
36685
  }
36183
36686
  };
36184
- var no_custom_constructor_default = rule11;
36687
+ var no_custom_constructor_default = rule12;
36185
36688
 
36186
36689
  // src/extensibility-rules/no-extra-type-params.ts
36187
36690
  import ts31 from "typescript";
@@ -36216,7 +36719,7 @@ function isSoleTypeParameterUsedForFieldsType(checker, node) {
36216
36719
  const fieldsTypeSymbol = getTypeSymbol(getBaseObjectFieldsType(checker, node)?.type);
36217
36720
  return typeParameterSymbol !== void 0 && fieldsTypeSymbol === typeParameterSymbol;
36218
36721
  }
36219
- var rule12 = {
36722
+ var rule13 = {
36220
36723
  meta: {
36221
36724
  type: "problem",
36222
36725
  docs: {
@@ -36294,7 +36797,7 @@ var rule12 = {
36294
36797
  };
36295
36798
  }
36296
36799
  };
36297
- var no_extra_type_params_default = rule12;
36800
+ var no_extra_type_params_default = rule13;
36298
36801
 
36299
36802
  // src/extensibility-rules/no-public-instance-fields.ts
36300
36803
  import ts34 from "typescript";
@@ -36328,7 +36831,7 @@ function getConstructors2(node) {
36328
36831
  (member) => ts34.isConstructorDeclaration(member) && member.body !== void 0
36329
36832
  );
36330
36833
  }
36331
- var rule13 = {
36834
+ var rule14 = {
36332
36835
  meta: {
36333
36836
  type: "problem",
36334
36837
  docs: {
@@ -36397,7 +36900,7 @@ var rule13 = {
36397
36900
  };
36398
36901
  }
36399
36902
  };
36400
- var no_public_instance_fields_default = rule13;
36903
+ var no_public_instance_fields_default = rule14;
36401
36904
 
36402
36905
  // src/extensibility-rules/prefer-es-private.ts
36403
36906
  import ts35 from "typescript";
@@ -36506,7 +37009,7 @@ function getAutofix(method, classNode) {
36506
37009
  ];
36507
37010
  };
36508
37011
  }
36509
- var rule14 = {
37012
+ var rule15 = {
36510
37013
  meta: {
36511
37014
  type: "suggestion",
36512
37015
  fixable: "code",
@@ -36564,7 +37067,7 @@ var rule14 = {
36564
37067
  };
36565
37068
  }
36566
37069
  };
36567
- var prefer_es_private_default = rule14;
37070
+ var prefer_es_private_default = rule15;
36568
37071
 
36569
37072
  // src/extensibility-rules/index.ts
36570
37073
  var extensibilityRules = {
@@ -36802,7 +37305,7 @@ function reportExplicitApiNameIssues(context, node) {
36802
37305
  });
36803
37306
  }
36804
37307
  }
36805
- var rule15 = {
37308
+ var rule16 = {
36806
37309
  meta: {
36807
37310
  type: "problem",
36808
37311
  docs: {
@@ -36847,7 +37350,7 @@ var rule15 = {
36847
37350
  };
36848
37351
  }
36849
37352
  };
36850
- var valid_api_name_default = rule15;
37353
+ var valid_api_name_default = rule16;
36851
37354
 
36852
37355
  // src/naming-rules/index.ts
36853
37356
  var namingRules = {
@@ -36870,7 +37373,7 @@ var noSecretsOptions = {
36870
37373
  "Stripe Webhook Secret": "whsec_[a-zA-Z0-9+/=]{20,}"
36871
37374
  }
36872
37375
  };
36873
- var rule16 = {
37376
+ var rule17 = {
36874
37377
  ...originalRule,
36875
37378
  meta: {
36876
37379
  ...originalRule.meta,
@@ -36880,7 +37383,7 @@ var rule16 = {
36880
37383
  }
36881
37384
  }
36882
37385
  };
36883
- var no_secrets_default = rule16;
37386
+ var no_secrets_default = rule17;
36884
37387
 
36885
37388
  // src/internal/analysis/apps/manifest-tools.ts
36886
37389
  import { parse } from "yaml";
@@ -36968,7 +37471,7 @@ function isObjectExpression(node) {
36968
37471
  function isProperty(node) {
36969
37472
  return node.type === "Property";
36970
37473
  }
36971
- function isIdentifier10(node) {
37474
+ function isIdentifier11(node) {
36972
37475
  return node.type === "Identifier";
36973
37476
  }
36974
37477
  function isLiteral(node) {
@@ -36985,7 +37488,7 @@ function getStringProperty(obj, name, sourceCode, scopeNode) {
36985
37488
  if (!isProperty(prop)) {
36986
37489
  continue;
36987
37490
  }
36988
- const keyName = isIdentifier10(prop.key) && prop.key.name || isLiteral(prop.key) && prop.key.value;
37491
+ const keyName = isIdentifier11(prop.key) && prop.key.name || isLiteral(prop.key) && prop.key.value;
36989
37492
  if (keyName !== name) {
36990
37493
  continue;
36991
37494
  }
@@ -36995,7 +37498,7 @@ function getStringProperty(obj, name, sourceCode, scopeNode) {
36995
37498
  node: prop.value
36996
37499
  };
36997
37500
  }
36998
- if (isIdentifier10(prop.value)) {
37501
+ if (isIdentifier11(prop.value)) {
36999
37502
  const varName = prop.value.name;
37000
37503
  let scope = sourceCode.getScope(scopeNode);
37001
37504
  while (scope) {
@@ -37014,7 +37517,7 @@ function getStringProperty(obj, name, sourceCode, scopeNode) {
37014
37517
  }
37015
37518
  return void 0;
37016
37519
  }
37017
- var rule17 = {
37520
+ var rule18 = {
37018
37521
  meta: {
37019
37522
  type: "problem",
37020
37523
  docs: {
@@ -37056,7 +37559,7 @@ var rule17 = {
37056
37559
  };
37057
37560
  }
37058
37561
  };
37059
- var valid_endpoint_id_default = rule17;
37562
+ var valid_endpoint_id_default = rule18;
37060
37563
 
37061
37564
  // src/security-rules/valid-extension-interface.ts
37062
37565
  import * as path4 from "path";
@@ -37100,7 +37603,7 @@ function resolveExtensionTarget(context) {
37100
37603
  }
37101
37604
  return { interfaceId: extensionForFile.interface_id, expectedInterfaceName };
37102
37605
  }
37103
- var rule18 = {
37606
+ var rule19 = {
37104
37607
  meta: {
37105
37608
  type: "problem",
37106
37609
  docs: {
@@ -37130,9 +37633,9 @@ var rule18 = {
37130
37633
  if (!sourceFile) {
37131
37634
  return;
37132
37635
  }
37636
+ const sourceCode = context.sourceCode;
37133
37637
  const classDeclaration = getDefaultExportedClassDeclaration(sourceFile);
37134
37638
  if (!classDeclaration) {
37135
- const sourceCode = context.sourceCode;
37136
37639
  const firstToken = sourceCode.getFirstToken(sourceCode.ast);
37137
37640
  context.report({
37138
37641
  node: firstToken ?? sourceCode.ast,
@@ -37150,21 +37653,25 @@ var rule18 = {
37150
37653
  ({ interfaceSymbol }) => symbolMatchesExtensionInterface(checker, interfaceSymbol)
37151
37654
  );
37152
37655
  if (sdkInterfaces.length === 0) {
37656
+ const highlightNode = classDeclaration.name ?? implementedTypes[0]?.heritageType.expression;
37153
37657
  context.report({
37154
- loc: toReportLoc(classDeclaration),
37658
+ ...highlightNode ? { loc: toReportLoc(highlightNode) } : { node: sourceCode.getFirstToken(sourceCode.ast) ?? sourceCode.ast },
37155
37659
  messageId: "MISSING_SDK_INTERFACE",
37156
37660
  data: { expectedInterfaceName, interfaceId }
37157
37661
  });
37158
37662
  return;
37159
37663
  }
37160
- const matchesExpected = sdkInterfaces.some(({ interfaceSymbol }) => {
37161
- const resolvedName = interfaceSymbol?.getName();
37162
- return resolvedName === expectedInterfaceName;
37163
- });
37664
+ const matchesExpected = sdkInterfaces.some(
37665
+ ({ interfaceSymbol }) => interfaceSymbol?.getName().startsWith(expectedInterfaceName) ?? false
37666
+ );
37164
37667
  if (!matchesExpected) {
37668
+ const firstMismatch = sdkInterfaces[0];
37669
+ if (!firstMismatch) {
37670
+ return;
37671
+ }
37165
37672
  const actualNames = sdkInterfaces.map(({ interfaceSymbol }) => interfaceSymbol?.getName() ?? "(unknown)").join(", ");
37166
37673
  context.report({
37167
- loc: toReportLoc(classDeclaration),
37674
+ loc: toReportLoc(firstMismatch.heritageType.expression),
37168
37675
  messageId: "WRONG_INTERFACE",
37169
37676
  data: {
37170
37677
  actualName: actualNames,
@@ -37180,16 +37687,16 @@ var rule18 = {
37180
37687
  };
37181
37688
  }
37182
37689
  };
37183
- var valid_extension_interface_default = rule18;
37690
+ var valid_extension_interface_default = rule19;
37184
37691
 
37185
37692
  // src/security-rules/index.ts
37186
37693
  var security = require_eslint_plugin_security();
37187
37694
  function requireRule(rules2, name, pluginName) {
37188
- const rule19 = rules2[name];
37189
- if (!rule19) {
37695
+ const rule20 = rules2[name];
37696
+ if (!rule20) {
37190
37697
  throw new Error(`Expected rule '${name}' not found in ${pluginName}`);
37191
37698
  }
37192
- return rule19;
37699
+ return rule20;
37193
37700
  }
37194
37701
  var securityRules = {
37195
37702
  "detect-bidi-characters": requireRule(