@mrhenry/stylelint-mrhenry-nesting 2.2.3 → 3.0.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.
@@ -1,5 +1,5 @@
1
- const stylelint = require("stylelint");
2
- const selectorParser = require('postcss-selector-parser');
1
+ import stylelint from 'stylelint';
2
+ import selectorParser from 'postcss-selector-parser';
3
3
 
4
4
  const ruleName = "@mrhenry/stylelint-mrhenry-nesting";
5
5
  const messages = stylelint.utils.ruleMessages(ruleName, {
@@ -119,7 +119,7 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
119
119
  const selectorsAST = selectorParser().astSync(rule.selector);
120
120
  const firstCompoundOrSelf = getFirstCompoundOrSelf(selectorsAST);
121
121
 
122
- isRelativeSelector = false;
122
+ let isRelativeSelector = false;
123
123
  if (firstCompoundOrSelf.nodes[0]?.type === 'combinator') {
124
124
  isRelativeSelector = true;
125
125
  }
@@ -172,7 +172,7 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
172
172
  // .foo { .bar {} }
173
173
  if (selectorAST.nodes[0]?.type !== 'nesting') {
174
174
  if (context.fix) {
175
- fixSelector(rule, selectorsAST, selectorAST);
175
+ fixSelector(rule, selectorsAST, selectorAST, isRelativeSelector);
176
176
  continue;
177
177
  }
178
178
 
@@ -242,7 +242,7 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
242
242
  };
243
243
  };
244
244
 
245
- function fixSelector(rule, selectorsAST, selectorAST) {
245
+ function fixSelector(rule, selectorsAST, selectorAST, isRelativeSelector) {
246
246
  if (
247
247
  selectorAST.nodes.length === 1 &&
248
248
  selectorAST.nodes[0].type === 'pseudo'
@@ -294,17 +294,22 @@ ruleFunction.ruleName = ruleName;
294
294
  ruleFunction.messages = messages;
295
295
  ruleFunction.meta = meta;
296
296
 
297
- module.exports = stylelint.createPlugin(ruleName, ruleFunction);
297
+ export default stylelint.createPlugin(ruleName, ruleFunction);
298
298
 
299
299
  function getFirstCompoundOrSelf(x) {
300
+ /* c8 ignore next */
300
301
  if (!x.nodes) {
302
+ /* c8 ignore next */
301
303
  return x;
304
+ /* c8 ignore next */
302
305
  }
303
306
 
304
307
  for (let i = 0; i < x.nodes.length; i++) {
305
308
  /* c8 ignore next */
306
309
  if (x.nodes[i].type !== 'selector') {
310
+ /* c8 ignore next */
307
311
  return x;
312
+ /* c8 ignore next */
308
313
  }
309
314
  }
310
315
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@mrhenry/stylelint-mrhenry-nesting",
3
- "version": "2.2.3",
3
+ "version": "3.0.0",
4
4
  "description": "Mr. Henry's preferred way of writing nested CSS",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "main": "stylelint-mrhenry-nesting.cjs",
8
+ "type": "module",
9
+ "main": "index.mjs",
9
10
  "scripts": {
10
- "test": "npm run test:jest",
11
- "test:jest": "c8 --100 jest"
11
+ "test": "c8 --100 node --test"
12
12
  },
13
13
  "author": "Mr. Henry",
14
14
  "license": "MIT",
@@ -19,13 +19,10 @@
19
19
  "directory": "packages/nesting"
20
20
  },
21
21
  "files": [
22
- "stylelint-mrhenry-nesting.js",
22
+ "index.mjs",
23
23
  "LICENSE",
24
24
  "README.md"
25
25
  ],
26
- "jest": {
27
- "preset": "jest-preset-stylelint"
28
- },
29
26
  "keywords": [
30
27
  "stylelint",
31
28
  "stylelint-plugin"
@@ -34,9 +31,9 @@
34
31
  "postcss-selector-parser": "^6.0.11"
35
32
  },
36
33
  "peerDependencies": {
37
- "stylelint": "^14.16.1 || ^15.0.0"
34
+ "stylelint": "^16.0.0"
38
35
  },
39
36
  "devDependencies": {
40
- "stylelint": "^15.10.1"
37
+ "stylelint": "^16.0.2"
41
38
  }
42
39
  }