Visitar URL original
Improve checks for invalid CSS function names · Issue #4048 · sass/sass · GitHub
Skip to content

Improve checks for invalid CSS function names #4048

Open

Description

@nex3

Currently, it's possible for users to define functions whose names differ from reserved names only by case, such as EXPRESSION() or URL(). These functions can't be invoked normally, because the logic for function calls is case-insensitive, but unlike their lowercase equivalents they're not forbidden at definition-time. We should make the invalid function name check case-insensitive to deprecate and eventually forbid these names.

Edit: I've updated the title to broaden the scope here a bit. There are a number of improvements to be made to this check, mostly in the form of loosening it for cases that aren't (or are no longer) of real concern.


Deprecation

Final Changes

Activity

  1. self-assigned this
    on Mar 10, 2025
  2. changed the title [-]Forbidden CSS function names should be case-insensitive[/-] [+]Improve checks for invalid CSS function names[/+] on Mar 17, 2025
  3. nex3 commented on Jul 30, 2025

    @nex3
    ContributorAuthor

    Hi @ugwudev, and thanks for reaching out! Implementing a deprecation isn't too difficult, but there are a few steps:

    1. In this repo, add the new deprecation to spec/deprecations.yaml. This is the shared source of truth for which deprecations exist, their names, and their documentation.

    2. In the https://github.com/sass/dart-sass repo, symlink this repo into build/sass, then run dart run grinder deprecations. This will add a deprecation enum entry for the new deprecation you just added. Then find the place where the deprecation should be emitted and emit it.

    3. In the https://github.com/sass/sass-spec repo, run npm run sass-spec -- --dart=<path/to/dart-sass> --interactive to run all the language tests. If it finds any language tests that are failing (likely because they're now using deprecated behavior), it'll give you an interactive menu for how to update them.

    4. Write some new tests to cover your new deprecations.

    5. Send out the pull requests. For the dart-sass pull request, make sure you include links to the other two pull requests so that it knows to run those tests; for the sass-spec pull request, make sure you include [skip dart-sass] since those tests are being run in the dart-sass repo anyway.

    You can see #4045, sass/sass-spec#2051, and sass/dart-sass#2540 as examples of PRs that add a new deprecation.

  4. nex3 commented on Aug 4, 2025

    @nex3
    ContributorAuthor

    I'm not sure what you mean by "a @debug deprecation", but generally deprecations should be emitted wherever it's easiest to detect the issue. The logger object that handles deprecations is piped throughout the codebase. In the case of function names, I'd expect the deprecation to be emitted in the parser (lib/src/parse/stylesheet.dart).

  5. nex3 commented on Aug 29, 2025

    @nex3
    ContributorAuthor

    I cloned the three repos (dart-sass, sass-spec, sass) and added a symlink from dart-sass/build to sass.

    It sounds like you might have this backwards: you should have a symlink from the sass repo to dart-sass/build/language. If that's still not working, try pasting your dart run grinder deprecations output here and I'll see if I can figure out what's going on.

    I also tried to emit the deprecation warning in stylesheet.dart, but with 3984 lines of code, I’m not sure where exactly it should go.

    The @function rule is parsed by the _functionRule() function.

  6. nex3 commented on Sep 3, 2025

    @nex3
    ContributorAuthor

    It's common that you'll get merge conflicts as the main branch evolves. How to handle them depends on how you're using Git, but if you're using the CLI you can use git pull origin main to pull in the latest version of the upstream code base. This will print out a list of conflicting files which you can then fix one-by-one in a text editor.

  7. added a commit that references this issue on Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions