jest-preset-stylelint 5.0.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/getTestRule.js +21 -24
  2. package/package.json +9 -9
package/getTestRule.js CHANGED
@@ -63,33 +63,30 @@ module.exports = function getTestRule(options = {}) {
63
63
 
64
64
  const actualWarnings = outputAfterLint.results[0].warnings;
65
65
 
66
- expect(outputAfterLint.results[0].parseErrors).toEqual([]);
66
+ expect(outputAfterLint.results[0]).toMatchObject({ parseErrors: [] });
67
67
  expect(actualWarnings).toHaveLength(testCase.warnings ? testCase.warnings.length : 1);
68
68
 
69
- (testCase.warnings || [testCase]).forEach((expected, i) => {
70
- const warning = actualWarnings[i];
71
-
69
+ for (const [i, expected] of (testCase.warnings || [testCase]).entries()) {
72
70
  // @ts-expect-error -- This is our custom matcher.
73
71
  expect(expected).toHaveMessage();
74
72
 
75
- expect(warning.text).toBe(expected.message);
76
-
77
- if (expected.line !== undefined) {
78
- expect(warning.line).toBe(expected.line);
79
- }
80
-
81
- if (expected.column !== undefined) {
82
- expect(warning.column).toBe(expected.column);
83
- }
84
-
85
- if (expected.endLine !== undefined) {
86
- expect(warning.endLine).toBe(expected.endLine);
73
+ const expectedWarning = {
74
+ text: expected.message,
75
+ line: expected.line,
76
+ column: expected.column,
77
+ endLine: expected.endLine,
78
+ endColumn: expected.endColumn,
79
+ };
80
+
81
+ for (const [key, value] of Object.entries(expectedWarning)) {
82
+ if (value === undefined) {
83
+ // @ts-expect-error -- Allow a partial object.
84
+ delete expectedWarning[key];
85
+ }
87
86
  }
88
87
 
89
- if (expected.endColumn !== undefined) {
90
- expect(warning.endColumn).toBe(expected.endColumn);
91
- }
92
- });
88
+ expect(actualWarnings[i]).toMatchObject(expectedWarning);
89
+ }
93
90
 
94
91
  if (!schema.fix) return;
95
92
 
@@ -122,10 +119,10 @@ module.exports = function getTestRule(options = {}) {
122
119
  code: fixedCode,
123
120
  });
124
121
 
125
- expect(outputAfterLintOnFixedCode.results[0].warnings).toEqual(
126
- outputAfterFix.results[0].warnings,
127
- );
128
- expect(outputAfterLintOnFixedCode.results[0].parseErrors).toEqual([]);
122
+ expect(outputAfterLintOnFixedCode.results[0]).toMatchObject({
123
+ warnings: outputAfterFix.results[0].warnings,
124
+ parseErrors: [],
125
+ });
129
126
  },
130
127
  });
131
128
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-preset-stylelint",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "Jest preset for Stylelint plugins.",
5
5
  "keywords": [
6
6
  "stylelint",
@@ -55,18 +55,18 @@
55
55
  "devDependencies": {
56
56
  "@stylelint/prettier-config": "^2.0.0",
57
57
  "@stylelint/remark-preset": "^3.0.0",
58
- "@types/jest": "^27.4.1",
59
- "eslint": "^8.14.0",
60
- "eslint-config-stylelint": "^15.0.0",
61
- "husky": "^7.0.4",
62
- "jest": "^28.0.3",
63
- "lint-staged": "^12.4.1",
58
+ "@types/jest": "^28.1.1",
59
+ "eslint": "^8.17.0",
60
+ "eslint-config-stylelint": "^15.1.0",
61
+ "husky": "^8.0.1",
62
+ "jest": "^28.1.0",
63
+ "lint-staged": "^13.0.0",
64
64
  "np": "^7.6.1",
65
65
  "npm-run-all": "^4.1.5",
66
66
  "prettier": "^2.6.2",
67
67
  "remark-cli": "^10.0.1",
68
- "stylelint": "^14.8.1",
69
- "typescript": "^4.6.4"
68
+ "stylelint": "^14.8.5",
69
+ "typescript": "^4.7.3"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "jest": "^25.3.0 || ^26.0.1 || ^27.0.1 || ^28.0.2"