Skip to content

Commit 44eb3fd

Browse files
committed
Fix --fatal-deprecation adding obsolete ones
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
1 parent 52fc718 commit 44eb3fd

File tree

7 files changed

+54
-4
lines changed

7 files changed

+54
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.94.2
2+
3+
* Using `--fatal-deprecation 1.92.0` no longer emits warnings about
4+
deprecations that are obsolete.
5+
16
## 1.94.1
27

38
* No user-visible changes.

lib/src/deprecation.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ enum Deprecation {
224224
var range = VersionRange(max: version, includeMax: true);
225225
return {
226226
for (var deprecation in Deprecation.values)
227-
if (deprecation.deprecatedIn.andThen(range.allows) ?? false)
227+
if ((deprecation.deprecatedIn.andThen(range.allows) ?? false) &&
228+
deprecation.obsoleteIn == null)
228229
deprecation,
229230
};
230231
}

pkg/sass-parser/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.35
2+
3+
* No user-visible changes.
4+
15
## 0.4.34
26

37
* No user-visible changes.

pkg/sass_api/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 16.0.2
2+
3+
* No user-visible changes.
4+
15
## 16.0.1
26

37
* No user-visible changes.

pkg/sass_api/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 16.0.1
5+
version: 16.0.2
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: ">=3.6.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.94.1
13+
sass: 1.94.2
1414

1515
dev_dependencies:
1616
dartdoc: ">=8.0.14 <10.0.0"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.94.1
2+
version: 1.94.2
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

test/deprecations_test.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ library;
88
import 'package:test/test.dart';
99

1010
import 'package:sass/sass.dart';
11+
import 'package:pub_semver/pub_semver.dart';
1112

1213
void main() {
1314
// Deprecated in all version of Dart Sass
@@ -151,6 +152,41 @@ void main() {
151152
);
152153
});
153154
});
155+
156+
group('Deprecation.forVersion', () {
157+
test('includes deprecations as of that version', () {
158+
final version = Version.parse('1.79.0');
159+
final deprecations = Deprecation.forVersion(version);
160+
161+
expect(
162+
deprecations,
163+
contains(Deprecation.colorFunctions),
164+
reason: 'color-functions deprecated in 1.79 (and not obsolete)',
165+
);
166+
});
167+
168+
test('excludes deprecations of newer versions', () {
169+
final version = Version.parse('1.79.0');
170+
final deprecations = Deprecation.forVersion(version);
171+
172+
expect(
173+
deprecations,
174+
isNot(contains(Deprecation.import)),
175+
reason: 'import deprecated as of 1.80',
176+
);
177+
});
178+
179+
test('excludes deprecations that are obsolete', () {
180+
final version = Version.parse('1.79.0');
181+
final deprecations = Deprecation.forVersion(version);
182+
183+
expect(
184+
deprecations,
185+
isNot(contains(Deprecation.mixedDecls)),
186+
reason: 'mixed-decls deprecated in 1.77.7 but obsolete in 1.92.0',
187+
);
188+
});
189+
});
154190
}
155191

156192
/// Confirms that [source] will error if [deprecation] is fatal.

0 commit comments

Comments
 (0)