Skip to content

Commit

Permalink
Simplify deprecation warning messages in console
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Jan 13, 2023
1 parent e1bb607 commit ff83ba8
Show file tree
Hide file tree
Showing 10 changed files with 496 additions and 497 deletions.
7 changes: 4 additions & 3 deletions lib/formatters/__tests__/stringFormatter.test.js
Expand Up @@ -145,7 +145,7 @@ path/to/file.css
source: 'file.css',
deprecations: [
{
text: 'Deprecated foo',
text: 'Deprecated foo.',
reference: 'bar',
},
],
Expand All @@ -160,7 +160,7 @@ path/to/file.css
source: 'file2.css',
deprecations: [
{
text: 'Deprecated foo',
text: 'Deprecated foo.',
reference: 'bar',
},
],
Expand All @@ -178,7 +178,8 @@ path/to/file.css
expect(output).toBe(stripIndent`
Invalid Option: Unexpected option for baz
Deprecation Warning: Deprecated foo See: bar`);
Deprecation Warning:
- Deprecated foo. See: bar`);
});

it('handles ignored file', () => {
Expand Down
21 changes: 11 additions & 10 deletions lib/formatters/stringFormatter.js
Expand Up @@ -47,22 +47,23 @@ function deprecationsFormatter(results) {
}

const seenText = new Set();
const lines = [];

return allDeprecationWarnings.reduce((output, warning) => {
if (seenText.has(warning.text)) return output;
for (const { text, reference } of allDeprecationWarnings) {
if (seenText.has(text)) continue;

seenText.add(warning.text);
seenText.add(text);

output += yellow('Deprecation Warning: ');
output += warning.text;
let line = ` ${dim('-')} ${text}`;

if (warning.reference) {
output += dim(' See: ');
output += dim(underline(warning.reference));
if (reference) {
line += dim(` See: ${underline(reference)}`);
}

return `${output}\n`;
}, '\n');
lines.push(line);
}

return ['', yellow('Deprecation Warning:'), ...lines, ''].join('\n');
}

/**
Expand Down
5 changes: 1 addition & 4 deletions lib/lintPostcssResult.js
Expand Up @@ -141,8 +141,5 @@ function isFixCompatible({ stylelint }) {
* @returns {void}
*/
function warnDeprecatedRule(result, ruleName) {
result.warn(
`The "${ruleName}" rule is deprecated and will be removed in the next major release.`,
{ stylelintType: 'deprecation' },
);
result.warn(`The "${ruleName}" rule is deprecated.`, { stylelintType: 'deprecation' });
}
244 changes: 122 additions & 122 deletions system-tests/001/__snapshots__/fs.test.js.snap

Large diffs are not rendered by default.

244 changes: 122 additions & 122 deletions system-tests/001/__snapshots__/no-fs.test.js.snap

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions system-tests/002/__snapshots__/fs.test.js.snap
Expand Up @@ -8,43 +8,43 @@ exports[`fs - invalid twbs buttons and their config 1`] = `
{
"deprecations": [
{
"text": "The "at-rule-semicolon-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-semicolon-space-before" rule is deprecated.",
},
{
"text": "The "at-rule-name-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-name-space-after" rule is deprecated.",
},
{
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated.",
},
{
"text": "The "max-empty-lines" rule is deprecated and will be removed in the next major release.",
"text": "The "max-empty-lines" rule is deprecated.",
},
{
"text": "The "number-leading-zero" rule is deprecated and will be removed in the next major release.",
"text": "The "number-leading-zero" rule is deprecated.",
},
{
"text": "The "selector-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-newline-before" rule is deprecated.",
},
{
"text": "The "selector-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-after" rule is deprecated.",
},
{
"text": "The "selector-list-comma-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-before" rule is deprecated.",
},
{
"text": "The "string-quotes" rule is deprecated and will be removed in the next major release.",
"text": "The "string-quotes" rule is deprecated.",
},
{
"text": "The "unicode-bom" rule is deprecated and will be removed in the next major release.",
"text": "The "unicode-bom" rule is deprecated.",
},
{
"text": "The "value-list-comma-newline-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-after" rule is deprecated.",
},
{
"text": "The "value-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-before" rule is deprecated.",
},
{
"text": "The "value-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-space-after" rule is deprecated.",
},
],
"errored": true,
Expand Down Expand Up @@ -87,55 +87,55 @@ exports[`fs - invalid twbs buttons and their config 1`] = `
"deprecations": [
{
"reference": undefined,
"text": "The "at-rule-semicolon-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-semicolon-space-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "at-rule-name-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-name-space-after" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "max-empty-lines" rule is deprecated and will be removed in the next major release.",
"text": "The "max-empty-lines" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "number-leading-zero" rule is deprecated and will be removed in the next major release.",
"text": "The "number-leading-zero" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "selector-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-newline-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "selector-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-after" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "selector-list-comma-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "string-quotes" rule is deprecated and will be removed in the next major release.",
"text": "The "string-quotes" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "unicode-bom" rule is deprecated and will be removed in the next major release.",
"text": "The "unicode-bom" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "value-list-comma-newline-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-after" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "value-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "value-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-space-after" rule is deprecated.",
},
],
"errored": true,
Expand Down
52 changes: 26 additions & 26 deletions system-tests/002/__snapshots__/no-fs.test.js.snap
Expand Up @@ -8,43 +8,43 @@ exports[`no-fs - invalid twbs buttons and their config 1`] = `
{
"deprecations": [
{
"text": "The "at-rule-semicolon-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-semicolon-space-before" rule is deprecated.",
},
{
"text": "The "at-rule-name-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-name-space-after" rule is deprecated.",
},
{
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated.",
},
{
"text": "The "max-empty-lines" rule is deprecated and will be removed in the next major release.",
"text": "The "max-empty-lines" rule is deprecated.",
},
{
"text": "The "number-leading-zero" rule is deprecated and will be removed in the next major release.",
"text": "The "number-leading-zero" rule is deprecated.",
},
{
"text": "The "selector-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-newline-before" rule is deprecated.",
},
{
"text": "The "selector-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-after" rule is deprecated.",
},
{
"text": "The "selector-list-comma-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-before" rule is deprecated.",
},
{
"text": "The "string-quotes" rule is deprecated and will be removed in the next major release.",
"text": "The "string-quotes" rule is deprecated.",
},
{
"text": "The "unicode-bom" rule is deprecated and will be removed in the next major release.",
"text": "The "unicode-bom" rule is deprecated.",
},
{
"text": "The "value-list-comma-newline-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-after" rule is deprecated.",
},
{
"text": "The "value-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-before" rule is deprecated.",
},
{
"text": "The "value-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-space-after" rule is deprecated.",
},
],
"errored": true,
Expand Down Expand Up @@ -87,55 +87,55 @@ exports[`no-fs - invalid twbs buttons and their config 1`] = `
"deprecations": [
{
"reference": undefined,
"text": "The "at-rule-semicolon-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-semicolon-space-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "at-rule-name-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "at-rule-name-space-after" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "declaration-block-semicolon-newline-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "max-empty-lines" rule is deprecated and will be removed in the next major release.",
"text": "The "max-empty-lines" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "number-leading-zero" rule is deprecated and will be removed in the next major release.",
"text": "The "number-leading-zero" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "selector-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-newline-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "selector-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-after" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "selector-list-comma-space-before" rule is deprecated and will be removed in the next major release.",
"text": "The "selector-list-comma-space-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "string-quotes" rule is deprecated and will be removed in the next major release.",
"text": "The "string-quotes" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "unicode-bom" rule is deprecated and will be removed in the next major release.",
"text": "The "unicode-bom" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "value-list-comma-newline-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-after" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "value-list-comma-newline-before" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-newline-before" rule is deprecated.",
},
{
"reference": undefined,
"text": "The "value-list-comma-space-after" rule is deprecated and will be removed in the next major release.",
"text": "The "value-list-comma-space-after" rule is deprecated.",
},
],
"errored": true,
Expand Down

0 comments on commit ff83ba8

Please sign in to comment.