Skip to content

Commit

Permalink
Merge branch 'master' into svelte-check-major
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm authored Aug 27, 2024
2 parents f580633 + 0655c67 commit 6a7f19d
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 53 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/DeploySvelte2tsxProd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:

jobs:
deploy:
permissions:
id-token: write # OpenID Connect token needed for provenance

runs-on: ubuntu-latest

steps:
Expand All @@ -32,7 +35,7 @@ jobs:
- run: |
cd packages/svelte2tsx
pnpm install
pnpm publish --no-git-checks
pnpm publish --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/DeploySvelteCheckProd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:

jobs:
deploy:
permissions:
id-token: write # OpenID Connect token needed for provenance

runs-on: ubuntu-latest

steps:
Expand All @@ -33,7 +36,7 @@ jobs:
- run: |
cd packages/svelte-check
pnpm install
pnpm publish --no-git-checks
pnpm publish --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/DeploySvelteLanguageServerProd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:

jobs:
deploy:
permissions:
id-token: write # OpenID Connect token needed for provenance

runs-on: ubuntu-latest

steps:
Expand All @@ -32,7 +35,7 @@ jobs:
- run: |
cd packages/language-server
pnpm install
pnpm publish --no-git-checks
pnpm publish --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 4 additions & 1 deletion .github/workflows/DeployTypescriptPluginProd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:

jobs:
deploy:
permissions:
id-token: write # OpenID Connect token needed for provenance

runs-on: ubuntu-latest

steps:
Expand All @@ -32,7 +35,7 @@ jobs:
- run: |
cd packages/typescript-plugin
pnpm install
pnpm publish --no-git-checks
pnpm publish --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ describe('ConfigLoader', () => {

assert.deepStrictEqual(
// Can't do the equal-check directly, instead check if it's the expected object props
// of svelte-preprocess
Object.keys(
configLoader.getConfig(normalizePath('/some/path/comp.svelte'))?.preprocess || {}
).sort(),
['markup', 'script', 'style'].sort()
['name', 'script'].sort()
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,60 +483,66 @@ describe('SveltePlugin#getDiagnostics', () => {
const { plugin, document } = setupFromFile('diagnostics-module.svelte');
const diagnostics = await plugin.getDiagnostics(document);

assert.deepStrictEqual(diagnostics, [
{
range: { start: { line: 1, character: 4 }, end: { line: 1, character: 26 } },
message: isSvelte5Plus
? 'Reactive declarations only exist at the top level of the instance script'
: '$: has no effect in a module script',
severity: 2,
source: 'svelte',
code: isSvelte5Plus
? 'reactive_declaration_invalid_placement'
: 'module-script-reactive-declaration'
}
]);
assert.deepStrictEqual(
diagnostics.filter((d) => d.code !== 'script_context_deprecated'),
[
{
range: { start: { line: 1, character: 4 }, end: { line: 1, character: 26 } },
message: isSvelte5Plus
? 'Reactive declarations only exist at the top level of the instance script'
: '$: has no effect in a module script',
severity: 2,
source: 'svelte',
code: isSvelte5Plus
? 'reactive_declaration_invalid_placement'
: 'module-script-reactive-declaration'
}
]
);
});

it('should correctly determine diagnostic position for script when theres also context="module"', async () => {
const { plugin, document } = setupFromFile('diagnostics-module-and-instance.svelte');
const diagnostics = await plugin.getDiagnostics(document);

assert.deepStrictEqual(diagnostics, [
{
code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let',
message:
"Component has unused export property 'unused1'. If it is for external reference only, please consider using `export const unused1`",
range: {
start: {
line: 5,
character: 13
assert.deepStrictEqual(
diagnostics.filter((d) => d.code !== 'script_context_deprecated'),
[
{
code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let',
message:
"Component has unused export property 'unused1'. If it is for external reference only, please consider using `export const unused1`",
range: {
start: {
line: 5,
character: 13
},
end: {
line: 5,
character: isSvelte5Plus ? 20 : 27
}
},
end: {
line: 5,
character: isSvelte5Plus ? 20 : 27
}
severity: 2,
source: 'svelte'
},
severity: 2,
source: 'svelte'
},
{
code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let',
message:
"Component has unused export property 'unused2'. If it is for external reference only, please consider using `export const unused2`",
range: {
start: {
line: 6,
character: 13
{
code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let',
message:
"Component has unused export property 'unused2'. If it is for external reference only, please consider using `export const unused2`",
range: {
start: {
line: 6,
character: 13
},
end: {
line: 6,
character: isSvelte5Plus ? 20 : 27
}
},
end: {
line: 6,
character: isSvelte5Plus ? 20 : 27
}
},
severity: 2,
source: 'svelte'
}
]);
severity: 2,
source: 'svelte'
}
]
);
});
});
6 changes: 5 additions & 1 deletion packages/svelte2tsx/src/svelte2tsx/nodes/Scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export class Scripts {
if (
tag.attributes &&
tag.attributes.find(
(a) => a.name == 'context' && a.value.length == 1 && a.value[0].raw == 'module'
(a) =>
(a.name == 'context' &&
a.value.length == 1 &&
a.value[0].raw == 'module') ||
a.name === 'module'
)
) {
moduleScriptTag = tag;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
///<reference types="svelte" />
;
export function preload() {}
let b = 5;
;;function render() {

let world = "name"
;
async () => {

{ svelteHTML.createElement("h1", {}); world; }};
return { props: {world: world}, slots: {}, events: {} }}

export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(['world'], __sveltets_2_with_any_event(render()))) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
export let world = "name"
</script>
<script module>
export function preload() {}
let b = 5;
</script>
<h1>hello {world}</h1>

0 comments on commit 6a7f19d

Please sign in to comment.