Skip to content

--fatal-deprecation excludes obsolete Deprecations - #2671

Merged
jathak merged 2 commits into
sass:mainfrom
halo:no-fatal-obsolete-warnings
Nov 19, 2025
Merged

jathak merged 2 commits into
sass:mainfrom
halo:no-fatal-obsolete-warnings

Conversation

@halo

@halo halo commented Nov 5, 2025 •

Copy link
Copy Markdown
Contributor

Using --fatal-deprecation 1.93.3 causes unrelated warnings:

Warning: mixed-decls deprecation is obsolete, so does not need to be made fatal.
Warning: type-function deprecation is obsolete, so does not need to be made fatal.

I think it is because Depdecation.forVersion does not filter out deprecations that have been marked as obsoleteIn.

This is my attempt to solve it. I hope I don't have to sign the Google Individual Contributor License Agreement, because I don't use a Google Account (I see no way to sign the agreement without an account, though I'm fine with agreeing to its contents, although my code is just a single conditional and the obvious related test). Also, the newly added test passes, and the grinder linted my code (as far as I can tell), but I could not run the -x node tests for some reason.

If this is unacceptable feel free to close this PR. It was a nice exercise learning something about Dart! Thank you for your time.

PS: This project is so well maintained and I'm grateful to @nex3 who kept in in shape for years and put so much effort in documentation and figuring out a path to go forward with the SASS syntax as CSS evolves more and more. Thank you!

Related: #2647

@jathak jathak 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.

Good catch with this! --fatal-deprecation <version> should definitely not make deprecations that were obsolete as of <version> fatal.

However, I actually think it makes more sense to exclude all deprecations that are obsolete in the currently running version from --fatal-deprecation, even if they weren't yet obsolete in the <version> passed to the flag.

If for instance, --fatal-deprecation 1.91.0 was added to a user's config when 1.91.0 was the current version, it makes sense for the flag to continue to work without warnings in 1.92.0 when mixed-decls and type-function are obsoleted without the user having to bump the fatal version to 1.92.0, which would additionally make with-private fatal.

Comment thread lib/src/deprecation.dart Outdated
/// Returns the set of all deprecations done in or before [version].
static Set<Deprecation> forVersion(Version version) {
var range = VersionRange(max: version, includeMax: true);
static Set<Deprecation> forVersion(Version version, [Version? current]) {

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.

A comparison to the current version is not necessary here. This should just exclude any deprecation where obsoleteIn is non-null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

xzMs8O1KQh17i

@halo

halo commented Nov 11, 2025 •

Copy link
Copy Markdown
Contributor Author

I admit I had to read your last paragraph 5 times before it finally sank in 😆 You are perfectly right.

The tests are somewhat lacking, because I don't know how stub the obsoletion data or sass version numbers.

(Edit: Sorry for all the --force. But I think I should have it now. Again 😄)

@halo
halo marked this pull request as ready for review November 11, 2025 20:50

@jathak jathak 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.

Can you bump the minor versions of the packages and add changelog entries so we can release this fix? (see here for instructions)

final version = Version.parse('1.79.0');
final deprecations = Deprecation.forVersion(version);

expect(

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.

Just check that a couple of the currently obsolete deprecations are excluded here. We use deprecations.yaml in the language repo as a single-source of truth for the current list of deprecations and don't want to have to manually update the list anywhere else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understand. I added two regression tests now (so that I don't break the current functionality) and one test for the intended fix (excluding obsolete deprecations).

Using `--fatal-deprecation 1.92.0` would emit: "Warning: mixed-decls
deprecation is obsolete, so does not need to be made fatal".
This commit avoids these warnings by excluding obsolete deprecations.
See also #2647
Comment thread pkg/sass_api/CHANGELOG.md
@@ -1,3 +1,7 @@
## 16.0.2

* No user-visible changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure about this (whether this is the Dart API or the JS API or both and if they were affected or not).

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.

Yeah, Deprecation.forVersion is only exposed in the Dart API. I've added a changelog entry for this to the main Dart Sass changelog

@halo
halo requested a review from jathak November 13, 2025 14:44

@jathak jathak 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 for this! Sorry for the delay in reviewing; missed it last week and then had jury duty this week.

@jathak
jathak merged commit 18fddef into sass:main Nov 19, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants