eslint-plugin-svelte 3.9.1 → 3.9.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/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.9.1";
17
+ version: "3.9.3";
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.9.1";
2
+ export declare const version: "3.9.3";
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.9.1';
5
+ export const version = '3.9.3';
@@ -104,6 +104,7 @@ export default createRule('no-top-level-browser-globals', {
104
104
  }
105
105
  return {
106
106
  ':function': enterFunction,
107
+ SvelteSnippetBlock: enterFunction,
107
108
  '*.typeAnnotation': enterTypeAnnotation,
108
109
  MetaProperty: enterMetaProperty,
109
110
  'Program:exit': verifyGlobalReferences
@@ -294,6 +295,22 @@ export default createRule('no-top-level-browser-globals', {
294
295
  if (parent.type === 'UnaryExpression' && parent.operator === '!') {
295
296
  return getGuardChecker({ not: !guardInfo.not, node: parent });
296
297
  }
298
+ if (parent.type === 'SvelteIfBlock' && parent.expression === guardInfo.node) {
299
+ if (!guardInfo.not) {
300
+ if (parent.children.length === 0) {
301
+ return null; // No block to check
302
+ }
303
+ const first = parent.children[0];
304
+ const last = parent.children.at(-1);
305
+ return (n) => first.range[0] <= n.range[0] && n.range[1] <= last.range[1];
306
+ }
307
+ // not
308
+ if (parent.else) {
309
+ const block = parent.else;
310
+ return (n) => block.range[0] <= n.range[0] && n.range[1] <= block.range[1];
311
+ }
312
+ return null;
313
+ }
297
314
  if (parent.type === 'IfStatement' && parent.test === guardInfo.node) {
298
315
  if (!guardInfo.not) {
299
316
  const block = parent.consequent;
@@ -12,7 +12,6 @@ import { extractLeadingComments } from './extract-leading-comments.js';
12
12
  import { findAttribute, getLangValue } from '../../utils/ast-utils.js';
13
13
  import path from 'path';
14
14
  import fs from 'fs';
15
- import semver from 'semver';
16
15
  const STYLE_TRANSFORMS = {
17
16
  postcss: transformWithPostCSS,
18
17
  pcss: transformWithPostCSS,
@@ -277,7 +276,7 @@ function* transformScripts(context, text) {
277
276
  }
278
277
  }
279
278
  }
280
- function hasTagOption(program) {
279
+ function isCustomElement(program) {
281
280
  return program.body.some((body) => {
282
281
  if (body.type !== 'SvelteElement' || body.kind !== 'special') {
283
282
  return false;
@@ -285,7 +284,7 @@ function hasTagOption(program) {
285
284
  if (body.name.name !== 'svelte:options') {
286
285
  return false;
287
286
  }
288
- return Boolean(findAttribute(body, 'tag'));
287
+ return Boolean(findAttribute(body, 'tag')) || Boolean(findAttribute(body, 'customElement'));
289
288
  });
290
289
  }
291
290
  /**
@@ -295,11 +294,7 @@ function getWarningsFromCode(code, context) {
295
294
  try {
296
295
  const result = compiler.compile(code, {
297
296
  generate: false,
298
- ...(semver.satisfies(compiler.VERSION, '>=4.0.0-0')
299
- ? { customElement: true }
300
- : hasTagOption(context.sourceCode.ast)
301
- ? { customElement: true }
302
- : {})
297
+ ...(isCustomElement(context.sourceCode.ast) ? { customElement: true } : {})
303
298
  });
304
299
  return { warnings: result.warnings, kind: 'warn' };
305
300
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-svelte",
3
- "version": "3.9.1",
3
+ "version": "3.9.3",
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",
@@ -36,7 +36,7 @@
36
36
  "@jridgewell/sourcemap-codec": "^1.5.0",
37
37
  "esutils": "^2.0.3",
38
38
  "globals": "^16.0.0",
39
- "known-css-properties": "^0.36.0",
39
+ "known-css-properties": "^0.37.0",
40
40
  "postcss": "^8.4.49",
41
41
  "postcss-load-config": "^3.1.4",
42
42
  "postcss-safe-parser": "^7.0.0",
@@ -66,7 +66,7 @@
66
66
  "eslint-visitor-keys": "^4.2.0",
67
67
  "espree": "^10.3.0",
68
68
  "less": "^4.2.1",
69
- "mocha": "^11.0.0",
69
+ "mocha": "~11.6.0",
70
70
  "postcss-nested": "^7.0.2",
71
71
  "postcss-selector-parser": "^7.0.0",
72
72
  "sass": "^1.81.0",