atom.io 0.46.11 → 0.46.13

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.
@@ -100,7 +100,7 @@ const exactCatchTypes = createRule$1({
100
100
  }
101
101
  const errorSymbolsToRepresent = new Set(acceptableErrorSymbols);
102
102
  for (const element of catchArray.elements) {
103
- if (!element || element.type !== AST_NODE_TYPES.Identifier) continue;
103
+ if (element?.type !== AST_NODE_TYPES.Identifier) continue;
104
104
  const constructorTsNode = parserServices.esTreeNodeToTSNodeMap.get(element);
105
105
  const constructorType = checker.getTypeAtLocation(constructorTsNode);
106
106
  const constructorName = element.name;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createRule","exactCatchTypes: ESLintUtils.RuleModule<\n\t`extraneousErrorTypes` | `invalidCatchProperty` | `missingCatchProperty`,\n\t[],\n\tunknown,\n\tESLintUtils.RuleListener\n>","functionName: string | null","typeArguments: TSESTree.TSTypeParameterInstantiation | undefined","catchProperty: TSESTree.Property | undefined","acceptableErrorSymbols: TsSymbol[]","instanceType: Type | undefined","explicitStateTypes: ESLintUtils.RuleModule<\n\t`noTypeArgument` | `noTypeArgumentOrAnnotation`,\n\tOptions,\n\tunknown,\n\tESLintUtils.RuleListener\n>","plugin: ESLint.Plugin","Rules.exactCatchTypes","Rules.explicitStateTypes"],"sources":["../../src/eslint-plugin/rules/exact-catch-types.ts","../../src/eslint-plugin/rules/explicit-state-types.ts","../../src/eslint-plugin/rules/index.ts","../../src/eslint-plugin/index.ts"],"sourcesContent":["import type { TSESTree } from \"@typescript-eslint/utils\"\nimport { AST_NODE_TYPES, ESLintUtils } from \"@typescript-eslint/utils\"\nimport type {\n\tInterfaceType,\n\tSymbol as TsSymbol,\n\tType,\n\tTypeNode,\n} from \"typescript\"\n\nconst createRule = ESLintUtils.RuleCreator(\n\t(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,\n)\n\nconst STATE_FUNCTIONS_WITH_CATCH = [\n\t`atom`,\n\t`atomFamily`,\n\t`selector`,\n\t`selectorFamily`,\n]\nconst FAMILY_FUNCTIONS = [`atomFamily`, `selectorFamily`]\n\nexport const exactCatchTypes: ESLintUtils.RuleModule<\n\t`extraneousErrorTypes` | `invalidCatchProperty` | `missingCatchProperty`,\n\t[],\n\tunknown,\n\tESLintUtils.RuleListener\n> = createRule({\n\tname: `catch-constructor-type`,\n\tmeta: {\n\t\ttype: `problem`,\n\t\tdocs: {\n\t\t\tdescription: `Ensures that when an error type (E) is provided to an atom, the 'catch' property is set and all constructors in it are assignable to E.`,\n\t\t},\n\t\tmessages: {\n\t\t\tmissingCatchProperty:\n\t\t\t\t`This {{functionName}} was provided the error type \\`{{errorTypeName}}\\` ` +\n\t\t\t\t`but the required 'catch' property is missing from its options. ` +\n\t\t\t\t`Either remove \\`{{errorTypeName}}\\`, or add \\`catch: [{{errorTypeName}}]\\` to the options object.`,\n\t\t\tinvalidCatchProperty:\n\t\t\t\t`This {{functionName}} was provided a catch array containing the class \\`{{constructorName}}\\`. ` +\n\t\t\t\t`However, that class is not represented in the {{functionName}}'s error type, \\`{{errorTypeName}}\\`. ` +\n\t\t\t\t`As a result, it might catch errors that the {{functionName}} is not designed to handle. ` +\n\t\t\t\t`Either include \\`{{constructorName}}\\` in the {{functionName}}'s error type, or remove it from the 'catch' array.`,\n\t\t\textraneousErrorTypes:\n\t\t\t\t`This {{functionName}} was provided an error type including the class \\`{{errorTypeName}}\\`, ` +\n\t\t\t\t`but its 'catch' property doesn't include a constructor for that class. ` +\n\t\t\t\t`Either include a constructor for \\`{{errorTypeName}}\\` in the 'catch' array, or remove \\`{{errorTypeName}}\\` as a possible error type.`,\n\t\t},\n\t\tschema: [],\n\t},\n\tdefaultOptions: [],\n\tcreate(context) {\n\t\tconst parserServices = ESLintUtils.getParserServices(context)\n\t\tconst checker = parserServices.program.getTypeChecker()\n\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tconst {\n\t\t\t\t\tcallee,\n\t\t\t\t\ttypeArguments: directTypeArguments,\n\t\t\t\t\targuments: callArguments,\n\t\t\t\t} = node\n\n\t\t\t\tlet errorParamIndex = 1\n\n\t\t\t\t// Check if the function call is one of the targeted state functions\n\t\t\t\tlet functionName: string | null = null\n\t\t\t\tif (callee.type === AST_NODE_TYPES.Identifier) {\n\t\t\t\t\tif (STATE_FUNCTIONS_WITH_CATCH.includes(callee.name)) {\n\t\t\t\t\t\tfunctionName = callee.name\n\t\t\t\t\t}\n\t\t\t\t} else if (callee.type === AST_NODE_TYPES.MemberExpression) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcallee.property.type === AST_NODE_TYPES.Identifier &&\n\t\t\t\t\t\tSTATE_FUNCTIONS_WITH_CATCH.includes(callee.property.name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfunctionName = callee.property.name\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!functionName) return\n\n\t\t\t\t// Where do the type arguments come from?\n\t\t\t\tlet typeArguments: TSESTree.TSTypeParameterInstantiation | undefined\n\t\t\t\tif (directTypeArguments) {\n\t\t\t\t\ttypeArguments = directTypeArguments\n\t\t\t\t} else {\n\t\t\t\t\tconst parent = node.parent\n\t\t\t\t\tif (\n\t\t\t\t\t\tparent?.type === AST_NODE_TYPES.VariableDeclarator &&\n\t\t\t\t\t\tparent.init === node\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Check if the VariableDeclarator has an id with a TypeAnnotation\n\t\t\t\t\t\tconst declaratorId = parent.id\n\t\t\t\t\t\tif (declaratorId.type === AST_NODE_TYPES.Identifier) {\n\t\t\t\t\t\t\t// Check for 'const myAtom: AtomToken<string> = ...'\n\t\t\t\t\t\t\tconst typeAnnotation = declaratorId.typeAnnotation?.typeAnnotation\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\ttypeAnnotation &&\n\t\t\t\t\t\t\t\t`typeArguments` in typeAnnotation &&\n\t\t\t\t\t\t\t\ttypeAnnotation.typeArguments\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\ttypeArguments = typeAnnotation.typeArguments\n\t\t\t\t\t\t\t\terrorParamIndex = 2 // AtomToken<T, K, E>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst optionsObject = callArguments[0]\n\n\t\t\t\tif (optionsObject?.type !== AST_NODE_TYPES.ObjectExpression) return\n\n\t\t\t\tconst isFamilyDeclaration = FAMILY_FUNCTIONS.includes(functionName)\n\t\t\t\tif (isFamilyDeclaration) {\n\t\t\t\t\terrorParamIndex = 2 // atomFamily<T, K, E>\n\t\t\t\t}\n\n\t\t\t\tconst errorTypeNode = typeArguments\n\t\t\t\t\t? typeArguments.params[errorParamIndex]\n\t\t\t\t\t: undefined\n\t\t\t\tif (!errorTypeNode) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlet catchProperty: TSESTree.Property | undefined\n\t\t\t\toptionsObject.properties.forEach((property) => {\n\t\t\t\t\tif (property.type === AST_NODE_TYPES.Property) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(property.key.type === AST_NODE_TYPES.Identifier &&\n\t\t\t\t\t\t\t\tproperty.key.name === `catch`) ||\n\t\t\t\t\t\t\t(property.key.type === AST_NODE_TYPES.Literal &&\n\t\t\t\t\t\t\t\tproperty.key.value === `catch`)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcatchProperty = property\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\tconst typeNode = parserServices.esTreeNodeToTSNodeMap.get(\n\t\t\t\t\terrorTypeNode,\n\t\t\t\t) as TypeNode\n\t\t\t\t// Get the TypeScript Type object for E\n\t\t\t\tconst errorTypeTs = checker.getTypeFromTypeNode(typeNode)\n\t\t\t\tconst errorTypeName = checker.typeToString(errorTypeTs)\n\n\t\t\t\tif (!catchProperty) {\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode: optionsObject,\n\t\t\t\t\t\tmessageId: `missingCatchProperty`,\n\t\t\t\t\t\tdata: { functionName, errorTypeName },\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// --- New Validation: Check Constructor Types ---\n\t\t\t\tconst catchArray = catchProperty.value\n\t\t\t\tif (catchArray.type !== AST_NODE_TYPES.ArrayExpression) {\n\t\t\t\t\t// We only check array literals (e.g., [Ctor1, Ctor2])\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// 3. Collect all acceptable nominal symbols from E\n\t\t\t\tconst acceptableErrorSymbols: TsSymbol[] = []\n\n\t\t\t\t// Check if E is a Union Type\n\t\t\t\tif (errorTypeTs.isUnion()) {\n\t\t\t\t\t// Add the symbol of every member of the union (e.g., Symbol(SpecialError), Symbol(FancyError))\n\t\t\t\t\tfor (const memberType of errorTypeTs.types) {\n\t\t\t\t\t\tconst symbol = memberType.getSymbol()\n\t\t\t\t\t\tif (symbol) {\n\t\t\t\t\t\t\tacceptableErrorSymbols.push(symbol)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// E is a single type, add its symbol\n\t\t\t\t\tconst symbol = errorTypeTs.getSymbol()\n\t\t\t\t\tif (symbol) {\n\t\t\t\t\t\tacceptableErrorSymbols.push(symbol)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (catchArray.elements.length === 0) {\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode: catchProperty,\n\t\t\t\t\t\tmessageId: `missingCatchProperty`,\n\t\t\t\t\t\tdata: { functionName, errorTypeName },\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst errorSymbolsToRepresent = new Set(acceptableErrorSymbols)\n\n\t\t\t\t// Iterate over each constructor reference in the 'catch' array\n\t\t\t\tfor (const element of catchArray.elements) {\n\t\t\t\t\tif (!element || element.type !== AST_NODE_TYPES.Identifier) {\n\t\t\t\t\t\t// Only check simple identifier references (e.g., [ClientError])\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get the type of the constructor identifier (e.g., the Type of 'Error')\n\t\t\t\t\tconst constructorTsNode =\n\t\t\t\t\t\tparserServices.esTreeNodeToTSNodeMap.get(element)\n\t\t\t\t\tconst constructorType = checker.getTypeAtLocation(constructorTsNode)\n\t\t\t\t\tconst constructorName = element.name\n\n\t\t\t\t\t// console.log(`constructorName`, constructorName)\n\n\t\t\t\t\t// Extract the instance type from the constructor type.\n\t\t\t\t\t// e.g., turn 'typeof ClientError' into 'ClientError'\n\t\t\t\t\tlet instanceType: Type | undefined\n\t\t\t\t\tif (\n\t\t\t\t\t\t(constructorType as InterfaceType).getConstructSignatures().length >\n\t\t\t\t\t\t0\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Get the return type of the constructor signature\n\t\t\t\t\t\tconst signature = (\n\t\t\t\t\t\t\tconstructorType as InterfaceType\n\t\t\t\t\t\t).getConstructSignatures()[0]\n\t\t\t\t\t\tinstanceType = signature.getReturnType()\n\t\t\t\t\t}\n\n\t\t\t\t\t// If we couldn't get the instance type, skip the check\n\n\t\t\t\t\tconst constructorInstanceSymbol = instanceType?.getSymbol()\n\t\t\t\t\tif (!constructorInstanceSymbol) continue\n\n\t\t\t\t\t// Check for symbol identity\n\t\t\t\t\tif (acceptableErrorSymbols.includes(constructorInstanceSymbol)) {\n\t\t\t\t\t\terrorSymbolsToRepresent.delete(constructorInstanceSymbol)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode: element,\n\t\t\t\t\t\t\tmessageId: `invalidCatchProperty`,\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tfunctionName,\n\t\t\t\t\t\t\t\tconstructorName: constructorName,\n\t\t\t\t\t\t\t\terrorTypeName: errorTypeName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const errorSymbol of errorSymbolsToRepresent) {\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode: catchProperty,\n\t\t\t\t\t\tmessageId: `extraneousErrorTypes`,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\terrorTypeName: checker.symbolToString(errorSymbol),\n\t\t\t\t\t\t\tfunctionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t},\n})\n","/* eslint-disable @typescript-eslint/switch-exhaustiveness-check */\nimport { AST_NODE_TYPES, ESLintUtils } from \"@typescript-eslint/utils\"\n\nconst createRule = ESLintUtils.RuleCreator(\n\t(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,\n)\n\nconst STATE_FUNCTIONS = [\n\t`atom`,\n\t`atomFamily`,\n\t`mutableAtom`,\n\t`mutableAtomFamily`,\n\t`selector`,\n\t`selectorFamily`,\n]\n\ntype Options = [\n\t{\n\t\tpermitAnnotation?: boolean\n\t},\n]\n\nexport const explicitStateTypes: ESLintUtils.RuleModule<\n\t`noTypeArgument` | `noTypeArgumentOrAnnotation`,\n\tOptions,\n\tunknown,\n\tESLintUtils.RuleListener\n> = createRule({\n\tname: `explicit-state-types`,\n\tmeta: {\n\t\ttype: `problem`,\n\t\tdocs: {\n\t\t\tdescription: `State declarations must have generic type arguments directly passed to them`,\n\t\t},\n\t\tmessages: {\n\t\t\tnoTypeArgument: `State declarations must have generic type arguments directly passed to them.`,\n\t\t\tnoTypeArgumentOrAnnotation: `State declarations must have generic type arguments directly passed to them, or a top-level type annotation.`,\n\t\t},\n\t\tschema: [\n\t\t\t{\n\t\t\t\ttype: `object`,\n\t\t\t\tproperties: {\n\t\t\t\t\tpermitAnnotation: {\n\t\t\t\t\t\ttype: `boolean`,\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t],\n\t},\n\tdefaultOptions: [\n\t\t{\n\t\t\tpermitAnnotation: false,\n\t\t},\n\t],\n\tcreate(context) {\n\t\tconst options = context.options[0]\n\t\tconst permitAnnotation = options?.permitAnnotation ?? false\n\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tconst callee = node.callee\n\n\t\t\t\tswitch (callee.type) {\n\t\t\t\t\tcase `Identifier`:\n\t\t\t\t\t\tif (STATE_FUNCTIONS.includes(callee.name) === false) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase `MemberExpression`:\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(callee.property.type === `Identifier` &&\n\t\t\t\t\t\t\t\tSTATE_FUNCTIONS.includes(callee.property.name)) === false\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// Check for the *required* generic type argument first\n\t\t\t\tif (node.typeArguments) {\n\t\t\t\t\treturn // Generic type argument is present, no error\n\t\t\t\t}\n\n\t\t\t\t// If generic arguments are missing, check if the top-level annotation exception is enabled AND present\n\t\t\t\tif (permitAnnotation) {\n\t\t\t\t\tlet hasAnnotation = false\n\t\t\t\t\t// Check if the CallExpression is the initializer of a variable declarator\n\t\t\t\t\tconst parent = node.parent\n\t\t\t\t\tif (\n\t\t\t\t\t\tparent?.type === AST_NODE_TYPES.VariableDeclarator &&\n\t\t\t\t\t\tparent.init === node\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Check if the VariableDeclarator has an id with a TypeAnnotation\n\t\t\t\t\t\tconst declaratorId = parent.id\n\t\t\t\t\t\tif (declaratorId.type === AST_NODE_TYPES.Identifier) {\n\t\t\t\t\t\t\t// Check for 'const myAtom: AtomToken<string> = ...'\n\t\t\t\t\t\t\thasAnnotation = Boolean(declaratorId.typeAnnotation)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (hasAnnotation) {\n\t\t\t\t\t\treturn // Exception met: type annotation is on the variable declaration\n\t\t\t\t\t}\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tmessageId: `noTypeArgumentOrAnnotation`,\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: `noTypeArgument`,\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t},\n})\n","export * from \"./exact-catch-types\"\nexport * from \"./explicit-state-types\"\n","import type { ESLint } from \"eslint\"\n\nimport * as Rules from \"./rules\"\n\nexport { Rules }\n\nconst plugin: ESLint.Plugin = {\n\trules: {\n\t\t\"exact-catch-types\": Rules.exactCatchTypes as any,\n\t\t\"explicit-state-types\": Rules.explicitStateTypes as any,\n\t},\n} satisfies ESLint.Plugin\n\nexport default plugin\n"],"mappings":";;;;AASA,MAAMA,eAAa,YAAY,aAC7B,SAAS,0CAA0C,OACpD;AAED,MAAM,6BAA6B;CAClC;CACA;CACA;CACA;CACA;AACD,MAAM,mBAAmB,CAAC,cAAc,iBAAiB;AAEzD,MAAaC,kBAKTD,aAAW;CACd,MAAM;CACN,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,2IACb;EACD,UAAU;GACT,sBACC;GAGD,sBACC;GAID,sBACC;GAGD;EACD,QAAQ,EAAE;EACV;CACD,gBAAgB,EAAE;CAClB,OAAO,SAAS;EACf,MAAM,iBAAiB,YAAY,kBAAkB,QAAQ;EAC7D,MAAM,UAAU,eAAe,QAAQ,gBAAgB;AAEvD,SAAO,EACN,eAAe,MAAM;GACpB,MAAM,EACL,QACA,eAAe,qBACf,WAAW,kBACR;GAEJ,IAAI,kBAAkB;GAGtB,IAAIE,eAA8B;AAClC,OAAI,OAAO,SAAS,eAAe,YAClC;QAAI,2BAA2B,SAAS,OAAO,KAAK,CACnD,gBAAe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B;EACD,QAAQ,CACP;GACC,MAAM;GACN,YAAY,EACX,kBAAkB;IACjB,MAAM;IACN,SAAS;IACT,EACD;GACD,sBAAsB;GACtB,CACD;EACD;CACD,gBAAgB,CACf,EACC,kBAAkB,OAClB,CACD;CACD,OAAO,SAAS;EAEf,MAAM,mBADU,QAAQ,QAAQ,IACE,oBAAoB;AAEtD,SAAO,EACN,eAAe,MAAM;GACpB,MAAM,SAAS,KAAK;AAEpB,WAAQ,OAAO,MAAf;IACC,KAAK;AACJ,SAAI,gBAAgB,SAAS,OAAO,KAAK,KAAK,MAC7C;AAED;IACD,KAAK;AACJ,UACE,OAAO,SAAS,SAAS,gBACzB,gBAAgB,SAAS,OAAO,SAAS,KAAK,MAAM,MAErD;AAED;IACD,QACC;;AAIF,OAAI,KAAK,cACR;AAID,OAAI,kBAAkB;IACrB,IAAI,gBAAgB;IAEpB,MAAM,SAAS,KAAK;AACpB,QACC,QAAQ,SAAS,eAAe,sBAChC,OAAO,SAAS,MACf;KAED,MAAM,eAAe,OAAO;AAC5B,SAAI,aAAa,SAAS,eAAe,WAExC,iBAAgB,QAAQ,aAAa,eAAe;;AAGtD,QAAI,cACH;AAED,YAAQ,OAAO;KACd;KACA,WAAW;KACX,CAAC;AACF;;AAGD,WAAQ,OAAO;IACd;IACA,WAAW;IACX,CAAC;KAEH;;CAEF,CAAC;;;;;;;;;;;AElHF,MAAMC,SAAwB,EAC7B,OAAO;CACN,qBAAqBC;CACrB,wBAAwBC;CACxB,EACD;AAED,4BAAe"}
1
+ {"version":3,"file":"index.js","names":["createRule","exactCatchTypes: ESLintUtils.RuleModule<\n\t`extraneousErrorTypes` | `invalidCatchProperty` | `missingCatchProperty`,\n\t[],\n\tunknown,\n\tESLintUtils.RuleListener\n>","functionName: string | null","typeArguments: TSESTree.TSTypeParameterInstantiation | undefined","catchProperty: TSESTree.Property | undefined","acceptableErrorSymbols: TsSymbol[]","instanceType: Type | undefined","explicitStateTypes: ESLintUtils.RuleModule<\n\t`noTypeArgument` | `noTypeArgumentOrAnnotation`,\n\tOptions,\n\tunknown,\n\tESLintUtils.RuleListener\n>","plugin: ESLint.Plugin","Rules.exactCatchTypes","Rules.explicitStateTypes"],"sources":["../../src/eslint-plugin/rules/exact-catch-types.ts","../../src/eslint-plugin/rules/explicit-state-types.ts","../../src/eslint-plugin/rules/index.ts","../../src/eslint-plugin/index.ts"],"sourcesContent":["import type { TSESTree } from \"@typescript-eslint/utils\"\nimport { AST_NODE_TYPES, ESLintUtils } from \"@typescript-eslint/utils\"\nimport type {\n\tInterfaceType,\n\tSymbol as TsSymbol,\n\tType,\n\tTypeNode,\n} from \"typescript\"\n\nconst createRule = ESLintUtils.RuleCreator(\n\t(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,\n)\n\nconst STATE_FUNCTIONS_WITH_CATCH = [\n\t`atom`,\n\t`atomFamily`,\n\t`selector`,\n\t`selectorFamily`,\n]\nconst FAMILY_FUNCTIONS = [`atomFamily`, `selectorFamily`]\n\nexport const exactCatchTypes: ESLintUtils.RuleModule<\n\t`extraneousErrorTypes` | `invalidCatchProperty` | `missingCatchProperty`,\n\t[],\n\tunknown,\n\tESLintUtils.RuleListener\n> = createRule({\n\tname: `catch-constructor-type`,\n\tmeta: {\n\t\ttype: `problem`,\n\t\tdocs: {\n\t\t\tdescription: `Ensures that when an error type (E) is provided to an atom, the 'catch' property is set and all constructors in it are assignable to E.`,\n\t\t},\n\t\tmessages: {\n\t\t\tmissingCatchProperty:\n\t\t\t\t`This {{functionName}} was provided the error type \\`{{errorTypeName}}\\` ` +\n\t\t\t\t`but the required 'catch' property is missing from its options. ` +\n\t\t\t\t`Either remove \\`{{errorTypeName}}\\`, or add \\`catch: [{{errorTypeName}}]\\` to the options object.`,\n\t\t\tinvalidCatchProperty:\n\t\t\t\t`This {{functionName}} was provided a catch array containing the class \\`{{constructorName}}\\`. ` +\n\t\t\t\t`However, that class is not represented in the {{functionName}}'s error type, \\`{{errorTypeName}}\\`. ` +\n\t\t\t\t`As a result, it might catch errors that the {{functionName}} is not designed to handle. ` +\n\t\t\t\t`Either include \\`{{constructorName}}\\` in the {{functionName}}'s error type, or remove it from the 'catch' array.`,\n\t\t\textraneousErrorTypes:\n\t\t\t\t`This {{functionName}} was provided an error type including the class \\`{{errorTypeName}}\\`, ` +\n\t\t\t\t`but its 'catch' property doesn't include a constructor for that class. ` +\n\t\t\t\t`Either include a constructor for \\`{{errorTypeName}}\\` in the 'catch' array, or remove \\`{{errorTypeName}}\\` as a possible error type.`,\n\t\t},\n\t\tschema: [],\n\t},\n\tdefaultOptions: [],\n\tcreate(context) {\n\t\tconst parserServices = ESLintUtils.getParserServices(context)\n\t\tconst checker = parserServices.program.getTypeChecker()\n\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tconst {\n\t\t\t\t\tcallee,\n\t\t\t\t\ttypeArguments: directTypeArguments,\n\t\t\t\t\targuments: callArguments,\n\t\t\t\t} = node\n\n\t\t\t\tlet errorParamIndex = 1\n\n\t\t\t\t// Check if the function call is one of the targeted state functions\n\t\t\t\tlet functionName: string | null = null\n\t\t\t\tif (callee.type === AST_NODE_TYPES.Identifier) {\n\t\t\t\t\tif (STATE_FUNCTIONS_WITH_CATCH.includes(callee.name)) {\n\t\t\t\t\t\tfunctionName = callee.name\n\t\t\t\t\t}\n\t\t\t\t} else if (callee.type === AST_NODE_TYPES.MemberExpression) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcallee.property.type === AST_NODE_TYPES.Identifier &&\n\t\t\t\t\t\tSTATE_FUNCTIONS_WITH_CATCH.includes(callee.property.name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfunctionName = callee.property.name\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!functionName) return\n\n\t\t\t\t// Where do the type arguments come from?\n\t\t\t\tlet typeArguments: TSESTree.TSTypeParameterInstantiation | undefined\n\t\t\t\tif (directTypeArguments) {\n\t\t\t\t\ttypeArguments = directTypeArguments\n\t\t\t\t} else {\n\t\t\t\t\tconst parent = node.parent\n\t\t\t\t\tif (\n\t\t\t\t\t\tparent?.type === AST_NODE_TYPES.VariableDeclarator &&\n\t\t\t\t\t\tparent.init === node\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Check if the VariableDeclarator has an id with a TypeAnnotation\n\t\t\t\t\t\tconst declaratorId = parent.id\n\t\t\t\t\t\tif (declaratorId.type === AST_NODE_TYPES.Identifier) {\n\t\t\t\t\t\t\t// Check for 'const myAtom: AtomToken<string> = ...'\n\t\t\t\t\t\t\tconst typeAnnotation = declaratorId.typeAnnotation?.typeAnnotation\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\ttypeAnnotation &&\n\t\t\t\t\t\t\t\t`typeArguments` in typeAnnotation &&\n\t\t\t\t\t\t\t\ttypeAnnotation.typeArguments\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\ttypeArguments = typeAnnotation.typeArguments\n\t\t\t\t\t\t\t\terrorParamIndex = 2 // AtomToken<T, K, E>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst optionsObject = callArguments[0]\n\n\t\t\t\tif (optionsObject?.type !== AST_NODE_TYPES.ObjectExpression) return\n\n\t\t\t\tconst isFamilyDeclaration = FAMILY_FUNCTIONS.includes(functionName)\n\t\t\t\tif (isFamilyDeclaration) {\n\t\t\t\t\terrorParamIndex = 2 // atomFamily<T, K, E>\n\t\t\t\t}\n\n\t\t\t\tconst errorTypeNode = typeArguments\n\t\t\t\t\t? typeArguments.params[errorParamIndex]\n\t\t\t\t\t: undefined\n\t\t\t\tif (!errorTypeNode) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlet catchProperty: TSESTree.Property | undefined\n\t\t\t\toptionsObject.properties.forEach((property) => {\n\t\t\t\t\tif (property.type === AST_NODE_TYPES.Property) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(property.key.type === AST_NODE_TYPES.Identifier &&\n\t\t\t\t\t\t\t\tproperty.key.name === `catch`) ||\n\t\t\t\t\t\t\t(property.key.type === AST_NODE_TYPES.Literal &&\n\t\t\t\t\t\t\t\tproperty.key.value === `catch`)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcatchProperty = property\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t\tconst typeNode = parserServices.esTreeNodeToTSNodeMap.get(\n\t\t\t\t\terrorTypeNode,\n\t\t\t\t) as TypeNode\n\t\t\t\t// Get the TypeScript Type object for E\n\t\t\t\tconst errorTypeTs = checker.getTypeFromTypeNode(typeNode)\n\t\t\t\tconst errorTypeName = checker.typeToString(errorTypeTs)\n\n\t\t\t\tif (!catchProperty) {\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode: optionsObject,\n\t\t\t\t\t\tmessageId: `missingCatchProperty`,\n\t\t\t\t\t\tdata: { functionName, errorTypeName },\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// --- New Validation: Check Constructor Types ---\n\t\t\t\tconst catchArray = catchProperty.value\n\t\t\t\tif (catchArray.type !== AST_NODE_TYPES.ArrayExpression) {\n\t\t\t\t\t// We only check array literals (e.g., [Ctor1, Ctor2])\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// 3. Collect all acceptable nominal symbols from E\n\t\t\t\tconst acceptableErrorSymbols: TsSymbol[] = []\n\n\t\t\t\t// Check if E is a Union Type\n\t\t\t\tif (errorTypeTs.isUnion()) {\n\t\t\t\t\t// Add the symbol of every member of the union (e.g., Symbol(SpecialError), Symbol(FancyError))\n\t\t\t\t\tfor (const memberType of errorTypeTs.types) {\n\t\t\t\t\t\tconst symbol = memberType.getSymbol()\n\t\t\t\t\t\tif (symbol) {\n\t\t\t\t\t\t\tacceptableErrorSymbols.push(symbol)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// E is a single type, add its symbol\n\t\t\t\t\tconst symbol = errorTypeTs.getSymbol()\n\t\t\t\t\tif (symbol) {\n\t\t\t\t\t\tacceptableErrorSymbols.push(symbol)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (catchArray.elements.length === 0) {\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode: catchProperty,\n\t\t\t\t\t\tmessageId: `missingCatchProperty`,\n\t\t\t\t\t\tdata: { functionName, errorTypeName },\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst errorSymbolsToRepresent = new Set(acceptableErrorSymbols)\n\n\t\t\t\t// Iterate over each constructor reference in the 'catch' array\n\t\t\t\tfor (const element of catchArray.elements) {\n\t\t\t\t\tif (element?.type !== AST_NODE_TYPES.Identifier) {\n\t\t\t\t\t\t// Only check simple identifier references (e.g., [ClientError])\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get the type of the constructor identifier (e.g., the Type of 'Error')\n\t\t\t\t\tconst constructorTsNode =\n\t\t\t\t\t\tparserServices.esTreeNodeToTSNodeMap.get(element)\n\t\t\t\t\tconst constructorType = checker.getTypeAtLocation(constructorTsNode)\n\t\t\t\t\tconst constructorName = element.name\n\n\t\t\t\t\t// console.log(`constructorName`, constructorName)\n\n\t\t\t\t\t// Extract the instance type from the constructor type.\n\t\t\t\t\t// e.g., turn 'typeof ClientError' into 'ClientError'\n\t\t\t\t\tlet instanceType: Type | undefined\n\t\t\t\t\tif (\n\t\t\t\t\t\t(constructorType as InterfaceType).getConstructSignatures().length >\n\t\t\t\t\t\t0\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Get the return type of the constructor signature\n\t\t\t\t\t\tconst signature = (\n\t\t\t\t\t\t\tconstructorType as InterfaceType\n\t\t\t\t\t\t).getConstructSignatures()[0]\n\t\t\t\t\t\tinstanceType = signature.getReturnType()\n\t\t\t\t\t}\n\n\t\t\t\t\t// If we couldn't get the instance type, skip the check\n\n\t\t\t\t\tconst constructorInstanceSymbol = instanceType?.getSymbol()\n\t\t\t\t\tif (!constructorInstanceSymbol) continue\n\n\t\t\t\t\t// Check for symbol identity\n\t\t\t\t\tif (acceptableErrorSymbols.includes(constructorInstanceSymbol)) {\n\t\t\t\t\t\terrorSymbolsToRepresent.delete(constructorInstanceSymbol)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode: element,\n\t\t\t\t\t\t\tmessageId: `invalidCatchProperty`,\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tfunctionName,\n\t\t\t\t\t\t\t\tconstructorName: constructorName,\n\t\t\t\t\t\t\t\terrorTypeName: errorTypeName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const errorSymbol of errorSymbolsToRepresent) {\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode: catchProperty,\n\t\t\t\t\t\tmessageId: `extraneousErrorTypes`,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\terrorTypeName: checker.symbolToString(errorSymbol),\n\t\t\t\t\t\t\tfunctionName,\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t},\n})\n","/* eslint-disable @typescript-eslint/switch-exhaustiveness-check */\nimport { AST_NODE_TYPES, ESLintUtils } from \"@typescript-eslint/utils\"\n\nconst createRule = ESLintUtils.RuleCreator(\n\t(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,\n)\n\nconst STATE_FUNCTIONS = [\n\t`atom`,\n\t`atomFamily`,\n\t`mutableAtom`,\n\t`mutableAtomFamily`,\n\t`selector`,\n\t`selectorFamily`,\n]\n\ntype Options = [\n\t{\n\t\tpermitAnnotation?: boolean\n\t},\n]\n\nexport const explicitStateTypes: ESLintUtils.RuleModule<\n\t`noTypeArgument` | `noTypeArgumentOrAnnotation`,\n\tOptions,\n\tunknown,\n\tESLintUtils.RuleListener\n> = createRule({\n\tname: `explicit-state-types`,\n\tmeta: {\n\t\ttype: `problem`,\n\t\tdocs: {\n\t\t\tdescription: `State declarations must have generic type arguments directly passed to them`,\n\t\t},\n\t\tmessages: {\n\t\t\tnoTypeArgument: `State declarations must have generic type arguments directly passed to them.`,\n\t\t\tnoTypeArgumentOrAnnotation: `State declarations must have generic type arguments directly passed to them, or a top-level type annotation.`,\n\t\t},\n\t\tschema: [\n\t\t\t{\n\t\t\t\ttype: `object`,\n\t\t\t\tproperties: {\n\t\t\t\t\tpermitAnnotation: {\n\t\t\t\t\t\ttype: `boolean`,\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t],\n\t},\n\tdefaultOptions: [\n\t\t{\n\t\t\tpermitAnnotation: false,\n\t\t},\n\t],\n\tcreate(context) {\n\t\tconst options = context.options[0]\n\t\tconst permitAnnotation = options?.permitAnnotation ?? false\n\n\t\treturn {\n\t\t\tCallExpression(node) {\n\t\t\t\tconst callee = node.callee\n\n\t\t\t\tswitch (callee.type) {\n\t\t\t\t\tcase `Identifier`:\n\t\t\t\t\t\tif (STATE_FUNCTIONS.includes(callee.name) === false) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase `MemberExpression`:\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t(callee.property.type === `Identifier` &&\n\t\t\t\t\t\t\t\tSTATE_FUNCTIONS.includes(callee.property.name)) === false\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// Check for the *required* generic type argument first\n\t\t\t\tif (node.typeArguments) {\n\t\t\t\t\treturn // Generic type argument is present, no error\n\t\t\t\t}\n\n\t\t\t\t// If generic arguments are missing, check if the top-level annotation exception is enabled AND present\n\t\t\t\tif (permitAnnotation) {\n\t\t\t\t\tlet hasAnnotation = false\n\t\t\t\t\t// Check if the CallExpression is the initializer of a variable declarator\n\t\t\t\t\tconst parent = node.parent\n\t\t\t\t\tif (\n\t\t\t\t\t\tparent?.type === AST_NODE_TYPES.VariableDeclarator &&\n\t\t\t\t\t\tparent.init === node\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Check if the VariableDeclarator has an id with a TypeAnnotation\n\t\t\t\t\t\tconst declaratorId = parent.id\n\t\t\t\t\t\tif (declaratorId.type === AST_NODE_TYPES.Identifier) {\n\t\t\t\t\t\t\t// Check for 'const myAtom: AtomToken<string> = ...'\n\t\t\t\t\t\t\thasAnnotation = Boolean(declaratorId.typeAnnotation)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (hasAnnotation) {\n\t\t\t\t\t\treturn // Exception met: type annotation is on the variable declaration\n\t\t\t\t\t}\n\t\t\t\t\tcontext.report({\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tmessageId: `noTypeArgumentOrAnnotation`,\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: `noTypeArgument`,\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t},\n})\n","export * from \"./exact-catch-types\"\nexport * from \"./explicit-state-types\"\n","import type { ESLint } from \"eslint\"\n\nimport * as Rules from \"./rules\"\n\nexport { Rules }\n\nconst plugin: ESLint.Plugin = {\n\trules: {\n\t\t\"exact-catch-types\": Rules.exactCatchTypes as any,\n\t\t\"explicit-state-types\": Rules.explicitStateTypes as any,\n\t},\n} satisfies ESLint.Plugin\n\nexport default plugin\n"],"mappings":";;;;AASA,MAAMA,eAAa,YAAY,aAC7B,SAAS,0CAA0C,OACpD;AAED,MAAM,6BAA6B;CAClC;CACA;CACA;CACA;CACA;AACD,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YAAQ,OAAO;KACd;KACA,WAAW;KACX,CAAC;AACF;;AAGD,WAAQ,OAAO;IACd;IACA,WAAW;IACX,CAAC;KAEH;;CAEF,CAAC;;;;;;;;;;;AElHF,MAAMC,SAAwB,EAC7B,OAAO;CACN,qBAAqBC;CACrB,wBAAwBC;CACxB,EACD;AAED,4BAAe"}
@@ -454,13 +454,20 @@ const TextInput = ({ value, set, label, placeholder, autoSize = false, testid })
454
454
  //#endregion
455
455
  //#region src/react-devtools/json-editor/editors-by-type/non-json.tsx
456
456
  const NonJsonEditor = ({ data, testid }) => {
457
- return data === void 0 ? /* @__PURE__ */ jsx(ElasticInput, {
457
+ if (data === void 0) return /* @__PURE__ */ jsx(ElasticInput, {
458
458
  disabled: true,
459
459
  value: "undefined",
460
460
  "data-testid": `${testid}-undefined`
461
- }) : /* @__PURE__ */ jsx(ElasticInput, {
461
+ });
462
+ let stringified$1;
463
+ try {
464
+ stringified$1 = JSON.stringify(data);
465
+ } catch (_) {
466
+ stringified$1 = `?`;
467
+ }
468
+ return /* @__PURE__ */ jsx(ElasticInput, {
462
469
  disabled: true,
463
- value: Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data),
470
+ value: Object.getPrototypeOf(data).constructor.name + ` ` + stringified$1,
464
471
  "data-testid": `${testid}-non-json-${Object.getPrototypeOf(data).constructor.name}`
465
472
  });
466
473
  };
@@ -478,6 +485,12 @@ const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [
478
485
  const disabled = isReadonly(path);
479
486
  const dataIsTree = refined.type === `array` || refined.type === `object`;
480
487
  const dataIsExpandable = dataIsTree && isOpen !== void 0 && setIsOpen;
488
+ let stringified$1;
489
+ try {
490
+ stringified$1 = JSON.stringify(data);
491
+ } catch (_) {
492
+ stringified$1 = `?`;
493
+ }
481
494
  return isHidden(path) ? null : /* @__PURE__ */ jsx(Components.ErrorBoundary, { children: /* @__PURE__ */ jsxs(Components.EditorWrapper, {
482
495
  className,
483
496
  style,
@@ -503,7 +516,7 @@ const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [
503
516
  }) }),
504
517
  dataIsTree ? /* @__PURE__ */ jsxs(Fragment$1, { children: [isOpen !== void 0 && setIsOpen ? /* @__PURE__ */ jsx("span", {
505
518
  className: "json_viewer",
506
- children: JSON.stringify(data)
519
+ children: stringified$1
507
520
  }) : null, recast ? /* @__PURE__ */ jsx("select", {
508
521
  onChange: (e) => {
509
522
  recast(e.target.value);
@@ -1052,6 +1065,12 @@ const StateIndexLeafNode = ({ node, isOpenState, typeState, dispose }) => {
1052
1065
  const stateType = stateTypeLoadable instanceof Promise ? `Promise` : stateTypeLoadable;
1053
1066
  const isPrimitive = Boolean(primitiveRefinery.refine(state));
1054
1067
  const path = node.family ? [node.family.key, node.family.subKey] : [node.key];
1068
+ let stringified$1;
1069
+ try {
1070
+ stringified$1 = JSON.stringify(state);
1071
+ } catch (_) {
1072
+ stringified$1 = `?`;
1073
+ }
1055
1074
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsxs("main", {
1056
1075
  onClick: () => {
1057
1076
  console.log(node, getFromStore(store, node));
@@ -1082,7 +1101,7 @@ const StateIndexLeafNode = ({ node, isOpenState, typeState, dispose }) => {
1082
1101
  ]
1083
1102
  }), /* @__PURE__ */ jsxs("footer", { children: [isPrimitive ? /* @__PURE__ */ jsx(StoreEditor, { token: node }) : /* @__PURE__ */ jsx("div", {
1084
1103
  className: "json_viewer",
1085
- children: JSON.stringify(state)
1104
+ children: stringified$1
1086
1105
  }), dispose ? /* @__PURE__ */ jsx(DEFAULT_JSON_EDITOR_COMPONENTS.Button, {
1087
1106
  onClick: () => {
1088
1107
  dispose?.();