jest-preset-stylelint 6.1.0 → 6.1.1

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 CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  const util = require('util');
4
4
 
5
- // @ts-expect-error -- TS2614: Module '"stylelint"' has no exported member 'lint'. Did you mean to use 'import lint from "stylelint"' instead?
6
- const { lint } = require('stylelint'); // eslint-disable-line node/no-unpublished-require -- Avoid auto-install of `stylelint` peer dependency.
7
-
8
5
  /**
9
6
  * @typedef {import('.').TestCase} TestCase
10
7
  * @typedef {import('.').TestSchema} TestSchema
@@ -13,6 +10,14 @@ const { lint } = require('stylelint'); // eslint-disable-line node/no-unpublishe
13
10
  /** @type {import('.').getTestRule} */
14
11
  module.exports = function getTestRule(options = {}) {
15
12
  return function testRule(schema) {
13
+ /** @type {import('stylelint').lint} */
14
+ let lint;
15
+
16
+ beforeAll(() => {
17
+ // eslint-disable-next-line n/no-unpublished-require -- Avoid auto-install of `stylelint` peer dependency.
18
+ lint = require('stylelint').lint;
19
+ });
20
+
16
21
  describe(`${schema.ruleName}`, () => {
17
22
  const stylelintConfig = {
18
23
  plugins: options.plugins || schema.plugins,
package/jest-preset.js CHANGED
@@ -2,5 +2,6 @@
2
2
 
3
3
  module.exports = {
4
4
  setupFiles: [require.resolve('./jest-setup.js')],
5
+ setupFilesAfterEnv: [require.resolve('./jest-setup-after-env.js')],
5
6
  testEnvironment: 'node',
6
7
  };
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ const os = require('os');
4
+
5
+ const eolDescriptor = Object.getOwnPropertyDescriptor(os, 'EOL');
6
+
7
+ if (!eolDescriptor) {
8
+ throw new TypeError('`os` must have an `EOL` property');
9
+ }
10
+
11
+ beforeAll(() => {
12
+ // NOTE: `jest.replaceProperty()` is unavailable for a read-only property.
13
+ Object.defineProperty(os, 'EOL', { ...eolDescriptor, value: '\n' });
14
+ });
15
+
16
+ afterAll(() => {
17
+ Object.defineProperty(os, 'EOL', eolDescriptor);
18
+ });
package/jest-setup.js CHANGED
@@ -1,8 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // Mock should be before stylelint required. Even if it's required inside other modules
4
- jest.mock('stylelint/lib/utils/getOsEol', () => () => '\n');
5
-
6
3
  const getTestRule = require('./getTestRule');
7
4
 
8
5
  global.testRule = getTestRule();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-preset-stylelint",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "Jest preset for Stylelint plugins.",
5
5
  "keywords": [
6
6
  "stylelint",
@@ -17,6 +17,7 @@
17
17
  "getTestRule.js",
18
18
  "jest-preset.js",
19
19
  "jest-setup.js",
20
+ "jest-setup-after-env.js",
20
21
  "index.d.ts"
21
22
  ],
22
23
  "scripts": {
@@ -55,21 +56,21 @@
55
56
  ]
56
57
  },
57
58
  "devDependencies": {
58
- "@stylelint/prettier-config": "^2.0.0",
59
+ "@stylelint/prettier-config": "^3.0.0",
59
60
  "@stylelint/remark-preset": "^4.0.0",
60
- "@types/jest": "^29.4.0",
61
- "eslint": "^8.34.0",
62
- "eslint-config-stylelint": "^18.0.0",
63
- "eslint-plugin-jest": "^27.2.1",
61
+ "@types/jest": "^29.5.3",
62
+ "eslint": "^8.45.0",
63
+ "eslint-config-stylelint": "^19.0.0",
64
+ "eslint-plugin-jest": "^27.2.3",
64
65
  "husky": "^8.0.3",
65
- "jest": "^29.4.3",
66
- "lint-staged": "^13.1.2",
67
- "np": "^7.6.3",
66
+ "jest": "^29.6.1",
67
+ "lint-staged": "^13.2.3",
68
+ "np": "^8.0.4",
68
69
  "npm-run-all": "^4.1.5",
69
- "prettier": "^2.8.4",
70
+ "prettier": "^3.0.0",
70
71
  "remark-cli": "^11.0.0",
71
- "stylelint": "^15.1.0",
72
- "typescript": "^4.9.5"
72
+ "stylelint": "^15.10.2",
73
+ "typescript": "^5.1.6"
73
74
  },
74
75
  "peerDependencies": {
75
76
  "jest": "^29.0.2"