@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.
- package/package.json +1 -1
- package/plugin/helpers.js +23 -2
package/package.json
CHANGED
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}
|
|
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
|
-
|
|
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
|