-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support for reactive vars type information (#207)
* fix: wrong store access type information * Create grumpy-avocados-behave.md * test: update new fixture * test: ignore ts-eslint v4 * fix: support for reactive vars type information * Create tame-tigers-brush.md * test: ignore ts-eslint v4
- Loading branch information
Showing
33 changed files
with
59,826 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte-eslint-parser": patch | ||
--- | ||
|
||
fix: support for reactive vars type information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/fixtures/integrations/type-info-tests/reactive-input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
let x = "hello" | ||
const get = ()=>"hello" | ||
$: y = x | ||
$: z = y | ||
$: foo = get | ||
</script> | ||
|
||
<input title={z} bind:value={x}> | ||
{foo()} |
1 change: 1 addition & 0 deletions
1
tests/fixtures/integrations/type-info-tests/reactive-output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
44 changes: 44 additions & 0 deletions
44
tests/fixtures/integrations/type-info-tests/reactive-setup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint eslint-comments/require-description: 0, @typescript-eslint/explicit-module-boundary-types: 0 */ | ||
import type { Linter } from "eslint"; | ||
import { BASIC_PARSER_OPTIONS } from "../../../src/parser/test-utils"; | ||
import { rules } from "@typescript-eslint/eslint-plugin"; | ||
export function setupLinter(linter: Linter) { | ||
linter.defineRule( | ||
"@typescript-eslint/no-unsafe-argument", | ||
rules["no-unsafe-argument"] as never | ||
); | ||
linter.defineRule( | ||
"@typescript-eslint/no-unsafe-assignment", | ||
rules["no-unsafe-assignment"] as never | ||
); | ||
linter.defineRule( | ||
"@typescript-eslint/no-unsafe-call", | ||
rules["no-unsafe-call"] as never | ||
); | ||
linter.defineRule( | ||
"@typescript-eslint/no-unsafe-member-access", | ||
rules["no-unsafe-member-access"] as never | ||
); | ||
linter.defineRule( | ||
"@typescript-eslint/no-unsafe-return", | ||
rules["no-unsafe-return"] as never | ||
); | ||
} | ||
|
||
export function getConfig() { | ||
return { | ||
parser: "svelte-eslint-parser", | ||
parserOptions: BASIC_PARSER_OPTIONS, | ||
rules: { | ||
"@typescript-eslint/no-unsafe-argument": "error", | ||
"@typescript-eslint/no-unsafe-assignment": "error", | ||
"@typescript-eslint/no-unsafe-call": "error", | ||
"@typescript-eslint/no-unsafe-member-access": "error", | ||
"@typescript-eslint/no-unsafe-return": "error", | ||
}, | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
}; | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/fixtures/integrations/type-info-tests/reactive2-input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script lang="ts"> | ||
// https://github.com/ota-meshi/svelte-eslint-parser/issues/206 | ||
let obj = { | ||
child: { | ||
title: "hello!", | ||
}, | ||
}; | ||
$: child = obj.child; | ||
$: title = child?.title ?? "Yo!"; | ||
</script> | ||
|
||
{child}{title} |
1 change: 1 addition & 0 deletions
1
tests/fixtures/integrations/type-info-tests/reactive2-output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
29 changes: 29 additions & 0 deletions
29
tests/fixtures/integrations/type-info-tests/reactive2-setup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint eslint-comments/require-description: 0, @typescript-eslint/explicit-module-boundary-types: 0 */ | ||
import type { Linter } from "eslint"; | ||
import { BASIC_PARSER_OPTIONS } from "../../../src/parser/test-utils"; | ||
import { rules } from "@typescript-eslint/eslint-plugin"; | ||
export function setupLinter(linter: Linter) { | ||
linter.defineRule( | ||
"@typescript-eslint/no-unsafe-assignment", | ||
rules["no-unsafe-assignment"] as never | ||
); | ||
linter.defineRule( | ||
"@typescript-eslint/no-unsafe-member-access", | ||
rules["no-unsafe-member-access"] as never | ||
); | ||
} | ||
|
||
export function getConfig() { | ||
return { | ||
parser: "svelte-eslint-parser", | ||
parserOptions: BASIC_PARSER_OPTIONS, | ||
rules: { | ||
"@typescript-eslint/no-unsafe-assignment": "error", | ||
"@typescript-eslint/no-unsafe-member-access": "error", | ||
}, | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
let x = "hello" | ||
const get = ()=>"hello" | ||
$: y = x | ||
$: z = y | ||
$: foo = get | ||
</script> | ||
|
||
<input title={z} bind:value={x}> | ||
{foo()} |
Oops, something went wrong.