Skip to content

Conversation

Copy link

Copilot AI commented Jan 2, 2026

  • Fix syntax error when filenames contain hyphens (e.g., volunteer-profile-shapes)
    • Use to-valid-identifier npm package instead of custom function
    • Update build.ts to import and use toValidIdentifier from the package
    • Remove custom toValidTypescriptIdentifier utility function and tests
    • Update templates (context.ejs, schema.ejs, shapeTypes.ejs) to use identifierName for TypeScript code and keep fileName for file paths
    • Add engines field to package.json to specify Node.js >=20 requirement (required by to-valid-identifier)
  • Run code review and security checks (CodeQL) - no alerts found
Original prompt

This section details on the original issue you should resolve

<issue_title>Syntax error in typescript with -</issue_title>
<issue_description>

Error Message:

SyntaxError: ',' expected. (8:23)
   6 |  * =============================================================================
   7 |  */
>  8 | export const volunteer-profile-shapesContext: LdoJsonldContext = {
     |                       ^
   9 |   "preferredLocation": {
  10 |     "@id": "https://id.volunteeringdata.io/volunteer_profile/preferredLocation",
  11 |     "@type": "@id",
    at S4 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:17:72190)
    at Q4 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:20:1042)
    at Object.e3 [as parse] (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:20:1584)
    at parse5 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/index.mjs:16731:24)
    at async coreFormat (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/index.mjs:17287:25)
    at async formatWithCursor (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/index.mjs:17504:14)
    at async Object.format2 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/index.mjs:19051:25)
    at async file:///Users/jesght/volunteer-profile-manager/node_modules/@ldo/cli/dist/build.js:48:102
    at async Promise.all (index 0)
    at async file:///Users/jesght/volunteer-profile-manager/node_modules/@ldo/cli/dist/build.js:40:9 {
  loc: { start: { line: 8, column: 23 }, end: { line: 8, column: 23 } },
  cause: $f: ',' expected.
      at ed (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:17:8771)
      at ad (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:17:10704)
      at e0 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:17:66963)
      at x4 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:17:72051)
      at h0 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:17:71793)
      at file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:20:1548
      at w4 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:17:72344)
      at Object.e3 [as parse] (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/plugins/typescript.mjs:20:1532)
      at parse5 (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/index.mjs:16731:24)
      at async coreFormat (file:///Users/jesght/volunteer-profile-manager/node_modules/prettier/index.mjs:17287:25) {
    fileName: 'estree.ts',
    location: {
      end: { column: 22, line: 8, offset: 318 },
      start: { column: 22, line: 8, offset: 318 }
    }
  },
  codeFrame: '\x1B[0m \x1B[90m  6 |\x1B[39m \x1B[90m * =============================================================================\x1B[39m\n' +
    ' \x1B[90m  7 |\x1B[39m \x1B[90m */\x1B[39m\n' +
    '\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m  8 |\x1B[39m \x1B[36mexport\x1B[39m \x1B[36mconst\x1B[39m volunteer\x1B[33m-\x1B[39mprofile\x1B[33m-\x1B[39mshapesContext\x1B[33m:\x1B[39m \x1B[33mLdoJsonldContext\x1B[39m \x1B[33m=\x1B[39m {\n' +
    ' \x1B[90m    |\x1B[39m                       \x1B[31m\x1B[1m^\x1B[22m\x1B[39m\n' +
    ' \x1B[90m  9 |\x1B[39m   \x1B[32m"preferredLocation"\x1B[39m\x1B[33m:\x1B[39m {\n' +
    ' \x1B[90m 10 |\x1B[39m     \x1B[32m"@id"\x1B[39m\x1B[33m:\x1B[39m \x1B[32m"https://id.volunteeringdata.io/volunteer_profile/preferredLocation"\x1B[39m\x1B[33m,\x1B[39m\n' +
    ' \x1B[90m 11 |\x1B[39m     \x1B[32m"@type"\x1B[39m\x1B[33m:\x1B[39m \x1B[32m"@id"\x1B[39m\x1B[33m,\x1B[39m\x1B[0m'
}

Node.js v25.1.0
[nodemon] app crashed - waiting for file changes before starting...

Shape:

# Volunteer Profile SHACL Shapes
# Validates volunteer profile data conformant to the Volunteer Profile Ontology
# For use with Solid applications

@prefix sh:              <http://www.w3.org/ns/shacl#> .
@prefix vp:              <https://id.volunteeringdata.io/volunteer-profile/> .
@prefix vps:             <https://id.volunteeringdata.io/volunteer-profile/shapes/> .
@prefix volunteering:    <https://id.volunteeringdata.io/schema/> .
@prefix rdf:             <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:            <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:             <http://www.w3.org/2001/XMLSchema#> .


## ============================================================================
## Volunteer Profile Shape
## ============================================================================

vps:VolunteerProfileShape
    a sh:NodeShape ;
    sh:targetClass vp:VolunteerProfile ;
    rdfs:label "Volunteer Pro...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes o-development/ldo#121

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Copilot AI and others added 2 commits January 2, 2026 21:13
…ript identifiers

Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix syntax error in TypeScript for volunteer profile shapes context Fix syntax error in TypeScript when shape filenames contain hyphens Jan 2, 2026
Copilot AI requested a review from jeswr January 2, 2026 21:18
@jeswr
Copy link
Collaborator

jeswr commented Jan 3, 2026

@copilot please use https://www.npmjs.com/package/to-valid-identifier rather than defining a custom toValidTypescriptIdentifier function.

…pm package

Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 3, 2026

@copilot please use https://www.npmjs.com/package/to-valid-identifier rather than defining a custom toValidTypescriptIdentifier function.

Done in 99b55f9. Replaced the custom toValidTypescriptIdentifier function with the to-valid-identifier package.

@jeswr jeswr marked this pull request as ready for review January 3, 2026 13:28
Copilot AI review requested due to automatic review settings January 3, 2026 13:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a TypeScript syntax error that occurs when SHACL/ShEx shape filenames contain hyphens (e.g., volunteer-profile-shapes). The fix replaces a custom identifier sanitization approach with the to-valid-identifier npm package, which properly converts filenames to valid TypeScript identifiers.

Key changes:

  • Introduced to-valid-identifier package to convert filenames with special characters into valid TypeScript identifiers
  • Updated all EJS templates to distinguish between identifierName (for TypeScript code) and fileName (for file paths and comments)
  • Modified build.ts to generate and pass identifierName to templates alongside the original fileName

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/cli/package.json Added to-valid-identifier dependency (v1.0.0)
package-lock.json Added lock entries for to-valid-identifier and its dependencies (@sindresorhus/base62 and reserved-identifiers)
packages/cli/src/build.ts Imported to-valid-identifier and added logic to convert fileName to identifierName before passing to templates
packages/cli/src/templates/context.ejs Updated to use identifierName for the exported constant name while keeping fileName for comments
packages/cli/src/templates/schema.ejs Updated to use identifierName for the exported constant name while keeping fileName for comments
packages/cli/src/templates/shapeTypes.ejs Updated to use identifierName for import and variable references while keeping fileName for file paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"prompts": "^2.4.2",
"rdf-dereference-store": "^1.4.0",
"rdf-namespaces": "^1.13.1",
"to-valid-identifier": "^1.0.0",
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The to-valid-identifier package requires Node.js >=20, but this package.json doesn't specify an engines field to enforce this requirement. Consider adding an engines field to prevent installation issues on older Node.js versions. For example:

"engines": {
  "node": ">=20"
}

This would make the requirement explicit and prevent users from encountering runtime errors when using Node.js versions below 20.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node that Node 18 is now EOL'd (https://nodejs.org/en/about/previous-releases)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added engines field with "node": ">=20" in d97cb64.

Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
@jeswr jeswr requested a review from jaxoncreed January 3, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants