@mrhenry/stylelint-mrhenry-nesting 3.0.0 → 3.0.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.
Files changed (2) hide show
  1. package/index.mjs +31 -6
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -25,13 +25,29 @@ const meta = {
25
25
  fixable: true,
26
26
  };
27
27
 
28
- const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
28
+ /** @type {import('stylelint').Rule<true|null, Array<string | RegExp>>} */
29
+ const ruleFunction = (primaryOption, secondaryOption, context) => {
29
30
  return (postcssRoot, postcssResult) => {
30
- if (!primaryOption) {
31
- return;
32
- }
31
+ const validPrimary = stylelint.utils.validateOptions(postcssResult, ruleName, {
32
+ actual: primaryOption,
33
+ possible: [true]
34
+ });
35
+
36
+ /* c8 ignore next */
37
+ if (!validPrimary) return;
38
+
39
+ const validSecondary = stylelint.utils.validateOptions(postcssResult, ruleName, {
40
+ actual: secondaryOption,
41
+ possible: {
42
+ ignoreAtRules: [isString, isRegExp],
43
+ },
44
+ optional: true,
45
+ });
46
+
47
+ /* c8 ignore next */
48
+ if (!validSecondary) return;
33
49
 
34
- const ignoreAtRulesOptions = secondaryOptionObject?.ignoreAtRules ?? [];
50
+ const ignoreAtRulesOptions = secondaryOption?.ignoreAtRules ?? [];
35
51
 
36
52
  postcssRoot.walkAtRules((atrule) => {
37
53
  let name = atrule.name.toLowerCase();
@@ -39,7 +55,8 @@ const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
39
55
  name === 'media' ||
40
56
  name === 'supports' ||
41
57
  name === 'container' ||
42
- name === 'scope'
58
+ name === 'scope' ||
59
+ name === 'starting-style'
43
60
  ) {
44
61
  // always allowed
45
62
  return;
@@ -315,3 +332,11 @@ function getFirstCompoundOrSelf(x) {
315
332
 
316
333
  return x.nodes[0];
317
334
  }
335
+
336
+ function isRegExp(value) {
337
+ return value instanceof RegExp;
338
+ }
339
+
340
+ function isString(value) {
341
+ return typeof value === 'string' || value instanceof String;
342
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrhenry/stylelint-mrhenry-nesting",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Mr. Henry's preferred way of writing nested CSS",
5
5
  "publishConfig": {
6
6
  "access": "public"