jest-preset-stylelint 7.1.1 → 7.3.0
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.
- package/getTestRule.js +12 -0
- package/index.d.ts +22 -0
- package/package.json +8 -8
package/getTestRule.js
CHANGED
|
@@ -7,6 +7,8 @@ const { inspect } = require('node:util');
|
|
|
7
7
|
* @typedef {import('.').TestSchema} TestSchema
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/** @import {Config} from 'stylelint' */
|
|
11
|
+
|
|
10
12
|
/** @type {import('.').getTestRule} */
|
|
11
13
|
module.exports = function getTestRule(options = {}) {
|
|
12
14
|
return function testRule(schema) {
|
|
@@ -23,11 +25,13 @@ module.exports = function getTestRule(options = {}) {
|
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
describe(`${schema.ruleName}`, () => {
|
|
28
|
+
/** @type {Config} */
|
|
26
29
|
const stylelintConfig = {
|
|
27
30
|
plugins: options.plugins || schema.plugins,
|
|
28
31
|
rules: {
|
|
29
32
|
[schema.ruleName]: schema.config,
|
|
30
33
|
},
|
|
34
|
+
languageOptions: schema.languageOptions,
|
|
31
35
|
};
|
|
32
36
|
|
|
33
37
|
setupTestCases({
|
|
@@ -70,6 +74,7 @@ module.exports = function getTestRule(options = {}) {
|
|
|
70
74
|
config: stylelintConfig,
|
|
71
75
|
customSyntax: schema.customSyntax,
|
|
72
76
|
codeFilename: testCase.codeFilename || schema.codeFilename,
|
|
77
|
+
computeEditInfo: schema.computeEditInfo,
|
|
73
78
|
};
|
|
74
79
|
|
|
75
80
|
const outputAfterLint = await lint(stylelintOptions).catch(formatExceptions);
|
|
@@ -92,9 +97,16 @@ module.exports = function getTestRule(options = {}) {
|
|
|
92
97
|
column: expected.column,
|
|
93
98
|
endLine: expected.endLine,
|
|
94
99
|
endColumn: expected.endColumn,
|
|
100
|
+
fix: expected.fix,
|
|
95
101
|
};
|
|
96
102
|
|
|
97
103
|
for (const [key, value] of Object.entries(expectedWarning)) {
|
|
104
|
+
if (schema.computeEditInfo && key === 'fix') {
|
|
105
|
+
// When `computeEditInfo` is set the test should only pass when `fix` matches the expected outcome,
|
|
106
|
+
// both in having a value and what the value is.
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
98
110
|
if (value === undefined) {
|
|
99
111
|
// @ts-expect-error -- Allow a partial object.
|
|
100
112
|
delete expectedWarning[key];
|
package/index.d.ts
CHANGED
|
@@ -57,6 +57,13 @@ export type Warning = {
|
|
|
57
57
|
* Expected end column number of the warning.
|
|
58
58
|
*/
|
|
59
59
|
endColumn?: number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Expected `EditInfo` of the warning.
|
|
63
|
+
*
|
|
64
|
+
* @experimental
|
|
65
|
+
*/
|
|
66
|
+
fix?: { range: [number, number]; text: string };
|
|
60
67
|
};
|
|
61
68
|
|
|
62
69
|
/**
|
|
@@ -108,6 +115,13 @@ export type TestSchema = {
|
|
|
108
115
|
*/
|
|
109
116
|
fix?: boolean;
|
|
110
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Turn on computing `EditInfo`. Default: `false`.
|
|
120
|
+
*
|
|
121
|
+
* @experimental
|
|
122
|
+
*/
|
|
123
|
+
computeEditInfo?: boolean;
|
|
124
|
+
|
|
111
125
|
/**
|
|
112
126
|
* Maps to Stylelint's `plugins` configuration property.
|
|
113
127
|
*
|
|
@@ -122,6 +136,14 @@ export type TestSchema = {
|
|
|
122
136
|
*/
|
|
123
137
|
plugins?: import('stylelint').Config['plugins'];
|
|
124
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Maps to Stylelint's `languageOptions` configuration property.
|
|
141
|
+
* Allows customization of syntax for at-rules, properties, types, and CSS-wide keywords.
|
|
142
|
+
*
|
|
143
|
+
* @see https://stylelint.io/user-guide/configure/#languageoptions
|
|
144
|
+
*/
|
|
145
|
+
languageOptions?: import('stylelint').Config['languageOptions'];
|
|
146
|
+
|
|
125
147
|
/**
|
|
126
148
|
* Maps to Stylelint's `customSyntax` option.
|
|
127
149
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-preset-stylelint",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Jest preset for Stylelint plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stylelint",
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"@stylelint/prettier-config": "^3.0.0",
|
|
64
64
|
"@stylelint/remark-preset": "^5.1.1",
|
|
65
65
|
"@types/jest": "^29.5.14",
|
|
66
|
-
"eslint": "^9.
|
|
66
|
+
"eslint": "^9.21.0",
|
|
67
67
|
"eslint-config-stylelint": "^23.0.0",
|
|
68
|
-
"eslint-plugin-jest": "^28.
|
|
68
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
69
69
|
"husky": "^9.1.7",
|
|
70
70
|
"jest": "^29.7.0",
|
|
71
71
|
"jest-light-runner": "^0.6.0",
|
|
72
|
-
"lint-staged": "^15.
|
|
73
|
-
"np": "^10.
|
|
72
|
+
"lint-staged": "^15.4.3",
|
|
73
|
+
"np": "^10.2.0",
|
|
74
74
|
"npm-run-all": "^4.1.5",
|
|
75
|
-
"prettier": "^3.
|
|
75
|
+
"prettier": "^3.5.2",
|
|
76
76
|
"remark-cli": "^12.0.1",
|
|
77
|
-
"stylelint": "^16.
|
|
78
|
-
"typescript": "^5.
|
|
77
|
+
"stylelint": "^16.15.0",
|
|
78
|
+
"typescript": "^5.8.2"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"jest": "^29.0.2"
|