eslint-plugin-use-agnostic 1.6.1 → 1.6.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.
@@ -31,8 +31,9 @@ const composedVariablesExclusives = [
31
31
  "DIRECTIVE21#USE_SERVER_FUNCTIONS#ATSTRATEGY",
32
32
  "DIRECTIVE21#USE_CLIENT_CONTEXTS#ATSTRATEGY",
33
33
  "DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#ATSTRATEGY",
34
- // "DIRECTIVE21#USE_AGNOSTIC_STRATEGIES#MODULESIMPLE", // ERROR. The "composedVariablesExclusives" key array should only include keys representing comment variables, but "DIRECTIVE21#USE_AGNOSTIC_STRATEGIES#MODULESIMPLE" represents a composed variable. Which defeats the purpose of "composedVariablesExclusives" since composed variables cannot be made of other composed variables. // Something to perhaps modify.
35
- // "DIRECTIVE21#USE_AGNOSTIC_STRATEGIES#KINDSSIMPLE",
34
+ "DIRECTIVE21#USE_AGNOSTIC_STRATEGIES#KINDSSIMPLE",
35
+ // actual composed variables below
36
+ "DIRECTIVE21#USE_AGNOSTIC_STRATEGIES#MODULESIMPLE",
36
37
  ];
37
38
 
38
39
  const config = {
@@ -87,15 +87,21 @@ const stripDoubleQuotes = (string) => {
87
87
  * @returns The commented directive, or lack thereof via `null`. Given the strictness of this architecture, the lack of a directive is considered a mistake. (Though rules may provide the opportunity to declare a default, and configs with preset defaults may become provided.)
88
88
  */
89
89
  export const getCommentedDirectiveFromSourceCode = (sourceCode) => {
90
+ // gets all comments from the source code
91
+ const allComments = sourceCode.getAllComments();
92
+
93
+ // returns null early if there are no comments
94
+ if (allComments.length === 0) return null;
95
+
90
96
  // gets the first comment from the source code
91
- const rawFirstComment = sourceCode.getAllComments()[0];
97
+ const rawFirstComment = allComments[0];
92
98
 
93
99
  const firstComment =
94
100
  rawFirstComment.type === "Shebang"
95
101
  ? sourceCode.getAllComments()[1]
96
102
  : rawFirstComment;
97
103
 
98
- // returns null early if there is no first comment
104
+ // returns null early if there is no such first comment
99
105
  if (!firstComment) return null;
100
106
 
101
107
  // returns null early if the first comment is not on one of the first three lines
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-use-agnostic",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",