Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
1 line
No EOL
9.2 KiB
Text
1 line
No EOL
9.2 KiB
Text
{"version":3,"sources":["../../../../src/server/typescript/rules/entry.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs'\n\nimport {\n ALLOWED_LAYOUT_PROPS,\n ALLOWED_PAGE_PROPS,\n NEXT_TS_ERRORS,\n} from '../constant'\nimport { getTs, isPageFile, isPositionInsideNode } from '../utils'\n\nimport type tsModule from 'typescript/lib/tsserverlibrary'\n\nconst entry = {\n // Give auto completion for the component's props\n getCompletionsAtPosition(\n fileName: string,\n node: tsModule.FunctionDeclaration,\n position: number\n ) {\n const ts = getTs()\n const entries: tsModule.CompletionEntry[] = []\n\n // Default export function might not accept parameters\n const paramNode = node.parameters?.[0] as\n | tsModule.ParameterDeclaration\n | undefined\n\n if (paramNode && isPositionInsideNode(position, paramNode)) {\n const props = paramNode?.name\n if (props && ts.isObjectBindingPattern(props)) {\n let validProps = []\n let validPropsWithType = []\n let type: string\n\n if (isPageFile(fileName)) {\n // For page entries (page.js), it can only have `params` and `searchParams`\n // as the prop names.\n validProps = ALLOWED_PAGE_PROPS\n validPropsWithType = ALLOWED_PAGE_PROPS\n type = 'page'\n } else {\n // For layout entires, check if it has any named slots.\n const currentDir = path.dirname(fileName)\n const items = fs.readdirSync(currentDir, {\n withFileTypes: true,\n })\n const slots = []\n for (const item of items) {\n if (item.isDirectory() && item.name.startsWith('@')) {\n slots.push(item.name.slice(1))\n }\n }\n validProps = ALLOWED_LAYOUT_PROPS.concat(slots)\n validPropsWithType = ALLOWED_LAYOUT_PROPS.concat(\n slots.map((s) => `${s}: React.ReactNode`)\n )\n type = 'layout'\n }\n\n // Auto completion for props\n for (const element of props.elements) {\n if (isPositionInsideNode(position, element)) {\n const nameNode = element.propertyName || element.name\n\n if (isPositionInsideNode(position, nameNode)) {\n for (const name of validProps) {\n entries.push({\n name,\n insertText: name,\n sortText: '_' + name,\n kind: ts.ScriptElementKind.memberVariableElement,\n kindModifiers: ts.ScriptElementKindModifier.none,\n labelDetails: {\n description: `Next.js ${type} prop`,\n },\n } as tsModule.CompletionEntry)\n }\n }\n\n break\n }\n }\n\n // Auto completion for types\n if (paramNode.type && ts.isTypeLiteralNode(paramNode.type)) {\n for (const member of paramNode.type.members) {\n if (isPositionInsideNode(position, member)) {\n for (const name of validPropsWithType) {\n entries.push({\n name,\n insertText: name,\n sortText: '_' + name,\n kind: ts.ScriptElementKind.memberVariableElement,\n kindModifiers: ts.ScriptElementKindModifier.none,\n labelDetails: {\n description: `Next.js ${type} prop type`,\n },\n } as tsModule.CompletionEntry)\n }\n\n break\n }\n }\n }\n }\n }\n\n return entries\n },\n\n // Give error diagnostics for the component\n getSemanticDiagnostics(\n fileName: string,\n source: tsModule.SourceFile,\n node: tsModule.FunctionDeclaration\n ) {\n const ts = getTs()\n\n let validProps = []\n let type: string\n\n if (isPageFile(fileName)) {\n // For page entries (page.js), it can only have `params` and `searchParams`\n // as the prop names.\n validProps = ALLOWED_PAGE_PROPS\n type = 'page'\n } else {\n // For layout entires, check if it has any named slots.\n const currentDir = path.dirname(fileName)\n const items = fs.readdirSync(currentDir, { withFileTypes: true })\n const slots = []\n for (const item of items) {\n if (item.isDirectory() && item.name.startsWith('@')) {\n slots.push(item.name.slice(1))\n }\n }\n validProps = ALLOWED_LAYOUT_PROPS.concat(slots)\n type = 'layout'\n }\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n const props = node.parameters?.[0]?.name\n if (props && ts.isObjectBindingPattern(props)) {\n for (const prop of props.elements) {\n const propName = (prop.propertyName || prop.name).getText()\n if (!validProps.includes(propName)) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Error,\n code: NEXT_TS_ERRORS.INVALID_PAGE_PROP,\n messageText: `\"${propName}\" is not a valid ${type} prop.`,\n start: prop.getStart(),\n length: prop.getWidth(),\n })\n }\n }\n }\n\n return diagnostics\n },\n}\n\nexport default entry\n"],"names":["path","fs","ALLOWED_LAYOUT_PROPS","ALLOWED_PAGE_PROPS","NEXT_TS_ERRORS","getTs","isPageFile","isPositionInsideNode","entry","getCompletionsAtPosition","fileName","node","position","ts","entries","paramNode","parameters","props","name","isObjectBindingPattern","validProps","validPropsWithType","type","currentDir","dirname","items","readdirSync","withFileTypes","slots","item","isDirectory","startsWith","push","slice","concat","map","s","element","elements","nameNode","propertyName","insertText","sortText","kind","ScriptElementKind","memberVariableElement","kindModifiers","ScriptElementKindModifier","none","labelDetails","description","isTypeLiteralNode","member","members","getSemanticDiagnostics","source","diagnostics","prop","propName","getText","includes","file","category","DiagnosticCategory","Error","code","INVALID_PAGE_PROP","messageText","start","getStart","length","getWidth"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,OAAOC,QAAQ,KAAI;AAEnB,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,cAAc,QACT,cAAa;AACpB,SAASC,KAAK,EAAEC,UAAU,EAAEC,oBAAoB,QAAQ,WAAU;AAIlE,MAAMC,QAAQ;IACZ,iDAAiD;IACjDC,0BACEC,QAAgB,EAChBC,IAAkC,EAClCC,QAAgB;YAMED;QAJlB,MAAME,KAAKR;QACX,MAAMS,UAAsC,EAAE;QAE9C,sDAAsD;QACtD,MAAMC,aAAYJ,mBAAAA,KAAKK,UAAU,qBAAfL,gBAAiB,CAAC,EAAE;QAItC,IAAII,aAAaR,qBAAqBK,UAAUG,YAAY;YAC1D,MAAME,QAAQF,6BAAAA,UAAWG,IAAI;YAC7B,IAAID,SAASJ,GAAGM,sBAAsB,CAACF,QAAQ;gBAC7C,IAAIG,aAAa,EAAE;gBACnB,IAAIC,qBAAqB,EAAE;gBAC3B,IAAIC;gBAEJ,IAAIhB,WAAWI,WAAW;oBACxB,2EAA2E;oBAC3E,qBAAqB;oBACrBU,aAAajB;oBACbkB,qBAAqBlB;oBACrBmB,OA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