Repository: conda-forge/conda-smithy

Issue:
False positive in `lint_recipe_name`
### Solution to issue cannot be found in the documentation.

- [x] I checked the documentation.

### Issue

In `lint_recipe_name`, you can get a false positive with the following recipe:

```yml
# recipe.yaml
context:
  version: '1.20.0'

# Note: This recipe is specifically designed to work well with the autotick bot.
# Also refer to https://github.com/conda-forge/rust-feedstock/blob/main/recipe/meta.yaml.
package:
  name: ${{ polars_variant }}
  version: ${{ version }}

# ...
```

You need to specify `polars_variant` in `conda_build_config.yaml`:

```yml
polars_variant:
  - polars  # [not ppc64le]
  - polars-lts-cpu
  - polars-u64-idx  # [not ppc64le]
```

this occurred in https://github.com/conda-forge/polars-feedstock/pull/303

https://github.com/conda-forge/conda-smithy/blob/fcbd049cb268eb5c8732f4b5e498bf011398f5ea/conda_smithy/linter/conda_recipe_v1_linter.py#L132-L140

### Installed packages

```shell
-
```

### Environment info

```shell
-
```

Discussion:

Patch:
diff --git a/conda_smithy/linter/conda_recipe_v1_linter.py b/conda_smithy/linter/conda_recipe_v1_linter.py
index 53be7cc1..c07c760d 100644
--- a/conda_smithy/linter/conda_recipe_v1_linter.py
+++ b/conda_smithy/linter/conda_recipe_v1_linter.py
@@ -134,6 +134,11 @@ def lint_recipe_name(
     lints: list[str],
 ) -> None:
     name = get_recipe_name(recipe_content)
+    # Avoid false positives if the recipe is using variables
+    # from conda_build_config.yaml.
+    # https://github.com/conda-forge/conda-smithy/issues/2224
+    if "${{" in name:
+        return
 
     lint_msg = _lint_recipe_name(name)
     if lint_msg:
diff --git a/news/2248-v1-recipe-name-var.rst b/news/2248-v1-recipe-name-var.rst
new file mode 100644
index 00000000..222647d5
--- /dev/null
+++ b/news/2248-v1-recipe-name-var.rst
@@ -0,0 +1,23 @@
+**Added:**
+
+* <news item>
+
+**Changed:**
+
+* <news item>
+
+**Deprecated:**
+
+* <news item>
+
+**Removed:**
+
+* <news item>
+
+**Fixed:**
+
+* Fixed a false positive when a v1 recipe name refers to a variable from ``conda_build_config.yaml`` (#2248).
+
+**Security:**
+
+* <news item>


Test patch:
diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py
index ef8264e8..2a95b3ba 100644
--- a/tests/test_lint_recipe.py
+++ b/tests/test_lint_recipe.py
@@ -1793,22 +1793,20 @@ linter:
         lints, _ = linter.lintify_meta_yaml(
             meta_with_context, recipe_version=1
         )
-        expected_message = (
-            "Recipe name has invalid characters. only lowercase alpha, "
-            "numeric, underscores, hyphens and dots allowed"
-        )
         self.assertIn(expected_message, lints)
 
         meta_with_context = {"recipe": {"name": "mp++"}, "outputs": []}  # noqa
         lints, _ = linter.lintify_meta_yaml(
             meta_with_context, recipe_version=1
         )
-        expected_message = (
-            "Recipe name has invalid characters. only lowercase alpha, "
-            "numeric, underscores, hyphens and dots allowed"
-        )
         self.assertIn(expected_message, lints)
 
+        # variable may be defined e.g. in conda_build_config.yaml
+        # https://github.com/conda-forge/conda-smithy/issues/2224
+        meta = {"package": {"name": "${{ variant_name }}"}}
+        lints, _ = linter.lintify_meta_yaml(meta, recipe_version=1)
+        self.assertNotIn(expected_message, lints)
+
     def test_end_empty_line(self):
         bad_contents = [
             # No empty lines at the end of the file