Skip to content

Commit

Permalink
Fix unit test failures caused by removed rule in Stylelint v16
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Mar 22, 2024
1 parent cd5b368 commit 9cf6812
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

exports[`warningToDiagnostic should add a rule documentation URL if a matching rule exists 1`] = `
Object {
"code": "color-hex-case",
"code": "color-no-invalid-hex",
"codeDescription": Object {
"href": "https://stylelint.io/rules/color-hex-case",
"href": "https://stylelint.io/rules/color-no-invalid-hex",
},
"message": "Expected \\"#AAA\\" to be \\"#aaa\\" (color-hex-case)",
"message": "Unexpected invalid hex color \\"#AA\\" (color-no-invalid-hex)",
"range": Object {
"end": Object {
"character": 12,
"character": 14,
"line": 1,
},
"start": Object {
Expand All @@ -24,38 +24,38 @@ Object {

exports[`warningToDiagnostic should convert a Stylelint warning to an LSP diagnostic 1`] = `
Object {
"code": "color-hex-case",
"message": "Expected \\"#AAA\\" to be \\"#aaa\\" (color-hex-case)",
"code": "color-hex-length",
"message": "Expected \\"#bbbbbb\\" to be \\"#bbb\\" (color-hex-length)",
"range": Object {
"end": Object {
"character": 12,
"line": 1,
"character": 25,
"line": 2,
},
"start": Object {
"character": 11,
"line": 1,
"character": 18,
"line": 2,
},
},
"severity": 1,
"severity": 2,
"source": "Stylelint",
}
`;

exports[`warningToDiagnostic should convert a Stylelint warning to an LSP diagnostic 2`] = `
Object {
"code": "color-hex-length",
"message": "Expected \\"#bbbbbb\\" to be \\"#bbb\\" (color-hex-length)",
"code": "color-no-invalid-hex",
"message": "Unexpected invalid hex color \\"#AA\\" (color-no-invalid-hex)",
"range": Object {
"end": Object {
"character": 25,
"line": 2,
"character": 14,
"line": 1,
},
"start": Object {
"character": 18,
"line": 2,
"character": 11,
"line": 1,
},
},
"severity": 2,
"severity": 1,
"source": "Stylelint",
}
`;
10 changes: 5 additions & 5 deletions src/utils/stylelint/__tests__/warning-to-diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ describe('warningToDiagnostic', () => {
results: [{ warnings }],
} = await lint({
code: `a {
color: #AAA;
color: #AA;
border-color: #bbbbbb;
}`,
config: {
rules: {
'color-hex-case': ['lower'],
'color-no-invalid-hex': true,
'color-hex-length': ['short', { severity: 'warning' }],
},
},
Expand All @@ -30,18 +30,18 @@ describe('warningToDiagnostic', () => {
results: [{ warnings }],
} = await lint({
code: `a {
color: #AAA;
color: #AA;
border-color: #bbbbbb;
}`,
config: {
rules: {
'color-hex-case': ['lower'],
'color-no-invalid-hex': true,
},
},
});

const rules = {
'color-hex-case': { url: 'https://stylelint.io/rules/color-hex-case' },
'color-no-invalid-hex': { url: 'https://stylelint.io/rules/color-no-invalid-hex' },
} as {
[name: string]: Partial<stylelint.RuleMeta>;
};
Expand Down

0 comments on commit 9cf6812

Please sign in to comment.