Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tally of fixable problems to string and verbose formatters #7539

Merged
merged 9 commits into from
Feb 28, 2024
5 changes: 5 additions & 0 deletions .changeset/selfish-points-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Added: Show a count of fixable problems in the string formatter
m-allanson marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 17 additions & 14 deletions lib/__tests__/standalone-fix.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ describe('writing fixes to files', () => {
expect(result.code).toBeUndefined();
expect(getCleanOutput(result.report)).toBe(stripIndent`
stylesheet.css
1:1 × Unknown rule at-rule-name-case at-rule-name-case
7:1 × Unexpected empty comment comment-no-empty
1:1 × Unknown rule at-rule-name-case at-rule-name-case
7:1 × Unexpected empty comment comment-no-empty

2 problems (2 errors, 0 warnings)
× 2 problems (2 errors, 0 warnings)
`);
});

Expand Down Expand Up @@ -248,9 +248,10 @@ it('one rule being disabled', async () => {
expect(result.code).toBe(code);
expect(getCleanOutput(result.report)).toBe(stripIndent`
test.css
3:11 × Expected "#ffffff" to be "#fff" color-hex-length
3:11 × Expected "#ffffff" to be "#fff" color-hex-length

1 problem (1 error, 0 warnings)
× 1 problem (1 error, 0 warnings)
1 error potentially fixable with the "--fix" option.
`);
});

Expand Down Expand Up @@ -298,10 +299,11 @@ it('two rules being disabled', async () => {
expect(result.code).toBe(code);
expect(getCleanOutput(result.report)).toBe(stripIndent`
test.css
2:3 × Unexpected duplicate selector "a", first used at line 2 no-duplicate-selectors
3:11 × Expected "#ffffff" to be "#fff" color-hex-length
2:3 × Unexpected duplicate selector "a", first used at line 2 no-duplicate-selectors
3:11 × Expected "#ffffff" to be "#fff" color-hex-length

2 problems (2 errors, 0 warnings)
× 2 problems (2 errors, 0 warnings)
1 error potentially fixable with the "--fix" option.
`);
});

Expand Down Expand Up @@ -348,9 +350,9 @@ it('one rule being disabled and another still autofixing', async () => {
}`);
expect(getCleanOutput(result.report)).toBe(stripIndent`
test.css
2:3 × Unexpected duplicate selector "a", first used at line 2 no-duplicate-selectors
2:3 × Unexpected duplicate selector "a", first used at line 2 no-duplicate-selectors

1 problem (1 error, 0 warnings)
× 1 problem (1 error, 0 warnings)
`);
});

Expand All @@ -370,9 +372,10 @@ it("doesn't return the fixed code if the fix option is false", async () => {
expect(result.code).toBeUndefined();
expect(getCleanOutput(result.report)).toBe(stripIndent`
test.css
1:12 × Expected "#ffffff" to be "#fff" color-hex-length
1:12 × Expected "#ffffff" to be "#fff" color-hex-length

1 problem (1 error, 0 warnings)
× 1 problem (1 error, 0 warnings)
1 error potentially fixable with the "--fix" option.
`);
});

Expand All @@ -394,8 +397,8 @@ it('returns the original code if the fix option is true but the code is not fixa
expect(result.code).toBe(code);
expect(getCleanOutput(result.report)).toBe(stripIndent`
test.css
1:12 × Unexpected invalid hex color "#y3" color-no-invalid-hex
1:12 × Unexpected invalid hex color "#y3" color-no-invalid-hex

1 problem (1 error, 0 warnings)
× 1 problem (1 error, 0 warnings)
`);
});