Skip to content

Commit bc88ccd

Browse files
authored
Add documentation for how to silence deprecations (#1104)
1 parent 4df1f66 commit bc88ccd

12 files changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## Can I Silence the Warnings?
2+
3+
Sass provides a powerful suite of options for managing which deprecation
4+
warnings you see and when.
5+
6+
### Terse and Verbose Mode
7+
8+
By default, Sass runs in terse mode, where it will only print each type of
9+
deprecation warning five times before it silences additional warnings. This
10+
helps ensure that users know when they need to be aware of an upcoming breaking
11+
change without creating an overwhelming amount of console noise.
12+
13+
If you run Sass in verbose mode instead, it will print *every* deprecation
14+
warning it encounters. This can be useful for tracking the remaining work to be
15+
done when fixing deprecations. You can enable verbose mode using the
16+
[`--verbose` flag] on the command line, or the [`verbose` option] in the
17+
JavaScript API.
18+
19+
[`--verbose` flag]: /documentation/cli/dart-sass/#verbose
20+
[`verbose` option]: /documentation/js-api/interfaces/Options/#verbose
21+
22+
{% headsUp %}
23+
When running from the [JS API], Sass doesn't share any information across
24+
compilations, so by default it'll print five warnings for *each stylesheet*
25+
that's compiled. However, you can fix this by writing (or asking the author of
26+
your favorite framework's Sass plugin to write) a [custom `Logger`] that only
27+
prints five errors per deprecation and can be shared across multiple
28+
compilations.
29+
30+
[JS API]: /documentation/js-api/
31+
[custom `Logger`]: https://sass-lang.com/documentation/js-api/interfaces/Logger-1/
32+
{% endheadsUp %}
33+
34+
### Silencing Deprecations in Dependencies
35+
36+
Sometimes, your dependencies have deprecation warnings that you can't do
37+
anything about. You can silence deprecation warnings from dependencies while
38+
still printing them for your app using the [`--quiet-deps` flag] on the command
39+
line, or the [`quietDeps` option] in the JavaScript API.
40+
41+
[`--quiet-deps` flag]: /documentation/cli/dart-sass/#quiet-deps
42+
[`quietDeps` option]: /documentation/js-api/interfaces/Options/#quietDeps
43+
44+
For the purposes of this flag, a "dependency" is any stylesheet that's not just
45+
a series of relative loads from the entrypoint stylesheet. This means anything
46+
that comes from a load path, and most stylesheets loaded through custom
47+
importers.
48+
49+
### Silencing Specific Deprecations
50+
51+
If you know that one particular deprecation isn't a problem for you, you can
52+
silence warnings for that specific deprecation using the
53+
[`--silence-deprecation` flag] on the command line, or the [`silenceDeprecations`
54+
option] in the JavaScript API.
55+
56+
[`--silence-deprecation` flag]: /documentation/cli/dart-sass/#silence-deprecation
57+
[`silenceDeprecations` option]: /documentation/js-api/interfaces/Options/#silenceDeprecations
58+
59+
{% headsUp %}
60+
This option is only available in the [modern JS API].
61+
62+
[modern JS API]: /documentation/js-api/#md:usage
63+
{% endheadsUp %}

source/documentation/breaking-changes/abs-percent.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ return `-10%` which in the browser would be `50px`.
1919
For this reason, we are deprecating the global abs() function with a percentage.
2020
To preserve the current behavior, use `math.abs()` instead.
2121

22+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/bogus-combinators.md

+2
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ invalid CSS from the compiled CSS, with one exception: we _won't_ omit selectors
6161
that begin with a leading combinator, since they may be used from a nested
6262
`@import` rule or `meta.load-css()` mixin. However, we don't encourage this
6363
pattern and will drop support for it in Dart Sass 2.0.0.
64+
65+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/css-function-mixin.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ deprecation warning named `css-function-mixin`.
3838
Between Dart Sass 2.0.0 and the release of Dart Sass's support for plain CSS
3939
functions and mixins, functions and mixins will not be allowed to have names
4040
that begin with `--`.
41+
42+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/duplicate-var-flags.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ each `!global` or `!default` flag, this will be a syntax error. This means that
2121

2222
Until Dart Sass 2.0.0 is released, multiple copies of a flag just produce
2323
deprecation warnings.
24+
25+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/function-units.md

+2
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,5 @@ units or with units other than `%` to `color.mix()` or `color.invert()`.
211211

212212
In Dart Sass 2.0.0, `list.nth()` and `list.set-nth()` will throw errors if
213213
they're passed an index `$n` with a unit.
214+
215+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/media-logic.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ Fortunately, these came up very infrequently in practice.
2828
First, we emitted deprecation warnings for the previous ambiguous cases. These
2929
will have suggestions for how to preserve the existing behavior or how to use
3030
the new CSS syntax.
31+
32+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/mixed-decls.md

+2
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,5 @@ declarations in `& {}`:
116116
&
117117
font-weight: normal
118118
{% endcodeExample %}
119+
120+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/moz-document.md

+2
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ First, we'll emit deprecation warnings for all usages of `@-moz-document` except
3535
for the empty url-prefix hack.
3636

3737
In Dart Sass 2.0, `@-moz-document` will be treated as an unknown at-rule.
38+
39+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/slash-div.md

+2
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ use `math.div()` and `list.slash()`.
131131
$ npm install -g sass-migrator
132132
$ sass-migrator division **/*.scss
133133
```
134+
135+
{% render 'silencing_deprecations' %}

source/documentation/breaking-changes/strict-unary.md

+2
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ existing behavior of these stylesheets.
6262
$ npm install -g sass-migrator
6363
$ sass-migrator strict-unary **/*.scss
6464
```
65+
66+
{% render 'silencing_deprecations' %}

source/documentation/cli/dart-sass.md

+10
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,16 @@ Error: Incompatible units em and px.
429429
test.scss 1:9 root stylesheet
430430
```
431431

432+
#### `--verbose`
433+
434+
This flag tells Sass to emit _all_ deprecation warnings when compiling. By
435+
default, Sass only emits five warnings for a given deprecation type when
436+
deprecated features are used, and silences any warnings beyond that.
437+
438+
```shellsession
439+
$ sass --verbose style.scss style.css
440+
```
441+
432442
#### `--quiet`
433443

434444
This flag (abbreviated `-q`) tells Sass not to emit any warnings when compiling.

0 commit comments

Comments
 (0)