Skip to content

Conversation

@abelpz
Copy link

@abelpz abelpz commented Feb 13, 2025

What it does

This PR introduces a custom JSON schema for Theia extension's package.json files. The schema extends the standard package.json schema while adding proper validation and IntelliSense support for Theia-specific properties such as theiaExtensions

This enhancement improves the developer experience by providing:

  • Auto-completion for Theia-specific properties
  • Proper property descriptions and type validation
  • Clear validation errors when required properties are missing
  • Better discoverability of available configuration options

How to test

  1. Open an existing Theia extension from the packages dir.
  2. Add the schema reference to the extension's package.json:
    {
      "$schema": "https://raw.githubusercontent.com/eclipse-theia/theia/master/schemas/theia-extension.schema.json",
      ...
    }
  3. Open the package.json file in VS Code or Theia
  4. Verify that you get:
    • IntelliSense suggestions for Theia-specific properties
    • Property descriptions when hovering over Theia-specific fields
  5. Try removing required properties and verify validation errors appear
  6. Test auto-completion for the theiaExtensions configuration

Follow-ups

  • Add other properties to the schema
  • Improve descriptions of properties
  • Consider creating documentation about all available schema properties
  • Adding this to the Yeoman generator for generated extensions

Breaking changes

  • No breaking changes introduced

Attribution

Review checklist

Reminder for reviewers

Copy link
Contributor

@martin-fleck-at martin-fleck-at left a comment

Choose a reason for hiding this comment

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

Hi @abelpz, thank you very much for that change! I really like the idea of extending the package.json with our own properties a lot! It's probably even a good idea to do it for the ApplicationProps as well some time in the future.

However, I do run into some troubles with the schema you provided. It does not really work for me in VS Code so I'm not sure this is a valid schema file to extend the existing package.json. I made some comments inline, could you please double check this?

Comment on lines +12 to +16
"description": "This helps people discover your package as it's listed in 'npm search'. Must include 'theia-extension'.",
"type": "array",
"items": {
"type": "string"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we need to re-specify these properties for keywords since it already exists in the base schema.

"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Theia package.json Schema",
"type": "object",
"$ref": "https://json.schemastore.org/package.json",
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the schema must follow something like this to properly extend the package.json:

  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Theia package.json Schema",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://json.schemastore.org/package"
    },
    {
      "required": [
        "keywords",
        "theiaExtensions"
      ],
      "properties": {
          ...
      }
    }
  ]
}

Comment on lines +17 to +20
"contains": {
"const": "theia-extension"
},
"minItems": 1
Copy link
Contributor

Choose a reason for hiding this comment

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

The error I get when not fulfilling this is Array does not contain required item. which might be confusing if you do not know the schema. Not sure if we really want to enforce this but I'm open to it.

"description": "Path to the secondary window module"
}
},
"additionalProperties": false
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure whether we want to be so restrictive but I'm open to it.

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Waiting on author in PR Backlog Mar 20, 2025
@martin-fleck-at
Copy link
Contributor

I would also need you to sign the ECA and your commit before we can do any merge of this. Thank you!

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Drive-by comment: The descriptions are not fully correct.

"properties": {
"frontend": {
"type": "string",
"description": "Path to the frontend module (used in browser and electron if frontendElectron is not provided)"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Path to the frontend module (used in browser and electron if frontendElectron is not provided)"
"description": "Path to the frontend module (used in browser and electron if frontendElectron and frontendOnly are both not provided)"

},
"frontendPreload": {
"type": "string",
"description": "Path to the frontend preload module"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Path to the frontend preload module"
"description": "Path to the frontend preload module (used if frontendOnlyPreload is not provided)"

@abelpz
Copy link
Author

abelpz commented Mar 20, 2025

Great @martin-fleck-at @sdirix. Thank you for replying to this, I appreciate all your comments. I didn't know much about how to describe this schema so I needed your help to define it better. I'll take a look at your reviews.

@ndoschek
Copy link
Member

Hi @abelpz, this PR has been open for some time without recent activity, just wondering if you are still planning to continue with it? TIA :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting on author

Development

Successfully merging this pull request may close these issues.

4 participants