Repository navigation
Fix mise warning #181
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
Fix mise warning #181
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -302,13 +302,20 @@ tool_versions contains [dir, version] if { | |
| } | ||
|
|
||
| # Every [vars]/[env] string, tagged with where it came from for the message. | ||
| # An entry is either the string itself or mise's directive table, whose `default` mise loads the same way. | ||
| config_strings contains entry if { | ||
| some file in input | ||
| is_mise(file) | ||
| some kind in ["vars", "env"] | ||
| some key, value in object.get(file.contents, kind, {}) | ||
| is_string(value) | ||
| entry := {"path": file.path, "kind": kind, "key": key, "value": value} | ||
| entry := {"path": file.path, "kind": kind, "key": key, "value": entry_string(value)} | ||
| } | ||
|
|
||
| entry_string(value) := value if is_string(value) | ||
|
|
||
| entry_string(value) := value.default if { | ||
| is_object(value) | ||
| is_string(value.default) | ||
| } | ||
|
|
||
| # An install path embeds a tool's version as the segment right after the tool's install dir. | ||
|
|
@@ -337,6 +344,31 @@ deny contains msg if { | |
| ) | ||
| } | ||
|
|
||
| # A [vars] value must double every `$` that is meant for a shell. | ||
| # mise expands `$NAME` and `${NAME}` in a [vars] value against the environment it loads the config in, before any | ||
| # task runs; a task `run` body gets no such pass. A shell snippet kept in [vars] -- a variable it sets, a `${OS:-}` | ||
| # guard -- therefore reaches mise first, which substitutes a name the loading environment happens to set and leaves | ||
| # an unset one in place, warning on every load: | ||
| # mise WARN env var 'tsgolint' is not defined and will be left unexpanded, referenced by `tsgolint_env` in | ||
| # D:\a\core\core\.mise\config.js.toml. Use ${tsgolint:-} to default to an empty string and suppress this warning. | ||
| # `$$` is mise's escape for a literal `$`, so write `$$name` for the shell, and `{{ env.NAME }}` to read the loading | ||
| # environment on purpose. An odd run of `$` before a name or `{` is the unescaped case; `$(` and `$1` are never | ||
| # expanded, so either spelling passes. A warning only fires where the template around the snippet renders it, which | ||
| # can be one OS alone, so this reads the TOML unrendered to catch it on every lane. Check-only: conftest has no fix | ||
| # pass, and the right rewrite depends on whether the value meant the shell or the loading environment. | ||
| unescaped_dollar := `(?:^|[^$])(?:\$\$)*(\$\{?[A-Za-z_][A-Za-z0-9_]*)` | ||
|
|
||
| deny contains msg if { | ||
| some entry in config_strings | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check table-form If a config uses
|
||
| entry.kind == "vars" | ||
| tokens := {m[1] | some m in regex.find_all_string_submatch_n(unescaped_dollar, entry.value, -1)} | ||
| count(tokens) > 0 | ||
| msg := sprintf( | ||
| "%s: [vars] %q has unescaped %s -- write $$ for the shell, or {{ env.NAME }} for the environment", | ||
| [entry.path, entry.key, concat(", ", sort(tokens))], | ||
| ) | ||
| } | ||
|
|
||
| tool_version_str(spec) := spec if is_string(spec) | ||
|
|
||
| tool_version_str(spec) := spec.version if is_object(spec) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: edge-toolkit/core
Length of output: 5286
Script executed:
Repository: edge-toolkit/core
Length of output: 41911
Script executed:
Repository: edge-toolkit/core
Length of output: 27729
Script executed:
Repository: edge-toolkit/core
Length of output: 20825
Keep the Windows tsgolint setup independent of shell expansion.
With
MISE_ENV_SHELL_EXPAND=false, both oxlint tasks export a PID-prefixedOXLINT_TSGOLINT_PATHand can fail instead of running type-aware linting. Make the setup work with either setting while preserving the required dollar escaping. Users can temporarily enable shell expansion for these tasks.