Repository: AndyOGo/stylelint-declaration-strict-value (js)

Issue:
Support stylelint 15
[stylelint 15](https://github.com/stylelint/stylelint/releases/tag/15.0.0) is released, please update the range in `peerDependencies` if the plugin is compatible.

Pull request description:
Chore/finalise stylelint v15 migration
fixes #309 

Patch:
diff --git a/jest.coverage.config.js b/jest.coverage.config.js
new file mode 100644
index 0000000..15c191e
--- /dev/null
+++ b/jest.coverage.config.js
@@ -0,0 +1,11 @@
+const baseConfig = require('./jest.config.json');
+
+/** @type {import('jest').Config} */
+const config = {
+  ...baseConfig,
+  collectCoverage: true,
+  coverageReporters: ['lcov', 'text'],
+  coverageDirectory: '<rootDir>/coverage',
+};
+
+module.exports = config;
diff --git a/jest.setup.js b/jest.setup.js
index e9dd089..77db895 100644
--- a/jest.setup.js
+++ b/jest.setup.js
@@ -4,9 +4,9 @@ const { lint } = require('stylelint');
 
 global.testRule = getTestRule({ plugins: ['./src/index.ts'] });
 
-global.testOptions = testOptions;
+global.testCustomAutoFixMessage = testCustomAutoFixMessage;
 
-function testOptions({ ruleName, config, reject }) {
+function testCustomAutoFixMessage({ ruleName, config, reject, fix }) {
   // eslint-disable-next-line no-undef
   describe(ruleName, () => {
     // eslint-disable-next-line no-undef
@@ -14,8 +14,9 @@ function testOptions({ ruleName, config, reject }) {
       const rejections = await Promise.all(
         reject.map(async ({ code, message }) => {
           const {
-            results: [{ invalidOptionWarnings }],
+            results: [{ warnings }],
           } = await lint({
+            fix,
             code,
             config: {
               plugins: ['./src/index.ts'],
@@ -25,17 +26,17 @@ function testOptions({ ruleName, config, reject }) {
             },
           });
 
-          return { message, invalidOptionWarnings };
+          return { message, warnings };
         })
       );
 
-      rejections.forEach(({ message, invalidOptionWarnings }) => {
+      rejections.forEach(({ message, warnings }) => {
         const expectedWarning = {
           text: message,
         };
 
         // eslint-disable-next-line no-undef
-        expect(invalidOptionWarnings[0]).toMatchObject(expectedWarning);
+        expect(warnings[0]).toMatchObject(expectedWarning);
       });
     });
   });
diff --git a/package.json b/package.json
index ad07e1f..adbbfc5 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
     "build": "microbundle --tsconfig tsconfig.build.json --compress",
     "release": "dotenv semantic-release",
     "test": "jest",
-    "coverage": "nyc --reporter lcov --reporter text node test",
+    "coverage": "jest --config='./jest.coverage.config.js'",
     "postcoverage": "dotenv codecov",
     "eslint": "eslint 'src/**/*.[tj]s' 'test/**/*.[tj]s'",
     "docs": "typedoc --plugin typedoc-plugin-markdown",
@@ -78,14 +78,14 @@
     "eslint-plugin-tsdoc": "^0.2.7",
     "husky": "^6.0.0",
     "jest": "^29.4.2",
-    "jest-preset-stylelint": "^6.0.0",
+    "jest-preset-stylelint": "^6.1.0",
     "lint-staged": "^10.5.2",
     "microbundle": "^0.12.0",
     "nyc": "^15.1.0",
     "pinst": "^2.1.6",
     "prettier": "^2.2.1",
     "semantic-release": "^17.3.0",
-    "stylelint": "^15.0.0",
+    "stylelint": "^15.1.0",
     "typedoc": "^0.22.7",
     "typedoc-plugin-markdown": "^3.2.1",
     "typescript": "^4.1.2"


Test patch:
diff --git a/test/.eslintrc.json b/test/.eslintrc.json
index 39a050c..0971412 100644
--- a/test/.eslintrc.json
+++ b/test/.eslintrc.json
@@ -1,7 +1,7 @@
 {
   "globals": {
     "testRule": "readonly",
-    "testOptions": "readonly"
+    "testCustomAutoFixMessage": "readonly"
   },
   "rules": {
     "import/no-extraneous-dependencies": ["error", {
diff --git a/test/auto-fix-func.js b/test/auto-fix-func.js
index 2650db9..265cac7 100644
--- a/test/auto-fix-func.js
+++ b/test/auto-fix-func.js
@@ -26,7 +26,6 @@ testRule({
 
 // autofix by function property
 testRule({
-  skip: true,
   ruleName,
   fix: true,
 
@@ -51,7 +50,6 @@ testRule({
     {
       code: '.foo { font-size: 16px; }',
       unfixable: true,
-      // message: `"font-size" is not a color property (${ruleName})`,
       message: `Expected variable or function for "16px" of "font-size" (${ruleName})`,
       line: 1,
       column: 8,
@@ -59,7 +57,6 @@ testRule({
     {
       code: '.foo { color: blue; }',
       unfixable: true,
-      // message: `Can't fix color "blue" (${ruleName})`,
       message: `Expected variable or function for "blue" of "color" (scale-unlimited/declaration-strict-value)`,
       line: 1,
       column: 8,
@@ -67,7 +64,6 @@ testRule({
     {
       code: '.foo { display: block; }',
       unfixable: true,
-      // message: `Property "display" with value "block" can't be autofixed (${ruleName})`,
       message: `Expected variable or function for "block" of "display" (scale-unlimited/declaration-strict-value)`,
       line: 1,
       column: 8,
@@ -75,9 +71,35 @@ testRule({
   ],
 });
 
+testCustomAutoFixMessage({
+  ruleName,
+  fix: true,
+
+  config: [
+    ['color', 'font-size', 'display'],
+    {
+      autoFixFunc: autoFixFuncWithThrow,
+    },
+  ],
+
+  reject: [
+    {
+      code: '.foo { font-size: 16px; }',
+      message: `"font-size" is not a color property (${ruleName})`,
+    },
+    {
+      code: '.foo { color: blue; }',
+      message: `Can't fix color "blue" (${ruleName})`,
+    },
+    {
+      code: '.foo { display: block; }',
+      message: `Property "display" with value "block" can't be autofixed (${ruleName})`,
+    },
+  ],
+});
+
 // autofix by function property disabled
 testRule({
-  skip: true,
   ruleName,
   fix: true,
 
@@ -92,14 +114,14 @@ testRule({
   reject: [
     {
       code: '.foo { color: #fff; }',
-      fixed: '.foo { color: $color-white; }',
+      unfixable: true,
       message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
       line: 1,
       column: 8,
     },
     {
       code: '.foo { color: red; }',
-      fixed: '.foo { color: $color-red; }',
+      unfixable: true,
       message: `Expected variable or function for "red" of "color" (${ruleName})`,
       line: 1,
       column: 8,
@@ -109,7 +131,6 @@ testRule({
 
 // autofix by file exporting function
 testRule({
-  skip: true,
   ruleName,
   fix: true,
 
@@ -120,7 +141,18 @@ testRule({
     },
   ],
 
-  accept: [{ code: '.foo { color: #fff; }' }, { code: '.foo { color: red; }' }],
+  reject: [
+    {
+      code: '.foo { color: #fff; }',
+      fixed: '.foo { color: $color-white; }',
+      message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
+    },
+    {
+      code: '.foo { color: red; }',
+      fixed: '.foo { color: $color-red; }',
+      message: `Expected variable or function for "red" of "color" (${ruleName})`,
+    },
+  ],
 });
 
 // autofix by file exporting function disabled
@@ -139,7 +171,6 @@ testRule({
   reject: [
     {
       code: '.foo { color: #fff; }',
-      // fixed: '.foo { color: $color-white; }',
       unfixable: true,
       message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
       line: 1,
@@ -147,7 +178,6 @@ testRule({
     },
     {
       code: '.foo { color: red; }',
-      // fixed: '.foo { color: $color-red; }',
       unfixable: true,
       message: `Expected variable or function for "red" of "color" (${ruleName})`,
       line: 1,
@@ -156,8 +186,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
@@ -175,8 +204,7 @@ testOptions({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
diff --git a/test/custom-message.js b/test/custom-message.js
index 1d3deed..574acab 100644
--- a/test/custom-message.js
+++ b/test/custom-message.js
@@ -50,8 +50,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
diff --git a/test/ignore-functions.js b/test/ignore-functions.js
index bf679f1..4076d90 100644
--- a/test/ignore-functions.js
+++ b/test/ignore-functions.js
@@ -227,8 +227,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
diff --git a/test/ignore-variables.js b/test/ignore-variables.js
index f0a459e..b9b1f09 100644
--- a/test/ignore-variables.js
+++ b/test/ignore-variables.js
@@ -248,8 +248,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
diff --git a/test/severity.js b/test/severity.js
index 4d0e3a7..ffab14b 100644
--- a/test/severity.js
+++ b/test/severity.js
@@ -27,8 +27,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
diff --git a/test/shorthand.js b/test/shorthand.js
index b4e5be0..6dd3f63 100644
--- a/test/shorthand.js
+++ b/test/shorthand.js
@@ -304,8 +304,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
@@ -323,8 +322,7 @@ testOptions({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
diff --git a/test/single-keyword.js b/test/single-keyword.js
index 91fea19..ab1c92c 100644
--- a/test/single-keyword.js
+++ b/test/single-keyword.js
@@ -71,8 +71,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [
diff --git a/test/single-value.js b/test/single-value.js
index c414b9d..4a4b31e 100644
--- a/test/single-value.js
+++ b/test/single-value.js
@@ -118,8 +118,7 @@ testRule({
   ],
 });
 
-testOptions({
-  skip: true,
+testRule({
   ruleName,
 
   config: [