Skip to content

Support template literals and constants in token-format - #162

Merged
Darshan808 merged 3 commits into
jupyterlab:mainfrom
Yash990-bit:token-format-static-strings
Oct 28, 2026
Merged

Darshan808 merged 3 commits into
jupyterlab:mainfrom
Yash990-bit:token-format-static-strings

Conversation

@Yash990-bit

Copy link
Copy Markdown
Contributor

Summary

Previously, token-format only checked raw string literals passed as the first argument to new Token(...). Token IDs declared via template literals, constants, or type-aware identifiers were skipped.

This PR updates token-format to use resolveStaticString and getTypeServices:

  • Statically validates template literals (e.g. new Token(`${PKG}:ISymbol`) and new Token(`${PKG}:kebab-case`))
  • Statically validates constants and identifiers
  • Adds type-aware resolution support when type services are available
  • Updates rule documentation and adds unit test cases

Resolve #161

Copilot AI balanced review requested due to automatic review settings October 19, 2026 19:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes reuse established utilities and include regression coverage, with no blocking issues identified; tests were not executed.

No open issues 🎉

What changed in this PR

Extends token-format beyond raw string literals using existing static-string and type-resolution utilities, addressing #161.

Changes:

  • Validates resolvable templates, constants, and string-literal-typed expressions.
  • Adds static and type-aware test cases.
  • Documents the expanded support.
File Description
website/​docs/​rules/​token-format.md Documents supported token ID expressions.
tests/​jupyter-token-format.test.ts Adds template, constant, and type-aware coverage.
src/​rules/​token-format.ts Uses shared resolution utilities and skips spread arguments.

Review effort: Balanced

@Yash990-bit
Yash990-bit marked this pull request as draft October 19, 2026 19:26

@Darshan808 Darshan808 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see this is in draft, but gave few feedbacks.

Comment thread tests/jupyter-token-format.test.ts Outdated
Comment thread website/docs/rules/token-format.md Outdated
@Darshan808 Darshan808 added the enhancement New feature or request label Oct 24, 2026
@Yash990-bit
Yash990-bit marked this pull request as ready for review October 24, 2026 10:44
@Yash990-bit

Copy link
Copy Markdown
Contributor Author

Hi @Darshan808 when you get a chance, could you please take a look at this PR?

Comment thread website/docs/rules/token-format.md Outdated

@Darshan808 Darshan808 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@Darshan808
Darshan808 merged commit 3b8c32b into jupyterlab:main Oct 28, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in CFP '25 tracking Oct 28, 2026
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

Status: Done

Development

Successfully merging this pull request may close these issues.

token-format: support template literals and constants using resolveStaticString

3 participants