Skip to content

Commit d388887

Browse files
committed
Forbid multiple !global or !default flags on the same variable
Closes #604
1 parent 473d83a commit d388887

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
parsing associated with it. It is now parsed like any other unknown plain CSS
88
at-rule, where Sass features are only allowed within `#{}` interpolation.
99

10+
* **Breaking change:** A variable definition may now only have a single
11+
`!global` flag or `!default` flag, or one of each.
12+
1013
### Bogus Combinators
1114

1215
* **Breaking change:** Selectors with more than one combinator in a row, such as

lib/src/deprecation.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum Deprecation {
1515
// DO NOT EDIT. This section was generated from the language repo.
1616
// See tool/grind/generate_deprecations.dart for details.
1717
//
18-
// Checksum: f9088047deb7019c0d619480b54cea07a65abbb4
18+
// Checksum: d1c9c01ca8d2b69e39b7371d774c9c86349efdef
1919

2020
/// Deprecation for passing a string directly to meta.call().
2121
callString('call-string',
@@ -70,6 +70,7 @@ enum Deprecation {
7070
/// Deprecation for using !default or !global multiple times for one variable.
7171
duplicateVarFlags('duplicate-var-flags',
7272
deprecatedIn: '1.62.0',
73+
obsoleteIn: '2.0.0',
7374
description:
7475
'Using !default or !global multiple times for one variable.'),
7576

lib/src/parse/stylesheet.dart

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,8 @@ abstract class StylesheetParser extends Parser {
255255
switch (identifier()) {
256256
case 'default':
257257
if (guarded) {
258-
warnings.add((
259-
deprecation: Deprecation.duplicateVarFlags,
260-
message:
261-
'!default should only be written once for each variable.\n'
262-
'This will be an error in Dart Sass 2.0.0.',
263-
span: scanner.spanFrom(flagStart),
264-
));
258+
error('Only one !default is allowed per declaration.',
259+
scanner.spanFrom(flagStart));
265260
}
266261
guarded = true;
267262

@@ -272,13 +267,8 @@ abstract class StylesheetParser extends Parser {
272267
scanner.spanFrom(flagStart),
273268
);
274269
} else if (global) {
275-
warnings.add((
276-
deprecation: Deprecation.duplicateVarFlags,
277-
message:
278-
'!global should only be written once for each variable.\n'
279-
'This will be an error in Dart Sass 2.0.0.',
280-
span: scanner.spanFrom(flagStart),
281-
));
270+
error('Only one !global is allowed per declaration.',
271+
scanner.spanFrom(flagStart));
282272
}
283273
global = true;
284274

0 commit comments

Comments
 (0)