@oscarpalmer/atoms 0.172.2 → 0.172.3

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/package.json +1 -1
  2. package/plugin/helpers.js +23 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/atoms",
3
- "version": "0.172.2",
3
+ "version": "0.172.3",
4
4
  "description": "Atomic utilities for making your JavaScript better.",
5
5
  "keywords": [
6
6
  "helper",
package/plugin/helpers.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * @typedef Plugin
9
9
  * @property {string} message
10
10
  * @property {string} name
11
- * @property {string} selector
11
+ * @property {string[]} selectors
12
12
  * @property {import('eslint').Rule.RuleModule} value
13
13
  */
14
14
 
@@ -59,7 +59,7 @@ export function getPlugin(name, methods, validator, prefix) {
59
59
  return {
60
60
  message,
61
61
  name: name.full,
62
- selector: `CallExpression[callee.type="${memberExpression}"][callee.object.type="${arrayExpression}"][callee.property.type="${identifierType}"]`,
62
+ selectors: getSelectors(methods),
63
63
  value: {
64
64
  create(context) {
65
65
  return {
@@ -83,6 +83,27 @@ export function getPlugin(name, methods, validator, prefix) {
83
83
  };
84
84
  }
85
85
 
86
+ /**
87
+ * @param {Set<string>} methods
88
+ * @returns {string[]}
89
+ */
90
+ function getSelectors(methods) {
91
+ const array = [...methods];
92
+ const {length} = array;
93
+
94
+ const selectors = [];
95
+
96
+ for (let index = 0; index < length; index += 1) {
97
+ const method = array[index];
98
+
99
+ selectors.push(
100
+ `CallExpression[callee.type="${memberExpression}"][callee.object.type="${arrayExpression}"][callee.property.type="${identifierType}"][callee.property.name="${method}"]`,
101
+ );
102
+ }
103
+
104
+ return selectors;
105
+ }
106
+
86
107
  /**
87
108
  * @param {import('eslint').Rule.RuleContext} context
88
109
  * @param {import('estree').CallExpression & import('eslint').Rule.NodeParentExtension} node