jest-preset-stylelint 5.0.1 → 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 (3) hide show
  1. package/getTestRule.js +21 -26
  2. package/index.d.ts +3 -3
  3. package/package.json +12 -12
package/getTestRule.js CHANGED
@@ -63,35 +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
- // @ts-expect-error -- TODO: `warning.endLine` is not implemented. See stylelint/stylelint#5725
87
- 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
+ }
88
86
  }
89
87
 
90
- if (expected.endColumn !== undefined) {
91
- // @ts-expect-error -- TODO: `warning.endColumn` is not implemented. See stylelint/stylelint#5725
92
- expect(warning.endColumn).toBe(expected.endColumn);
93
- }
94
- });
88
+ expect(actualWarnings[i]).toMatchObject(expectedWarning);
89
+ }
95
90
 
96
91
  if (!schema.fix) return;
97
92
 
@@ -124,10 +119,10 @@ module.exports = function getTestRule(options = {}) {
124
119
  code: fixedCode,
125
120
  });
126
121
 
127
- expect(outputAfterLintOnFixedCode.results[0].warnings).toEqual(
128
- outputAfterFix.results[0].warnings,
129
- );
130
- expect(outputAfterLintOnFixedCode.results[0].parseErrors).toEqual([]);
122
+ expect(outputAfterLintOnFixedCode.results[0]).toMatchObject({
123
+ warnings: outputAfterFix.results[0].warnings,
124
+ parseErrors: [],
125
+ });
131
126
  },
132
127
  });
133
128
  });
package/index.d.ts CHANGED
@@ -149,13 +149,13 @@ export type TestSchema = {
149
149
  /**
150
150
  * Test a rule with the specified schema.
151
151
  */
152
- export declare function testRule(schema: TestSchema): void;
152
+ export type TestRule = (schema: TestSchema) => void;
153
153
 
154
154
  /**
155
155
  * Create a `testRule()` function with any specified plugins.
156
156
  */
157
- export function getTestRule(options?: { plugins?: TestSchema['plugins'] }): typeof testRule;
157
+ export function getTestRule(options?: { plugins?: TestSchema['plugins'] }): TestRule;
158
158
 
159
159
  declare global {
160
- var testRule: typeof testRule;
160
+ var testRule: TestRule;
161
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-preset-stylelint",
3
- "version": "5.0.1",
3
+ "version": "5.0.4",
4
4
  "description": "Jest preset for Stylelint plugins.",
5
5
  "keywords": [
6
6
  "stylelint",
@@ -55,21 +55,21 @@
55
55
  "devDependencies": {
56
56
  "@stylelint/prettier-config": "^2.0.0",
57
57
  "@stylelint/remark-preset": "^3.0.0",
58
- "@types/jest": "^27.4.0",
59
- "eslint": "^8.9.0",
60
- "eslint-config-stylelint": "^15.0.0",
61
- "husky": "^7.0.4",
62
- "jest": "^27.5.1",
63
- "lint-staged": "^12.3.4",
64
- "np": "^7.6.0",
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
+ "np": "^7.6.1",
65
65
  "npm-run-all": "^4.1.5",
66
- "prettier": "^2.5.1",
66
+ "prettier": "^2.6.2",
67
67
  "remark-cli": "^10.0.1",
68
- "stylelint": "^14.5.1",
69
- "typescript": "^4.5.5"
68
+ "stylelint": "^14.8.5",
69
+ "typescript": "^4.7.3"
70
70
  },
71
71
  "peerDependencies": {
72
- "jest": "^25.3.0 || ^26.0.1 || ^27.0.1"
72
+ "jest": "^25.3.0 || ^26.0.1 || ^27.0.1 || ^28.0.2"
73
73
  },
74
74
  "engines": {
75
75
  "node": "^12.20.0 || ^14.13.1 || >=16.0.0"