Skip to content

Commit

Permalink
Deprecate duplicate !global and !default declarations (#1931)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Apr 7, 2023
1 parent 702a7ee commit 283bdc0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.62.0

* Deprecate the use of multiple `!global` or `!default` flags on the same
variable. This deprecation is named `duplicate-var-flags`.

## 1.61.0

* **Potentially breaking change:** Drop support for End-of-Life Node.js 12.
Expand Down
5 changes: 5 additions & 0 deletions lib/src/deprecation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ enum Deprecation {
deprecatedIn: '1.56.0',
description: 'Passing invalid units to built-in functions.'),

duplicateVariableFlags('duplicate-var-flags',
deprecatedIn: '1.62.0',
description:
'Using !default or !global multiple times for one variable.'),

/// Deprecation for `@import` rules.
import.future('import', description: '@import rules.'),

Expand Down
14 changes: 14 additions & 0 deletions lib/src/parse/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,25 @@ abstract class StylesheetParser extends Parser {
while (scanner.scanChar($exclamation)) {
var flag = identifier();
if (flag == 'default') {
if (guarded) {
logger.warnForDeprecation(
Deprecation.duplicateVariableFlags,
'!default should only be written once for each variable.\n'
'This will be an error in Dart Sass 2.0.0.',
span: scanner.spanFrom(flagStart));
}

guarded = true;
} else if (flag == 'global') {
if (namespace != null) {
error("!global isn't allowed for variables in other modules.",
scanner.spanFrom(flagStart));
} else if (global) {
logger.warnForDeprecation(
Deprecation.duplicateVariableFlags,
'!global should only be written once for each variable.\n'
'This will be an error in Dart Sass 2.0.0.',
span: scanner.spanFrom(flagStart));
}

global = true;
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.3.0

* No user-visible changes.

## 6.2.0

* No user-visible changes.
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 6.2.0
version: 6.3.0-dev
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: ">=2.17.0 <3.0.0"

dependencies:
sass: 1.61.0
sass: 1.62.0

dev_dependencies:
dartdoc: ^5.0.0
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.61.0
version: 1.62.0-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit 283bdc0

Please sign in to comment.