diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7de5a35e13..05b48f2ae0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ ### Before submitting the PR, please make sure you do the following - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs -- [ ] Prefix your PR title with `[feat]`, `[fix]`, `[chore]`, or `[docs]`. +- [ ] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`. - [ ] This message body should clearly illustrate what problems it solves. - [ ] Ideally, include a test that fails without this PR but passes with it. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbfde04f67..1e0ce53864 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,29 +1,86 @@ name: CI -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: +permissions: + contents: read # to fetch code (actions/checkout) jobs: + Setup: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: npm + - run: npm install + env: + SKIP_PREPARE: true + - run: npm run build + env: + PUBLISH: true + - name: Upload build assets + id: upload-artifact + uses: actions/upload-artifact@v3 + with: + name: build-assets + path: | + index.* + compiler.* + ssr.* + action/ + animate/ + easing/ + internal/ + motion/ + store/ + transition/ + types/ Tests: + needs: Setup runs-on: ${{ matrix.os }} timeout-minutes: 15 strategy: matrix: - node-version: [8, 10, 12, 14, 16] + node-version: [8, 10, 12, 14, 16, 18] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: npm + - name: Download build assets + uses: actions/download-artifact@v3 + id: download-artifact + with: + name: build-assets + - name: Get Node version ${{ runner.os }} + run: echo "NODE_VERSION=`node --version`" >> $GITHUB_ENV + if: runner.os != 'Windows' + - name: Get Node version ${{ runner.os }} + run: | + chcp 65001 + echo ("NODE_VERSION=$(node --version)") >> $env:GITHUB_ENV + if: runner.os == 'Windows' + - run: npm install --save-dev puppeteer@13 + if: ${{ runner.os == 'Linux' && (!startsWith(env.NODE_VERSION, 'v8.') && !startsWith(env.NODE_VERSION, 'v10.')) }} - run: npm install - - run: npm test + env: + SKIP_PREPARE: true + - run: npm run test:integration env: CI: true Lint: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: cache: npm - run: 'npm i && npm run lint' @@ -34,8 +91,11 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: cache: npm - - run: 'npm i && npm run test:unit' + - run: npm install + env: + SKIP_PREPARE: true + - run: npm run test:unit diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ea6e0f5a60..763fb72577 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,6 +7,8 @@ on: paths: - site/content/** +permissions: {} + jobs: release: name: Deploy docs @@ -25,4 +27,4 @@ jobs: repo: 'svelte' branch: 'master' docs_path: 'site/content' - token: ${{ steps.github-app.outputs.token }} \ No newline at end of file + token: ${{ steps.github-app.outputs.token }} diff --git a/.gitignore b/.gitignore index ee1daa2c03..e70d995994 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .idea .DS_Store -.nyc_output .vscode node_modules *.map @@ -9,6 +8,7 @@ node_modules /compiler.*js /index.*js /ssr.*js +/action /internal /store /easing @@ -21,3 +21,4 @@ node_modules _actual*.* _output /types +.eslintcache diff --git a/.mocharc.js b/.mocharc.js index e55f26099e..449f81ecd6 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -1,7 +1,7 @@ +const is_unit_test = process.env.UNIT_TEST; + module.exports = { - file: [ - 'test/test.ts' - ], + file: is_unit_test ? [] : ['test/test.ts'], require: [ 'sucrase/register' ] diff --git a/.mocharc.unit.js b/.mocharc.unit.js new file mode 100644 index 0000000000..387d70e7e0 --- /dev/null +++ b/.mocharc.unit.js @@ -0,0 +1,15 @@ +module.exports = { + spec: [ + 'src/**/__test__.ts', + ], + require: [ + 'sucrase/register' + ], + recursive: true, +}; + +// add coverage options when running 'npx c8 mocha' +if (process.env.NODE_V8_COVERAGE) { + module.exports.fullTrace = true; + module.exports.require.push('source-map-support/register'); +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd186cfcb..610e92f4a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,149 @@ # Svelte changelog +## Unreleased + +* Make `noreferrer` warning less zealous ([#6289](https://github.com/sveltejs/svelte/issues/6289)) +* `trusted-types` CSP compatibility for Web Components ([#8134](https://github.com/sveltejs/svelte/issues/8134)) +* Add `data-sveltekit-replacestate` and `data-sveltekit-keepfocus` attribute typings ([#8281](https://github.com/sveltejs/svelte/issues/8281)) + +## 3.55.1 + +* Fix `draw` transition with delay showing a dot at the beginning of the path ([#6816](https://github.com/sveltejs/svelte/issues/6816)) +* Fix infinity runtime call stack when propagating bindings ([#7032](https://github.com/sveltejs/svelte/issues/7032)) +* Fix static `` optimization in production mode ([#7937](https://github.com/sveltejs/svelte/issues/7937)) +* Fix `svelte-ignore` comment breaking named slot ([#8075](https://github.com/sveltejs/svelte/issues/8075)) +* Revert change to prevent running init binding unnecessarily ([#8103](https://github.com/sveltejs/svelte/issues/8103)) +* Fix adding duplicate event listeners with `` ([#8129](https://github.com/sveltejs/svelte/issues/8129)) +* Improve detection of promises that are also functions ([#8162](https://github.com/sveltejs/svelte/pull/8162)) +* Avoid mutating spread component props during SSR ([#8171](https://github.com/sveltejs/svelte/issues/8171)) +* Add missing typing for global `part` attribute ([#8181](https://github.com/sveltejs/svelte/issues/8181)) +* Add missing `submitter` property to `on:submit` event type + +## 3.55.0 + +* Add `svelte/elements` for HTML/Svelte typings ([#7649](https://github.com/sveltejs/svelte/pull/7649)) + +## 3.54.0 + +* Pass `options.direction` argument to custom transition functions ([#3918](https://github.com/sveltejs/svelte/issues/3918)) +* Support fallback a11y WAI-ARIA roles ([#8044](https://github.com/sveltejs/svelte/issues/8044)) +* Prevent running init binding unnecessarily ([#5689](https://github.com/sveltejs/svelte/issues/5689), [#6298](https://github.com/sveltejs/svelte/issues/6298)) +* Allow updating variables from `@const` declared function ([#7843](https://github.com/sveltejs/svelte/issues/7843)) +* Do not emit `a11y-no-noninteractive-tabindex` warning if element has a `tabpanel` ([#8025](https://github.com/sveltejs/svelte/pull/8025)) +* Fix escaping SSR'd values in `style:` directive ([#8085](https://github.com/sveltejs/svelte/issues/8085)) + +## 3.53.1 + +* Fix exception in `rel=` attribute check with dynamic values ([#7994](https://github.com/sveltejs/svelte/issues/7994)) +* Do not emit deprecation warnings for `css` compiler options for now ([#8009](https://github.com/sveltejs/svelte/issues/8009)) +* Make compiler run in browser again ([#8010](https://github.com/sveltejs/svelte/issues/8010)) +* Upgrade `tslib` ([#8013](https://github.com/sveltejs/svelte/issues/8013)) + +## 3.53.0 + +* Check whether `parentNode` exists before removing child ([#6037](https://github.com/sveltejs/svelte/issues/6037)) +* Upgrade various dependencies, notably `css-tree` to `2.2.1` ([#7572](https://github.com/sveltejs/svelte/pull/7572), [#7982](https://github.com/sveltejs/svelte/pull/7982)) +* Extend `css` compiler option with `'external' | 'injected' | 'none'` settings and deprecate old `true | false` values ([#7914](https://github.com/sveltejs/svelte/pull/7914)) + +## 3.52.0 + +* Throw compile-time error when attempting to update `const` variable ([#4895](https://github.com/sveltejs/svelte/issues/4895)) +* Warn when using `` without `rel="noreferrer"` ([#6188](https://github.com/sveltejs/svelte/issues/6188)) +* Support `style:foo|important` modifier ([#7365](https://github.com/sveltejs/svelte/issues/7365)) +* Fix hydration regression with `{@html}` and components in `` ([#7941](https://github.com/sveltejs/svelte/pull/7941)) + +## 3.51.0 + +* Add a11y warnings: + * `a11y-click-events-have-key-events`: check if click event is accompanied by key events ([#5073](https://github.com/sveltejs/svelte/pull/5073)) + * `a11y-no-noninteractive-tabindex`: check for tabindex on non-interactive elements ([#6693](https://github.com/sveltejs/svelte/pull/6693)) +* Warn when two-way binding to `{...rest}` object in `{#each}` block ([#6860](https://github.com/sveltejs/svelte/issues/6860)) +* Support `--style-props` on `` ([#7461](https://github.com/sveltejs/svelte/issues/7461)) +* Supports nullish values for component event handlers ([#7568](https://github.com/sveltejs/svelte/issues/7568)) +* Supports SVG elements with ``([#7613](https://github.com/sveltejs/svelte/issues/7613)) +* Treat `inert` as boolean attribute ([#7785](https://github.com/sveltejs/svelte/pull/7785)) +* Support `--style-props` for SVG components ([#7808](https://github.com/sveltejs/svelte/issues/7808)) +* Fix false positive dev warnings about unset props when they are bound ([#4457](https://github.com/sveltejs/svelte/issues/4457)) +* Fix hydration with `{@html}` and components in `` ([#4533](https://github.com/sveltejs/svelte/issues/4533), [#6463](https://github.com/sveltejs/svelte/issues/6463), [#7444](https://github.com/sveltejs/svelte/issues/7444)) +* Support scoped style for `` ([#7443](https://github.com/sveltejs/svelte/issues/7443)) +* Improve error message for invalid value for `` ([#7550](https://github.com/sveltejs/svelte/issues/7550)) +* Improve error message when using logic blocks or tags at invalid location ([#7552](https://github.com/sveltejs/svelte/issues/7552)) +* Warn instead of throwing error if `` is a void tag ([#7566](https://github.com/sveltejs/svelte/issues/7566)) +* Supports custom elements in `` ([#7733](https://github.com/sveltejs/svelte/issues/7733)) +* Fix calling component unmount if a component is mounted and then immediately unmounted ([#7817](https://github.com/sveltejs/svelte/issues/7817)) +* Do not generate `a11y-role-has-required-aria-props` warning when elements match their semantic role ([#7837](https://github.com/sveltejs/svelte/issues/7837)) +* Improve performance of custom element data setting in `` ([#7869](https://github.com/sveltejs/svelte/pull/7869)) + +## 3.50.1 + +* Add all global objects and functions as known globals ([#3805](https://github.com/sveltejs/svelte/issues/3805), [#7223](https://github.com/sveltejs/svelte/issues/7223)) +* Fix regression with style manager ([#7828](https://github.com/sveltejs/svelte/issues/7828)) + +## 3.50.0 + +* Add a11y warnings: + * `a11y-incorrect-aria-attribute-type`: check ARIA state and property values ([#6978](https://github.com/sveltejs/svelte/pull/6978)) + * `a11y-no-abstract-role`: check that ARIA roles are non-abstract ([#6241](https://github.com/sveltejs/svelte/pull/6241)) + * `a11y-no-interactive-element-to-noninteractive-role`: check for non-interactive roles used on interactive elements ([#5955](https://github.com/sveltejs/svelte/pull/5955)) + * `a11y-role-has-required-aria-props`: check that elements with `role` attribute have all required attributes for that role ([#5852](https://github.com/sveltejs/svelte/pull/5852)) +* Add `ComponentEvents` convenience type ([#7702](https://github.com/sveltejs/svelte/pull/7702)) +* Add `SveltePreprocessor` utility type ([#7742](https://github.com/sveltejs/svelte/pull/7742)) +* Enhance action typings ([#7805](https://github.com/sveltejs/svelte/pull/7805)) +* Remove empty stylesheets created from transitions ([#4801](https://github.com/sveltejs/svelte/issues/4801), [#7164](https://github.com/sveltejs/svelte/issues/7164)) +* Make `a11y-label-has-associated-control` warning check all descendants for input control ([#5528](https://github.com/sveltejs/svelte/issues/5528)) +* Only show lowercase component name warnings for non-HTML/SVG elements ([#5712](https://github.com/sveltejs/svelte/issues/5712)) +* Disallow invalid CSS selectors starting with a combinator ([#7643](https://github.com/sveltejs/svelte/issues/7643)) +* Use `Node.parentNode` instead of `Node.parentElement` for legacy browser support ([#7723](https://github.com/sveltejs/svelte/issues/7723)) +* Handle arrow function on `` inside `` ([#7485](https://github.com/sveltejs/svelte/issues/7485)) +* Improve parsing speed when encountering large blocks of whitespace ([#7675](https://github.com/sveltejs/svelte/issues/7675)) +* Fix `class:` directive updates in aborted/restarted transitions ([#7764](https://github.com/sveltejs/svelte/issues/7764)) + +## 3.49.0 + +* Improve performance of string escaping during SSR ([#5701](https://github.com/sveltejs/svelte/pull/5701)) +* Add `ComponentType` and `ComponentProps` convenience types ([#6770](https://github.com/sveltejs/svelte/pull/6770)) +* Add support for CSS `@layer` ([#7504](https://github.com/sveltejs/svelte/issues/7504)) +* Export `CompileOptions` from `svelte/compiler` ([#7658](https://github.com/sveltejs/svelte/pull/7658)) +* Fix DOM-less components not being properly destroyed ([#7488](https://github.com/sveltejs/svelte/issues/7488)) +* Fix `class:` directive updates with `` ([#7521](https://github.com/sveltejs/svelte/issues/7521), [#7571](https://github.com/sveltejs/svelte/issues/7571)) +* Harden attribute escaping during SSR ([#7530](https://github.com/sveltejs/svelte/pull/7530)) + +## 3.48.0 + +* Allow creating cancelable custom events with `createEventDispatcher` ([#4623](https://github.com/sveltejs/svelte/issues/4623)) +* Support `{@const}` tag in `{#if}` blocks [#7241](https://github.com/sveltejs/svelte/issues/7241) +* Return the context object in `setContext` [#7427](https://github.com/sveltejs/svelte/issues/7427) +* Allow comments inside `{#each}` blocks when using `animate:` ([#3999](https://github.com/sveltejs/svelte/issues/3999)) +* Fix `|local` transitions in `{#key}` blocks ([#5950](https://github.com/sveltejs/svelte/issues/5950)) +* Support svg namespace for `{@html}` ([#7002](https://github.com/sveltejs/svelte/issues/7002), [#7450](https://github.com/sveltejs/svelte/issues/7450)) +* Fix `{@const}` tag not working inside a component when there's no `let:` [#7189](https://github.com/sveltejs/svelte/issues/7189) +* Remove extraneous leading newline inside `
` and `
+
+
+ +
+ +
+ + + +
+ +
+ + + +
+ + + +
+ +
diff --git a/test/runtime/samples/transition-js-deferred-option-direction/_config.js b/test/runtime/samples/transition-js-deferred-option-direction/_config.js new file mode 100644 index 0000000000..2bf448d9c7 --- /dev/null +++ b/test/runtime/samples/transition-js-deferred-option-direction/_config.js @@ -0,0 +1,19 @@ +export default { + test({ assert, component, target }) { + component.visible = true; + + const div_in = target.querySelector('#in'); + const div_out = target.querySelector('#out'); + const div_both = target.querySelector('#both'); + + assert.equal(div_in.initial, 'in'); + assert.equal(div_out.initial, 'out'); + assert.equal(div_both.initial, 'both'); + + return Promise.resolve().then(() => { + assert.equal(div_in.later, 'in'); + assert.equal(div_out.later, 'out'); + assert.equal(div_both.later, 'both'); + }); + } +}; diff --git a/test/runtime/samples/transition-js-deferred-option-direction/main.svelte b/test/runtime/samples/transition-js-deferred-option-direction/main.svelte new file mode 100644 index 0000000000..9ac816ce75 --- /dev/null +++ b/test/runtime/samples/transition-js-deferred-option-direction/main.svelte @@ -0,0 +1,24 @@ + + +{#if visible} +
+
+{/if} + +{#if !visible} +
+{/if} diff --git a/test/runtime/samples/transition-js-option-direction/_config.js b/test/runtime/samples/transition-js-option-direction/_config.js new file mode 100644 index 0000000000..649b4ec7fa --- /dev/null +++ b/test/runtime/samples/transition-js-option-direction/_config.js @@ -0,0 +1,13 @@ +export default { + test({ assert, component, target }) { + component.visible = true; + + const div_in = target.querySelector('#in'); + const div_out = target.querySelector('#out'); + const div_both = target.querySelector('#both'); + + assert.equal(div_in.direction, 'in'); + assert.equal(div_out.direction, 'out'); + assert.equal(div_both.direction, 'both'); + } +}; diff --git a/test/runtime/samples/transition-js-option-direction/main.svelte b/test/runtime/samples/transition-js-option-direction/main.svelte new file mode 100644 index 0000000000..7bae2c158d --- /dev/null +++ b/test/runtime/samples/transition-js-option-direction/main.svelte @@ -0,0 +1,20 @@ + + +{#if visible} +
+
+{/if} + +{#if !visible} +
+{/if} diff --git a/test/server-side-rendering/index.ts b/test/server-side-rendering/index.ts index f5773e37b6..a5458be109 100644 --- a/test/server-side-rendering/index.ts +++ b/test/server-side-rendering/index.ts @@ -84,7 +84,7 @@ describe('ssr', () => { try { if (config.withoutNormalizeHtml) { - assert.strictEqual(html.trim(), expectedHtml.trim().replace(/\r\n/g, '\n')); + assert.strictEqual(html.trim().replace(/\r\n/g, '\n'), expectedHtml.trim().replace(/\r\n/g, '\n')); } else { (compileOptions.preserveComments ? assert.htmlEqualWithComments @@ -117,7 +117,9 @@ describe('ssr', () => { fs.writeFileSync(`${dir}/_actual-head.html`, head); try { - assert.htmlEqual( + (compileOptions.hydratable + ? assert.htmlEqualWithComments + : assert.htmlEqual)( head, fs.readFileSync(`${dir}/_expected-head.html`, 'utf-8') ); diff --git a/test/server-side-rendering/samples/attribute-escaped-quotes-spread/_expected.html b/test/server-side-rendering/samples/attribute-escaped-quotes-spread/_expected.html index b3970f88ba..5db9a90fff 100644 --- a/test/server-side-rendering/samples/attribute-escaped-quotes-spread/_expected.html +++ b/test/server-side-rendering/samples/attribute-escaped-quotes-spread/_expected.html @@ -2,4 +2,10 @@ bar="'>" foo="">" qux="&&&" -> \ No newline at end of file + quux="">" +> + +
diff --git a/test/server-side-rendering/samples/attribute-escaped-quotes-spread/main.svelte b/test/server-side-rendering/samples/attribute-escaped-quotes-spread/main.svelte index 66047eb09a..9d721cd88f 100644 --- a/test/server-side-rendering/samples/attribute-escaped-quotes-spread/main.svelte +++ b/test/server-side-rendering/samples/attribute-escaped-quotes-spread/main.svelte @@ -1,10 +1,15 @@ -
\ No newline at end of file +
+
diff --git a/test/server-side-rendering/samples/attribute-escaped-quotes/_expected.html b/test/server-side-rendering/samples/attribute-escaped-quotes/_expected.html index c3c9405d7b..e99c5b0f6e 100644 --- a/test/server-side-rendering/samples/attribute-escaped-quotes/_expected.html +++ b/test/server-side-rendering/samples/attribute-escaped-quotes/_expected.html @@ -1,3 +1,4 @@
\ No newline at end of file + foo="">\" + bar="">\" +> diff --git a/test/server-side-rendering/samples/attribute-escaped-quotes/main.svelte b/test/server-side-rendering/samples/attribute-escaped-quotes/main.svelte index ed34f4d129..aeed0f20d1 100644 --- a/test/server-side-rendering/samples/attribute-escaped-quotes/main.svelte +++ b/test/server-side-rendering/samples/attribute-escaped-quotes/main.svelte @@ -1,5 +1,6 @@ -
\ No newline at end of file +
diff --git a/test/server-side-rendering/samples/dynamic-element-string/_expected.html b/test/server-side-rendering/samples/dynamic-element-string/_expected.html new file mode 100644 index 0000000000..cb98432e14 --- /dev/null +++ b/test/server-side-rendering/samples/dynamic-element-string/_expected.html @@ -0,0 +1 @@ +
Foo
diff --git a/test/server-side-rendering/samples/dynamic-element-string/main.svelte b/test/server-side-rendering/samples/dynamic-element-string/main.svelte new file mode 100644 index 0000000000..62d65d5f20 --- /dev/null +++ b/test/server-side-rendering/samples/dynamic-element-string/main.svelte @@ -0,0 +1 @@ +Foo \ No newline at end of file diff --git a/test/server-side-rendering/samples/dynamic-element-variable/_expected.html b/test/server-side-rendering/samples/dynamic-element-variable/_expected.html new file mode 100644 index 0000000000..3ae445f54c --- /dev/null +++ b/test/server-side-rendering/samples/dynamic-element-variable/_expected.html @@ -0,0 +1,2 @@ +

Foo

+
Bar
\ No newline at end of file diff --git a/test/server-side-rendering/samples/dynamic-element-variable/main.svelte b/test/server-side-rendering/samples/dynamic-element-variable/main.svelte new file mode 100644 index 0000000000..9aaba18bf1 --- /dev/null +++ b/test/server-side-rendering/samples/dynamic-element-variable/main.svelte @@ -0,0 +1,7 @@ + + +Foo +Bar \ No newline at end of file diff --git a/test/server-side-rendering/samples/head-html-and-component/HeadNested.svelte b/test/server-side-rendering/samples/head-html-and-component/HeadNested.svelte new file mode 100644 index 0000000000..33bbdd1fd1 --- /dev/null +++ b/test/server-side-rendering/samples/head-html-and-component/HeadNested.svelte @@ -0,0 +1,2 @@ +{@html ''} + diff --git a/test/server-side-rendering/samples/head-html-and-component/Nested.svelte b/test/server-side-rendering/samples/head-html-and-component/Nested.svelte new file mode 100644 index 0000000000..28f5371910 --- /dev/null +++ b/test/server-side-rendering/samples/head-html-and-component/Nested.svelte @@ -0,0 +1,5 @@ + + + {@html ''} + + diff --git a/test/server-side-rendering/samples/head-html-and-component/_expected-head.html b/test/server-side-rendering/samples/head-html-and-component/_expected-head.html new file mode 100644 index 0000000000..da265f414d --- /dev/null +++ b/test/server-side-rendering/samples/head-html-and-component/_expected-head.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/server-side-rendering/samples/head-html-and-component/_expected.html b/test/server-side-rendering/samples/head-html-and-component/_expected.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/server-side-rendering/samples/head-html-and-component/main.svelte b/test/server-side-rendering/samples/head-html-and-component/main.svelte new file mode 100644 index 0000000000..188ecace6b --- /dev/null +++ b/test/server-side-rendering/samples/head-html-and-component/main.svelte @@ -0,0 +1,12 @@ + + + + {@html ''} + + + + + diff --git a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_config.js b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_config.js index ae9b250f86..f1f4fff921 100644 --- a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_config.js +++ b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_config.js @@ -1,5 +1,6 @@ export default { compileOptions: { hydratable: true - } + }, + withoutNormalizeHtml: true }; diff --git a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html index 107753cdd0..bdd08c32f5 100644 --- a/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html +++ b/test/server-side-rendering/samples/head-meta-hydrate-duplicate/_expected-head.html @@ -1,4 +1,6 @@ Some Title - - - \ No newline at end of file + + + + + diff --git a/test/server-side-rendering/samples/pre-tag/.editorconfig b/test/server-side-rendering/samples/pre-tag/.editorconfig new file mode 100644 index 0000000000..d53d6a3faf --- /dev/null +++ b/test/server-side-rendering/samples/pre-tag/.editorconfig @@ -0,0 +1,2 @@ +[{main.svelte,_expected.html}] +trim_trailing_whitespace = unset diff --git a/test/server-side-rendering/samples/pre-tag/_expected.html b/test/server-side-rendering/samples/pre-tag/_expected.html index 7f88acdff4..5459102786 100644 --- a/test/server-side-rendering/samples/pre-tag/_expected.html +++ b/test/server-side-rendering/samples/pre-tag/_expected.html @@ -1,5 +1,4 @@ -
-  A
+
  A
   B
   
     C
@@ -18,8 +17,7 @@
   F
 
 
-
-    A
+
    A
     B
     
       C
@@ -28,3 +26,14 @@
     E
     F
   
+ +
leading newline
+
  leading newline and spaces
+
+
+leading newlines
+ +
without spaces
+
  with spaces  
+
 
+newline after leading space
diff --git a/test/server-side-rendering/samples/pre-tag/main.svelte b/test/server-side-rendering/samples/pre-tag/main.svelte index fb240817f7..be3bf9e7ff 100644 --- a/test/server-side-rendering/samples/pre-tag/main.svelte +++ b/test/server-side-rendering/samples/pre-tag/main.svelte @@ -32,3 +32,20 @@ F
+ +
+
+leading newline
+
+  leading newline and spaces
+
+
+leading newlines
+
+ +
+
without spaces
+
  with spaces  
+
 
+newline after leading space
+
diff --git a/test/server-side-rendering/samples/preserve-whitespaces/_expected.html b/test/server-side-rendering/samples/preserve-whitespaces/_expected.html index fb240817f7..c712354f6a 100644 --- a/test/server-side-rendering/samples/preserve-whitespaces/_expected.html +++ b/test/server-side-rendering/samples/preserve-whitespaces/_expected.html @@ -1,5 +1,4 @@ -
-  A
+
  A
   B
   
     C
@@ -21,8 +20,7 @@
 
 
 
-
-    A
+  
    A
     B
     
       C
diff --git a/test/server-side-rendering/samples/textarea-content/.editorconfig b/test/server-side-rendering/samples/textarea-content/.editorconfig
new file mode 100644
index 0000000000..d53d6a3faf
--- /dev/null
+++ b/test/server-side-rendering/samples/textarea-content/.editorconfig
@@ -0,0 +1,2 @@
+[{main.svelte,_expected.html}]
+trim_trailing_whitespace = unset
diff --git a/test/server-side-rendering/samples/textarea-content/_config.js b/test/server-side-rendering/samples/textarea-content/_config.js
new file mode 100644
index 0000000000..39b31839f5
--- /dev/null
+++ b/test/server-side-rendering/samples/textarea-content/_config.js
@@ -0,0 +1,3 @@
+export default {
+	withoutNormalizeHtml: true
+};
diff --git a/test/server-side-rendering/samples/textarea-content/_expected.html b/test/server-side-rendering/samples/textarea-content/_expected.html
new file mode 100644
index 0000000000..5ca4604bb6
--- /dev/null
+++ b/test/server-side-rendering/samples/textarea-content/_expected.html
@@ -0,0 +1,28 @@
+
+
+
+ +
+ +
+ +
+ +
+ + + +
diff --git a/test/server-side-rendering/samples/textarea-content/main.svelte b/test/server-side-rendering/samples/textarea-content/main.svelte new file mode 100644 index 0000000000..e2e052ca7a --- /dev/null +++ b/test/server-side-rendering/samples/textarea-content/main.svelte @@ -0,0 +1,40 @@ + + +
+ +
+ +
+ + + +
+ +
+ + + +
+ + + +
+ +
diff --git a/test/store/index.ts b/test/store/index.ts index b6fc5940e1..389f29244b 100644 --- a/test/store/index.ts +++ b/test/store/index.ts @@ -88,6 +88,14 @@ describe('store', () => { unsubscribe(); }); + + it('no error even if unsubscribe calls twice', () => { + let num = 0; + const store = writable(num, set => set(num += 1)); + const unsubscribe = store.subscribe(() => { }); + unsubscribe(); + assert.doesNotThrow(() => unsubscribe()); + }); }); describe('readable', () => { diff --git a/test/validator/samples/a11y-aria-proptypes-boolean/input.svelte b/test/validator/samples/a11y-aria-proptypes-boolean/input.svelte new file mode 100644 index 0000000000..c992928229 --- /dev/null +++ b/test/validator/samples/a11y-aria-proptypes-boolean/input.svelte @@ -0,0 +1,8 @@ + + + + +G diff --git a/test/validator/samples/a11y-label-has-associated-control/warnings.json b/test/validator/samples/a11y-label-has-associated-control/warnings.json index b70a1a47de..f618e16973 100644 --- a/test/validator/samples/a11y-label-has-associated-control/warnings.json +++ b/test/validator/samples/a11y-label-has-associated-control/warnings.json @@ -1,32 +1,32 @@ [ - { - "code": "a11y-label-has-associated-control", - "end": { - "character": 16, - "column": 16, - "line": 1 - }, - "message": "A11y: A form label must be associated with a control.", - "pos": 0, - "start": { - "character": 0, - "column": 0, - "line": 1 - } - }, - { - "code": "a11y-label-has-associated-control", - "end": { - "character": 149, - "column": 30, - "line": 6 - }, - "message": "A11y: A form label must be associated with a control.", - "pos": 119, - "start": { - "character": 119, - "column": 0, - "line": 6 - } - } + { + "code": "a11y-label-has-associated-control", + "end": { + "character": 82, + "column": 16, + "line": 5 + }, + "message": "A11y: A form label must be associated with a control.", + "pos": 66, + "start": { + "character": 66, + "column": 0, + "line": 5 + } + }, + { + "code": "a11y-label-has-associated-control", + "end": { + "character": 215, + "column": 30, + "line": 10 + }, + "message": "A11y: A form label must be associated with a control.", + "pos": 185, + "start": { + "character": 185, + "column": 0, + "line": 10 + } + } ] diff --git a/test/validator/samples/a11y-no-abstract-roles/input.svelte b/test/validator/samples/a11y-no-abstract-roles/input.svelte new file mode 100644 index 0000000000..dbe6bd8581 --- /dev/null +++ b/test/validator/samples/a11y-no-abstract-roles/input.svelte @@ -0,0 +1,12 @@ +
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/validator/samples/a11y-no-abstract-roles/warnings.json b/test/validator/samples/a11y-no-abstract-roles/warnings.json new file mode 100644 index 0000000000..917522d7ca --- /dev/null +++ b/test/validator/samples/a11y-no-abstract-roles/warnings.json @@ -0,0 +1,182 @@ +[ + { + "code": "a11y-no-abstract-role", + "end": { + "character": 19, + "column": 19, + "line": 1 + }, + "message": "A11y: Abstract role 'command' is forbidden", + "pos": 5, + "start": { + "character": 5, + "column": 5, + "line": 1 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 43, + "column": 21, + "line": 2 + }, + "message": "A11y: Abstract role 'composite' is forbidden", + "pos": 27, + "start": { + "character": 27, + "column": 5, + "line": 2 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 63, + "column": 17, + "line": 3 + }, + "message": "A11y: Abstract role 'input' is forbidden", + "pos": 51, + "start": { + "character": 51, + "column": 5, + "line": 3 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 86, + "column": 20, + "line": 4 + }, + "message": "A11y: Abstract role 'landmark' is forbidden", + "pos": 71, + "start": { + "character": 71, + "column": 5, + "line": 4 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 106, + "column": 17, + "line": 5 + }, + "message": "A11y: Abstract role 'range' is forbidden", + "pos": 94, + "start": { + "character": 94, + "column": 5, + "line": 5 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 129, + "column": 20, + "line": 6 + }, + "message": "A11y: Abstract role 'roletype' is forbidden", + "pos": 114, + "start": { + "character": 114, + "column": 5, + "line": 6 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 151, + "column": 19, + "line": 7 + }, + "message": "A11y: Abstract role 'section' is forbidden", + "pos": 137, + "start": { + "character": 137, + "column": 5, + "line": 7 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 177, + "column": 23, + "line": 8 + }, + "message": "A11y: Abstract role 'sectionhead' is forbidden", + "pos": 159, + "start": { + "character": 159, + "column": 5, + "line": 8 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 198, + "column": 18, + "line": 9 + }, + "message": "A11y: Abstract role 'select' is forbidden", + "pos": 185, + "start": { + "character": 185, + "column": 5, + "line": 9 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 222, + "column": 21, + "line": 10 + }, + "message": "A11y: Abstract role 'structure' is forbidden", + "pos": 206, + "start": { + "character": 206, + "column": 5, + "line": 10 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 243, + "column": 18, + "line": 11 + }, + "message": "A11y: Abstract role 'widget' is forbidden", + "pos": 230, + "start": { + "character": 230, + "column": 5, + "line": 11 + } + }, + { + "code": "a11y-no-abstract-role", + "end": { + "character": 264, + "column": 18, + "line": 12 + }, + "message": "A11y: Abstract role 'window' is forbidden", + "pos": 251, + "start": { + "character": 251, + "column": 5, + "line": 12 + } + } +] diff --git a/test/validator/samples/a11y-no-interactive-element-to-noninteractive-role/input.svelte b/test/validator/samples/a11y-no-interactive-element-to-noninteractive-role/input.svelte new file mode 100644 index 0000000000..80b4fd9410 --- /dev/null +++ b/test/validator/samples/a11y-no-interactive-element-to-noninteractive-role/input.svelte @@ -0,0 +1,150 @@ + +link +link +link +link +link +link +link +link +link + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/validator/samples/logic-block-in-attribute/errors.json b/test/validator/samples/logic-block-in-attribute/errors.json new file mode 100644 index 0000000000..ebf68938e7 --- /dev/null +++ b/test/validator/samples/logic-block-in-attribute/errors.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-logic-block-placement", + "message": "{#if} logic block cannot be in attribute value", + "start": { "line": 1, "column": 12, "character": 12 }, + "end": { "line": 1, "column": 12, "character": 12 }, + "pos": 12 + } +] diff --git a/test/validator/samples/logic-block-in-attribute/input.svelte b/test/validator/samples/logic-block-in-attribute/input.svelte new file mode 100644 index 0000000000..241529527c --- /dev/null +++ b/test/validator/samples/logic-block-in-attribute/input.svelte @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/validator/samples/logic-block-in-textarea/errors.json b/test/validator/samples/logic-block-in-textarea/errors.json new file mode 100644 index 0000000000..b1d73d4903 --- /dev/null +++ b/test/validator/samples/logic-block-in-textarea/errors.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-logic-block-placement", + "message": "{#each} logic block cannot be inside \ No newline at end of file diff --git a/test/validator/samples/rest-eachblock-binding-2/input.svelte b/test/validator/samples/rest-eachblock-binding-2/input.svelte new file mode 100644 index 0000000000..d92557673b --- /dev/null +++ b/test/validator/samples/rest-eachblock-binding-2/input.svelte @@ -0,0 +1,11 @@ + + +{#each objArray as [id, ...rest] (id)} + +
+{/each} diff --git a/test/validator/samples/rest-eachblock-binding-2/warnings.json b/test/validator/samples/rest-eachblock-binding-2/warnings.json new file mode 100644 index 0000000000..921f14c619 --- /dev/null +++ b/test/validator/samples/rest-eachblock-binding-2/warnings.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-rest-eachblock-binding", + "message": "...rest operator will create a new object and binding propagation with original object will not work", + "pos": 102, + "start": { "line": 8, "column": 24, "character": 102 }, + "end": { "line": 8, "column": 31, "character": 109 } + } +] diff --git a/test/validator/samples/rest-eachblock-binding-3/input.svelte b/test/validator/samples/rest-eachblock-binding-3/input.svelte new file mode 100644 index 0000000000..b8bae0cd7f --- /dev/null +++ b/test/validator/samples/rest-eachblock-binding-3/input.svelte @@ -0,0 +1,8 @@ + + +{#each objArray as { bar: { id, ...rest } } (id)} + +
+{/each} diff --git a/test/validator/samples/rest-eachblock-binding-3/warnings.json b/test/validator/samples/rest-eachblock-binding-3/warnings.json new file mode 100644 index 0000000000..8da9d536d1 --- /dev/null +++ b/test/validator/samples/rest-eachblock-binding-3/warnings.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-rest-eachblock-binding", + "message": "...rest operator will create a new object and binding propagation with original object will not work", + "pos": 168, + "start": { "line": 5, "column": 32, "character": 168 }, + "end": { "line": 5, "column": 39, "character": 175 } + } +] diff --git a/test/validator/samples/rest-eachblock-binding/input.svelte b/test/validator/samples/rest-eachblock-binding/input.svelte new file mode 100644 index 0000000000..7b96705448 --- /dev/null +++ b/test/validator/samples/rest-eachblock-binding/input.svelte @@ -0,0 +1,8 @@ + + +{#each objArray as { id, ...rest } (id)} + +
+{/each} diff --git a/test/validator/samples/rest-eachblock-binding/warnings.json b/test/validator/samples/rest-eachblock-binding/warnings.json new file mode 100644 index 0000000000..12942ec95a --- /dev/null +++ b/test/validator/samples/rest-eachblock-binding/warnings.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-rest-eachblock-binding", + "message": "...rest operator will create a new object and binding propagation with original object will not work", + "pos": 143, + "start": { "line": 5, "column": 25, "character": 143 }, + "end": { "line": 5, "column": 32, "character": 150 } + } +] diff --git a/test/validator/samples/security-anchor-rel-noreferer-legacy/_config.js b/test/validator/samples/security-anchor-rel-noreferer-legacy/_config.js new file mode 100644 index 0000000000..52f59c8767 --- /dev/null +++ b/test/validator/samples/security-anchor-rel-noreferer-legacy/_config.js @@ -0,0 +1,3 @@ +export default { + legacy: true +}; diff --git a/test/validator/samples/security-anchor-rel-noreferer-legacy/input.svelte b/test/validator/samples/security-anchor-rel-noreferer-legacy/input.svelte new file mode 100644 index 0000000000..f5361e5cfe --- /dev/null +++ b/test/validator/samples/security-anchor-rel-noreferer-legacy/input.svelte @@ -0,0 +1,33 @@ +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +Same host (valid) +Same host (valid) +Same host (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) + +svelte website (valid) diff --git a/test/validator/samples/security-anchor-rel-noreferer-legacy/warnings.json b/test/validator/samples/security-anchor-rel-noreferer-legacy/warnings.json new file mode 100644 index 0000000000..24c10fb763 --- /dev/null +++ b/test/validator/samples/security-anchor-rel-noreferer-legacy/warnings.json @@ -0,0 +1,272 @@ +[ + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 73, + "column": 73, + "line": 1 + }, + "pos": 0, + "start": { + "character": 0, + "column": 0, + "line": 1 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 154, + "column": 80, + "line": 2 + }, + "pos": 74, + "start": { + "character": 74, + "column": 0, + "line": 2 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 243, + "column": 88, + "line": 3 + }, + "pos": 155, + "start": { + "character": 155, + "column": 0, + "line": 3 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 319, + "column": 75, + "line": 4 + }, + "pos": 244, + "start": { + "character": 244, + "column": 0, + "line": 4 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 402, + "column": 82, + "line": 5 + }, + "pos": 320, + "start": { + "character": 320, + "column": 0, + "line": 5 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 493, + "column": 90, + "line": 6 + }, + "pos": 403, + "start": { + "character": 403, + "column": 0, + "line": 6 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 561, + "column": 67, + "line": 7 + }, + "pos": 494, + "start": { + "character": 494, + "column": 0, + "line": 7 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 636, + "column": 74, + "line": 8 + }, + "pos": 562, + "start": { + "character": 562, + "column": 0, + "line": 8 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 719, + "column": 82, + "line": 9 + }, + "pos": 637, + "start": { + "character": 637, + "column": 0, + "line": 9 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 792, + "column": 72, + "line": 10 + }, + "pos": 720, + "start": { + "character": 720, + "column": 0, + "line": 10 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 872, + "column": 79, + "line": 11 + }, + "pos": 793, + "start": { + "character": 793, + "column": 0, + "line": 11 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 960, + "column": 87, + "line": 12 + }, + "pos": 873, + "start": { + "character": 873, + "column": 0, + "line": 12 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 1033, + "column": 72, + "line": 13 + }, + "pos": 961, + "start": { + "character": 961, + "column": 0, + "line": 13 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 1113, + "column": 79, + "line": 14 + }, + "pos": 1034, + "start": { + "character": 1034, + "column": 0, + "line": 14 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 1201, + "column": 87, + "line": 15 + }, + "pos": 1114, + "start": { + "character": 1114, + "column": 0, + "line": 15 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 1277, + "column": 75, + "line": 16 + }, + "pos": 1202, + "start": { + "character": 1202, + "column": 0, + "line": 16 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 1360, + "column": 82, + "line": 17 + }, + "pos": 1278, + "start": { + "character": 1278, + "column": 0, + "line": 17 + } + }, + { + "code": "security-anchor-rel-noreferrer", + "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"", + "end": { + "character": 1451, + "column": 90, + "line": 18 + }, + "pos": 1361, + "start": { + "character": 1361, + "column": 0, + "line": 18 + } + } +] diff --git a/test/validator/samples/security-anchor-rel-noreferer/input.svelte b/test/validator/samples/security-anchor-rel-noreferer/input.svelte new file mode 100644 index 0000000000..f5361e5cfe --- /dev/null +++ b/test/validator/samples/security-anchor-rel-noreferer/input.svelte @@ -0,0 +1,33 @@ +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +svelte website (invalid) +Same host (valid) +Same host (valid) +Same host (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) +svelte website (valid) + +svelte website (valid) diff --git a/test/validator/samples/security-anchor-rel-noreferer/warnings.json b/test/validator/samples/security-anchor-rel-noreferer/warnings.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/test/validator/samples/security-anchor-rel-noreferer/warnings.json @@ -0,0 +1 @@ +[] diff --git a/test/validator/samples/slot-warning-ignore/input.svelte b/test/validator/samples/slot-warning-ignore/input.svelte new file mode 100644 index 0000000000..003b5bde63 --- /dev/null +++ b/test/validator/samples/slot-warning-ignore/input.svelte @@ -0,0 +1,8 @@ + + + + +
hi!
+
diff --git a/test/validator/samples/slot-warning-ignore/warnings.json b/test/validator/samples/slot-warning-ignore/warnings.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/test/validator/samples/slot-warning-ignore/warnings.json @@ -0,0 +1 @@ +[] diff --git a/test/validator/samples/slot-warning/input.svelte b/test/validator/samples/slot-warning/input.svelte new file mode 100644 index 0000000000..3d60236edc --- /dev/null +++ b/test/validator/samples/slot-warning/input.svelte @@ -0,0 +1,7 @@ + + + +
hi!
+
diff --git a/test/validator/samples/slot-warning/warnings.json b/test/validator/samples/slot-warning/warnings.json new file mode 100644 index 0000000000..14691b4231 --- /dev/null +++ b/test/validator/samples/slot-warning/warnings.json @@ -0,0 +1,17 @@ +[ + { + "code": "a11y-click-events-have-key-events", + "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", + "start": { + "character": 78, + "column": 1, + "line": 6 + }, + "end": { + "character": 112, + "column": 35, + "line": 6 + }, + "pos": 78 + } +] diff --git a/test/validator/samples/slot-warning2/input.svelte b/test/validator/samples/slot-warning2/input.svelte new file mode 100644 index 0000000000..ab3c52d35d --- /dev/null +++ b/test/validator/samples/slot-warning2/input.svelte @@ -0,0 +1,8 @@ + + + + +
hi!
+
diff --git a/test/validator/samples/slot-warning2/warnings.json b/test/validator/samples/slot-warning2/warnings.json new file mode 100644 index 0000000000..5554c3f764 --- /dev/null +++ b/test/validator/samples/slot-warning2/warnings.json @@ -0,0 +1,17 @@ +[ + { + "code": "a11y-click-events-have-key-events", + "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", + "start": { + "character": 120, + "column": 1, + "line": 7 + }, + "end": { + "character": 154, + "column": 35, + "line": 7 + }, + "pos": 120 + } +] diff --git a/test/validator/samples/style-directive-modifiers-invalid/errors.json b/test/validator/samples/style-directive-modifiers-invalid/errors.json new file mode 100644 index 0000000000..245dfc63a8 --- /dev/null +++ b/test/validator/samples/style-directive-modifiers-invalid/errors.json @@ -0,0 +1,15 @@ +[{ + "message": "Valid modifiers for style directives are: important", + "code": "invalid-style-directive-modifier", + "start": { + "line": 1, + "column": 8, + "character": 8 + }, + "end": { + "line": 1, + "column": 29, + "character": 29 + }, + "pos": 8 +}] diff --git a/test/validator/samples/style-directive-modifiers-invalid/input.svelte b/test/validator/samples/style-directive-modifiers-invalid/input.svelte new file mode 100644 index 0000000000..5fd7b1b1b5 --- /dev/null +++ b/test/validator/samples/style-directive-modifiers-invalid/input.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/validator/samples/svelte-slot-placement-2/errors.json b/test/validator/samples/svelte-fragment-placement-2/errors.json similarity index 100% rename from test/validator/samples/svelte-slot-placement-2/errors.json rename to test/validator/samples/svelte-fragment-placement-2/errors.json diff --git a/test/validator/samples/svelte-slot-placement-2/input.svelte b/test/validator/samples/svelte-fragment-placement-2/input.svelte similarity index 100% rename from test/validator/samples/svelte-slot-placement-2/input.svelte rename to test/validator/samples/svelte-fragment-placement-2/input.svelte diff --git a/test/validator/samples/svelte-slot-placement/errors.json b/test/validator/samples/svelte-fragment-placement/errors.json similarity index 100% rename from test/validator/samples/svelte-slot-placement/errors.json rename to test/validator/samples/svelte-fragment-placement/errors.json diff --git a/test/validator/samples/svelte-slot-placement/input.svelte b/test/validator/samples/svelte-fragment-placement/input.svelte similarity index 100% rename from test/validator/samples/svelte-slot-placement/input.svelte rename to test/validator/samples/svelte-fragment-placement/input.svelte diff --git a/test/validator/samples/unreferenced-variables/input.svelte b/test/validator/samples/unreferenced-variables/input.svelte index 8c9e0b15f3..cebd861985 100644 --- a/test/validator/samples/unreferenced-variables/input.svelte +++ b/test/validator/samples/unreferenced-variables/input.svelte @@ -1,25 +1,48 @@ + + -{$q} +{$q2} diff --git a/test/validator/samples/unreferenced-variables/warnings.json b/test/validator/samples/unreferenced-variables/warnings.json index dfac58ebdb..4097ba023b 100644 --- a/test/validator/samples/unreferenced-variables/warnings.json +++ b/test/validator/samples/unreferenced-variables/warnings.json @@ -2,76 +2,76 @@ { "code": "unused-export-let", "end": { - "character": 103, - "column": 12, - "line": 8 + "character": 519, + "column": 13, + "line": 31 }, - "message": "Component has unused export property 'd'. If it is for external reference only, please consider using `export const d`", - "pos": 102, + "message": "Component has unused export property 'd2'. If it is for external reference only, please consider using `export const d2`", + "pos": 517, "start": { - "character": 102, + "character": 517, "column": 11, - "line": 8 + "line": 31 } }, { "code": "unused-export-let", "end": { - "character": 106, - "column": 15, - "line": 8 + "character": 523, + "column": 17, + "line": 31 }, - "message": "Component has unused export property 'e'. If it is for external reference only, please consider using `export const e`", - "pos": 105, + "message": "Component has unused export property 'e2'. If it is for external reference only, please consider using `export const e2`", + "pos": 521, "start": { - "character": 105, - "column": 14, - "line": 8 + "character": 521, + "column": 15, + "line": 31 } }, { "code": "unused-export-let", "end": { - "character": 130, - "column": 18, - "line": 9 + "character": 549, + "column": 19, + "line": 32 }, - "message": "Component has unused export property 'g'. If it is for external reference only, please consider using `export const g`", - "pos": 125, + "message": "Component has unused export property 'g2'. If it is for external reference only, please consider using `export const g2`", + "pos": 543, "start": { - "character": 125, + "character": 543, "column": 13, - "line": 9 + "line": 32 } }, { "code": "unused-export-let", "end": { - "character": 150, - "column": 18, - "line": 10 + "character": 570, + "column": 19, + "line": 33 }, - "message": "Component has unused export property 'h'. If it is for external reference only, please consider using `export const h`", - "pos": 145, + "message": "Component has unused export property 'h2'. If it is for external reference only, please consider using `export const h2`", + "pos": 564, "start": { - "character": 145, + "character": 564, "column": 13, - "line": 10 + "line": 33 } }, { "code": "unused-export-let", "end": { - "character": 199, - "column": 25, - "line": 12 + "character": 621, + "column": 26, + "line": 35 }, - "message": "Component has unused export property 'j'. If it is for external reference only, please consider using `export const j`", - "pos": 187, + "message": "Component has unused export property 'j2'. If it is for external reference only, please consider using `export const j2`", + "pos": 608, "start": { - "character": 187, + "character": 608, "column": 13, - "line": 12 + "line": 35 } } ]