eslint-plugin-svelte 3.8.0 → 3.8.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.
package/lib/main.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare const configs: {
14
14
  export declare const rules: Record<string, Rule.RuleModule>;
15
15
  export declare const meta: {
16
16
  name: "eslint-plugin-svelte";
17
- version: "3.8.0";
17
+ version: "3.8.1";
18
18
  };
19
19
  export declare const processors: {
20
20
  '.svelte': typeof processor;
package/lib/meta.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const name: "eslint-plugin-svelte";
2
- export declare const version: "3.8.0";
2
+ export declare const version: "3.8.1";
package/lib/meta.js CHANGED
@@ -2,4 +2,4 @@
2
2
  // This file has been automatically generated,
3
3
  // in order to update its content execute "pnpm run update"
4
4
  export const name = 'eslint-plugin-svelte';
5
- export const version = '3.8.0';
5
+ export const version = '3.8.1';
@@ -25,11 +25,17 @@ export default createRule('no-top-level-browser-globals', {
25
25
  });
26
26
  const maybeGuards = [];
27
27
  const functions = [];
28
+ const typeAnnotations = [];
28
29
  function enterFunction(node) {
29
30
  if (isTopLevelLocation(node)) {
30
31
  functions.push(node);
31
32
  }
32
33
  }
34
+ function enterTypeAnnotation(node) {
35
+ if (!isInTypeAnnotation(node)) {
36
+ typeAnnotations.push(node);
37
+ }
38
+ }
33
39
  function enterMetaProperty(node) {
34
40
  if (node.meta.name !== 'import' || node.property.name !== 'meta')
35
41
  return;
@@ -69,7 +75,7 @@ export default createRule('no-top-level-browser-globals', {
69
75
  const reportCandidates = [];
70
76
  // Collects references to global variables.
71
77
  for (const ref of iterateBrowserGlobalReferences()) {
72
- if (!isTopLevelLocation(ref.node))
78
+ if (!isTopLevelLocation(ref.node) || isInTypeAnnotation(ref.node))
73
79
  continue;
74
80
  const guardChecker = getGuardCheckerFromReference(ref.node);
75
81
  if (guardChecker) {
@@ -98,6 +104,7 @@ export default createRule('no-top-level-browser-globals', {
98
104
  }
99
105
  return {
100
106
  ':function': enterFunction,
107
+ '*.typeAnnotation': enterTypeAnnotation,
101
108
  MetaProperty: enterMetaProperty,
102
109
  'Program:exit': verifyGlobalReferences
103
110
  };
@@ -127,6 +134,18 @@ export default createRule('no-top-level-browser-globals', {
127
134
  }
128
135
  return true;
129
136
  }
137
+ /**
138
+ * Checks whether the node is in type annotation.
139
+ * @returns `true` if the node is in type annotation.
140
+ */
141
+ function isInTypeAnnotation(node) {
142
+ for (const typeAnnotation of typeAnnotations) {
143
+ if (typeAnnotation.range[0] <= node.range[0] && node.range[1] <= typeAnnotation.range[1]) {
144
+ return true;
145
+ }
146
+ }
147
+ return false;
148
+ }
130
149
  /**
131
150
  * Iterate over the references of modules that can check the browser environment.
132
151
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-svelte",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "ESLint plugin for Svelte using AST",
5
5
  "repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git",
6
6
  "homepage": "https://sveltejs.github.io/eslint-plugin-svelte",