Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sveltejs/svelte-eslint-parser
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.39.2
Choose a base ref
...
head repository: sveltejs/svelte-eslint-parser
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.40.0
Choose a head ref
  • 7 commits
  • 20 files changed
  • 4 contributors

Commits on Jul 11, 2024

  1. Copy the full SHA
    01f0ed5 View commit details
  2. chore(deps): update dependency esbuild to ^0.23.0

    renovate[bot] committed Jul 11, 2024
    Copy the full SHA
    3693817 View commit details
  3. chore(deps): update dependency rimraf to v6 (#547)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7b0e194 View commit details
  4. chore(deps): update typescript-eslint monorepo to ~7.16.0 (#545)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jul 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    19e0099 View commit details
  5. Revert "fix: update svelte to 5.0.0-next.181 and fix for {:else if}"

    This reverts commit 01f0ed5.
    ota-meshi committed Jul 11, 2024
    Copy the full SHA
    79b22e6 View commit details
  6. fix: update svelte to 5.0.0-next.181 and fix for {:else if} (#548)

    ota-meshi authored Jul 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    dfe5cb8 View commit details
  7. chore: release svelte-eslint-parser (#549)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Jul 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7b29182 View commit details
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# svelte-eslint-parser

## 0.40.0

### Minor Changes

- [#548](https://github.com/sveltejs/svelte-eslint-parser/pull/548) [`dfe5cb8`](https://github.com/sveltejs/svelte-eslint-parser/commit/dfe5cb815ef2119cfa56ade8755c45b8533c24e1) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: update svelte to 5.0.0-next.181 and fix for `{:else if}`

## 0.39.2

### Patch Changes
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-eslint-parser",
"version": "0.39.2",
"version": "0.40.0",
"description": "Svelte parser for ESLint",
"repository": "git+https://github.com/sveltejs/svelte-eslint-parser.git",
"homepage": "https://github.com/sveltejs/svelte-eslint-parser#readme",
@@ -47,7 +47,7 @@
"version:ci": "env-cmd -e version-ci pnpm run build:meta && changeset version"
},
"peerDependencies": {
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.115"
"svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.181"
},
"peerDependenciesMeta": {
"svelte": {
@@ -58,56 +58,56 @@
"eslint-scope": "^7.2.2",
"eslint-visitor-keys": "^3.4.3",
"espree": "^9.6.1",
"postcss": "^8.4.38",
"postcss": "^8.4.39",
"postcss-scss": "^4.0.9"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.5",
"@changesets/get-release-plan": "^4.0.2",
"@changesets/cli": "^2.27.7",
"@changesets/get-release-plan": "^4.0.3",
"@ota-meshi/eslint-plugin": "^0.15.3",
"@types/benchmark": "^2.1.5",
"@types/chai": "^4.3.16",
"@types/eslint": "^8.56.10",
"@types/eslint-scope": "^3.7.7",
"@types/eslint-visitor-keys": "^3.3.0",
"@types/estree": "^1.0.5",
"@types/mocha": "^10.0.6",
"@types/node": "^20.14.4",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.10",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "~7.13.1",
"@typescript-eslint/types": "~7.13.1",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "~7.16.0",
"@typescript-eslint/types": "~7.16.0",
"benchmark": "^2.1.4",
"chai": "^4.4.1",
"env-cmd": "^10.1.0",
"esbuild": "^0.21.5",
"esbuild": "^0.23.0",
"esbuild-register": "^3.5.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-json-schema-validator": "^5.1.0",
"eslint-plugin-json-schema-validator": "^5.1.2",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-node-dependencies": "^0.12.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-svelte": "^2.40.0",
"eslint-plugin-svelte": "^2.41.0",
"eslint-plugin-yml": "^1.14.0",
"estree-walker": "^3.0.3",
"locate-character": "^3.0.0",
"magic-string": "^0.30.10",
"mocha": "^10.4.0",
"mocha": "^10.6.0",
"mocha-chai-jest-snapshot": "^1.1.4",
"nyc": "^17.0.0",
"prettier": "~3.3.2",
"prettier-plugin-pkg": "^0.18.1",
"prettier-plugin-svelte": "^3.2.4",
"rimraf": "^5.0.7",
"prettier-plugin-svelte": "^3.2.5",
"rimraf": "^6.0.0",
"semver": "^7.6.2",
"svelte": "^5.0.0-next.158",
"svelte2tsx": "^0.7.10",
"typescript": "~5.5.0",
"svelte": "^5.0.0-next.181",
"svelte2tsx": "^0.7.13",
"typescript": "~5.5.3",
"typescript-eslint-parser-for-extra-files": "^0.7.0"
},
"publishConfig": {
16 changes: 2 additions & 14 deletions src/context/index.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import type {
} from "../ast";
import type ESTree from "estree";
import type * as SvAST from "../parser/svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../parser/svelte-ast-types-for-v5";
import { ScriptLetContext } from "./script-let";
import { LetDirectiveCollections } from "./let-directive-collection";
import { parseAttributes } from "../parser/html";
@@ -169,19 +169,7 @@ export class Context {
| SvAST.SlotTemplate
| SvAST.Slot
| SvAST.Title
| Compiler.RegularElement
| Compiler.Component
| Compiler.SvelteComponent
| Compiler.SvelteElement
| Compiler.SvelteWindow
| Compiler.SvelteBody
| Compiler.SvelteHead
| Compiler.SvelteDocument
| Compiler.SvelteFragment
| Compiler.SvelteSelf
| Compiler.SvelteOptionsRaw
| Compiler.SlotElement
| Compiler.TitleElement
| Compiler.ElementLike
>();

public readonly snippets: SvelteSnippetBlock[] = [];
2 changes: 1 addition & 1 deletion src/meta.ts
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
// This file has been automatically generated,
// in order to update its content execute "pnpm run build:meta"
export const name = "svelte-eslint-parser";
export const version = "0.39.2";
export const version = "0.40.0";
2 changes: 1 addition & 1 deletion src/parser/compat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Compatibility for Svelte v4 <-> v5 */
import type ESTree from "estree";
import type * as SvAST from "./svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "./svelte-ast-types-for-v5";

export type Child =
| Compiler.Text
2 changes: 1 addition & 1 deletion src/parser/converts/attr.ts
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ import type {
import type ESTree from "estree";
import type { Context } from "../../context";
import type * as SvAST from "../svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../svelte-ast-types-for-v5";
import { getWithLoc, indexOf } from "./common";
import { convertMustacheTag } from "./mustache";
import { convertTextToLiteral } from "./text";
34 changes: 18 additions & 16 deletions src/parser/converts/block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as SvAST from "../svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../svelte-ast-types-for-v5";
import type {
SvelteAwaitBlock,
SvelteAwaitBlockAwaitCatch,
@@ -114,20 +114,21 @@ export function convertIfBlock(
node: SvAST.IfBlock | Compiler.IfBlock,
parent: SvelteIfBlock["parent"],
ctx: Context,
elseif: true,
elseifContext?: { start: number },
): SvelteIfBlockElseIf;
/** Convert for IfBlock */
export function convertIfBlock(
node: SvAST.IfBlock | Compiler.IfBlock,
parent: SvelteIfBlock["parent"],
ctx: Context,
elseif?: true,
elseifContext?: { start: number },
): SvelteIfBlock {
// {#if expr} {:else} {/if}
// {:else if expr} {/if}
const elseif = Boolean(elseifContext);
const nodeStart = startBlockIndex(
ctx.code,
elseif ? node.start - 1 : node.start,
elseifContext?.start ?? node.start,
elseif ? ":else" : "#if",
);
const ifBlock: SvelteIfBlock = {
@@ -188,7 +189,9 @@ export function convertIfBlock(
};
ifBlock.else = elseBlock;

const elseIfBlock = convertIfBlock(c, elseBlock, ctx, true);
const elseIfBlock = convertIfBlock(c, elseBlock, ctx, {
start: elseStart,
});
// adjust loc
elseBlock.range[1] = elseIfBlock.range[1];
elseBlock.loc.end = {
@@ -238,22 +241,21 @@ function startBlockIndexForElse(
lastExpression: ESTree.Node | { start: number; end: number },
ctx: Context,
) {
let baseStart: number;
const elseChildren = getChildren(elseFragment);
if (elseChildren.length > 0) {
const c = elseChildren[0];
baseStart = c.start;
if (c.type === "IfBlock" && c.elseif) {
baseStart = Math.min(baseStart, getWithLoc(getTestFromIfBlock(c)).start);
const contentStart = getWithLoc(getTestFromIfBlock(c)).start;
if (contentStart <= c.start) {
return startBlockIndex(ctx.code, contentStart - 1, ":else");
}
}
} else {
const beforeEnd = endIndexFromFragment(beforeFragment, () => {
return ctx.code.indexOf("}", getWithLoc(lastExpression).end) + 1;
});
baseStart = beforeEnd + 1;
return startBlockIndex(ctx.code, c.start, ":else");
}

return startBlockIndex(ctx.code, baseStart - 1, ":else");
const beforeEnd = endIndexFromFragment(beforeFragment, () => {
return ctx.code.indexOf("}", getWithLoc(lastExpression).end) + 1;
});
return startBlockIndex(ctx.code, beforeEnd, ":else");
}

/** Convert for EachBlock */
@@ -706,7 +708,7 @@ function extractMustacheBlockTokens(
| SvelteKeyBlock
| SvelteSnippetBlock,
ctx: Context,
option?: { startOnly?: true },
option?: { startOnly?: boolean },
) {
const startSectionNameStart = indexOf(
ctx.code,
2 changes: 1 addition & 1 deletion src/parser/converts/const.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import type { SvelteConstTag } from "../../ast";
import type { Context } from "../../context";
import { getDeclaratorFromConstTag } from "../compat";
import type * as SvAST from "../svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../svelte-ast-types-for-v5";

/** Convert for ConstTag */
export function convertConstTag(
2 changes: 1 addition & 1 deletion src/parser/converts/element.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ import type {
import type ESTree from "estree";
import type { Context } from "../../context";
import type * as SvAST from "../svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../svelte-ast-types-for-v5";

import {
convertAwaitBlock,
2 changes: 1 addition & 1 deletion src/parser/converts/mustache.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import type {
import type { Context } from "../../context";
import type * as SvAST from "../svelte-ast-types";
import { hasTypeInfo } from "../../utils";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../svelte-ast-types-for-v5";

/** Convert for MustacheTag */
export function convertMustacheTag(
2 changes: 1 addition & 1 deletion src/parser/converts/render.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import type * as ESTree from "estree";
import type { SvelteRenderTag } from "../../ast";
import type { Context } from "../../context";
import { getWithLoc } from "./common";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../svelte-ast-types-for-v5";

/** Convert for RenderTag */
export function convertRenderTag(
2 changes: 1 addition & 1 deletion src/parser/converts/root.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as SvAST from "../svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "../svelte-ast-types-for-v5";
import type {
SvelteAttribute,
SvelteGenericsDirective,
2 changes: 1 addition & 1 deletion src/parser/html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "./svelte-ast-types-for-v5";
import type ESTree from "estree";
import { getEspree } from "./espree";

2 changes: 1 addition & 1 deletion src/parser/index.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import type { ScopeManager } from "eslint-scope";
import { Variable } from "eslint-scope";
import { parseScript, parseScriptInSvelte } from "./script";
import type * as SvAST from "./svelte-ast-types";
import type * as Compiler from "svelte/compiler";
import type * as Compiler from "./svelte-ast-types-for-v5";
import { sortNodes } from "./sort";
import { parseTemplate } from "./template";
import {
Loading