eslint-plugin-use-agnostic 1.6.2 → 1.6.4

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.
@@ -47,6 +47,9 @@ Indeed, Server Functions Modules have no business exporting JSX. `,
47
47
  return {
48
48
  ImportDeclaration: (node) =>
49
49
  importsFlow(context, node, currentFileEffectiveDirective),
50
+ // that should work
51
+ ImportExpression: (node) =>
52
+ importsFlow(context, node, currentFileEffectiveDirective),
50
53
  ExportNamedDeclaration: (node) =>
51
54
  reExportsFlow(context, node, currentFileEffectiveDirective),
52
55
  ExportAllDeclaration: (node) =>
@@ -57,6 +57,9 @@ Please include a Strategy that corresponds to the kind of module this export wou
57
57
  return {
58
58
  ImportDeclaration: (node) =>
59
59
  importsFlow(context, node, verifiedCommentedDirective),
60
+ // that should work
61
+ ImportExpression: (node) =>
62
+ importsFlow(context, node, verifiedCommentedDirective),
60
63
  ExportNamedDeclaration: (node) =>
61
64
  allExportsFlow(context, node, verifiedCommentedDirective),
62
65
  ExportAllDeclaration: (node) =>
@@ -87,15 +87,19 @@ 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
- rawFirstComment.type === "Shebang"
95
- ? sourceCode.getAllComments()[1]
96
- : rawFirstComment;
100
+ rawFirstComment.type === "Shebang" ? allComments[1] : rawFirstComment;
97
101
 
98
- // returns null early if there is no first comment
102
+ // returns null early if there is no such first comment
99
103
  if (!firstComment) return null;
100
104
 
101
105
  // 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.2",
3
+ "version": "1.6.4",
4
4
  "description": "Highlights problematic server-client imports in projects made with the Fullstack React Architecture.",
5
5
  "keywords": [
6
6
  "eslint",