Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check constants passed to arguments of fromJSON calls are valid as JSON #464

Closed
rhysd opened this issue Oct 21, 2024 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@rhysd
Copy link
Owner

rhysd commented Oct 21, 2024

I noticed that it is popular to pass a string constant to fromJSON() to create an immediate array/object value. Here is a simple example:

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    if: ${{ contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) }}
    steps:
      - run: echo hello

It would be nice to check the string literals are valid as JSON.

@rhysd rhysd added the enhancement New feature or request label Oct 21, 2024
@rhysd rhysd changed the title Check constants in fromJSON call arguments Check constants in arguments of fromJSON calls Oct 21, 2024
@rhysd rhysd changed the title Check constants in arguments of fromJSON calls Check constants in arguments of fromJSON calls are valid as JSON Oct 21, 2024
@rhysd rhysd changed the title Check constants in arguments of fromJSON calls are valid as JSON Check constants passed to arguments of fromJSON calls are valid as JSON Oct 22, 2024
@rhysd
Copy link
Owner Author

rhysd commented Nov 2, 2024

It is also possible to strongly type the return value of fromJSON but I'm not sure this is really needed.

@rhysd rhysd closed this as completed in 919b72a Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant