diff --git a/.mocharc.coverage.js b/.mocharc.coverage.js deleted file mode 100644 index 91c93518ca..0000000000 --- a/.mocharc.coverage.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = Object.assign( - {}, - require('./mocharc.js'), - { - fullTrace: true, - require: [ - 'source-map-support/register' - ] - } -); diff --git a/.mocharc.js b/.mocharc.js index 6159fd937f..de41cdd353 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -3,3 +3,13 @@ module.exports = { 'test/test.js' ] }; + +// add coverage options when running 'npx c8 mocha' +if (process.env.NODE_V8_COVERAGE) { + Object.assign(module.exports, { + fullTrace: true, + require: [ + 'source-map-support/register' + ] + }); +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a9441c41..2734f9dcc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Svelte changelog +## 3.27.0 + +* Add `|nonpassive` event modifier, explicitly passing `passive: false` ([#2068](https://github.com/sveltejs/svelte/issues/2068)) +* Scope CSS selectors with `~` and `+` combinators ([#3104](https://github.com/sveltejs/svelte/issues/3104)) +* Fix keyed `{#each}` not reacting to key changing ([#5444](https://github.com/sveltejs/svelte/issues/5444)) +* Fix destructuring into store values ([#5449](https://github.com/sveltejs/svelte/issues/5449)) +* Fix erroneous `missing-declaration` warning with `use:obj.method` ([#5451](https://github.com/sveltejs/svelte/issues/5451)) + +## 3.26.0 + +* Support `use:obj.method` as actions ([#3935](https://github.com/sveltejs/svelte/issues/3935)) +* Support `_` as numeric separator ([#5407](https://github.com/sveltejs/svelte/issues/5407)) +* Fix assignments to properties on store values ([#5412](https://github.com/sveltejs/svelte/issues/5412)) +* Add special style scoping handling of `[open]` selectors on `
` elements ([#5421](https://github.com/sveltejs/svelte/issues/5421)) +* Support `import.meta` in template expressions ([#5422](https://github.com/sveltejs/svelte/issues/5422)) + +## 3.25.1 + +* Fix specificity of certain styles involving a child selector ([#4795](https://github.com/sveltejs/svelte/issues/4795)) +* Fix transitions that are parameterised with stores ([#5244](https://github.com/sveltejs/svelte/issues/5244)) +* Fix scoping of styles involving child selector and `*` ([#5370](https://github.com/sveltejs/svelte/issues/5370)) +* Fix destructuring which reassigns stores ([#5388](https://github.com/sveltejs/svelte/issues/5388)) +* Fix `{#await}`s with no `{:catch}` getting stuck unresolved if the promise rejects ([#5401](https://github.com/sveltejs/svelte/issues/5401)) + ## 3.25.0 * Use `null` rather than `undefined` for coerced bound value of `` ([#1701](https://github.com/sveltejs/svelte/issues/1701)) diff --git a/package-lock.json b/package-lock.json index 34189b3f63..3ddddec683 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.25.0", + "version": "3.27.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -315,9 +315,9 @@ "dev": true }, "acorn": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", - "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true }, "acorn-globals": { diff --git a/package.json b/package.json index 59f35dfa80..62b15efb5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.25.0", + "version": "3.27.0", "description": "Cybernetically enhanced web apps", "module": "index.mjs", "main": "index", @@ -23,10 +23,10 @@ }, "types": "types/runtime/index.d.ts", "scripts": { - "test": "mocha --config .mocharc.js", + "test": "mocha", "test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts", - "quicktest": "mocha --config .mocharc.js", - "precoverage": "c8 mocha --config .mocharc.coverage.js", + "quicktest": "mocha", + "precoverage": "c8 mocha", "coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html", "codecov": "codecov", "precodecov": "npm run coverage", @@ -68,7 +68,7 @@ "@types/node": "^8.10.53", "@typescript-eslint/eslint-plugin": "^3.0.2", "@typescript-eslint/parser": "^3.0.2", - "acorn": "^7.3.1", + "acorn": "^7.4.0", "agadoo": "^1.1.0", "c8": "^5.0.1", "code-red": "^0.1.3", diff --git a/site/content/blog/2019-04-15-setting-up-your-editor.md b/site/content/blog/2019-04-15-setting-up-your-editor.md index b80223d820..fb8287d0cb 100644 --- a/site/content/blog/2019-04-15-setting-up-your-editor.md +++ b/site/content/blog/2019-04-15-setting-up-your-editor.md @@ -30,7 +30,9 @@ To treat `*.svelte` files as HTML, open *__Edit → Config...__* and add the fol ## Vim/Neovim -To treat all `*.svelte` files as HTML, add the following line to your `init.vim`: +You can use the [coc-svelte extension](https://github.com/coc-extensions/coc-svelte) which utilises the official language-server. + +As an alternative you can treat all `*.svelte` files as HTML. Add the following line to your `init.vim`: ``` au! BufNewFile,BufRead *.svelte set ft=html @@ -50,13 +52,7 @@ To set the filetype for a single file, use a [modeline](https://vim.fandom.com/w ## Visual Studio Code -To treat `*.svelte` files as HTML, add the following lines to your `settings.json` file: - -```cson - "files.associations": { - "*.svelte": "html" - } -``` +We recommend using the official [Svelte for VS Code extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). ## JetBrains WebStorm diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 74beaa2358..10e59e8a1f 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -496,6 +496,7 @@ The following modifiers are available: * `preventDefault` — calls `event.preventDefault()` before running the handler * `stopPropagation` — calls `event.stopPropagation()`, preventing the event reaching the next element * `passive` — improves scrolling performance on touch/wheel events (Svelte will add it automatically where it's safe to do so) +* `nonpassive` — explicitly set `passive: false` * `capture` — fires the handler during the *capture* phase instead of the *bubbling* phase * `once` — remove the handler after the first time it runs * `self` — only trigger handler if event.target is the element itself diff --git a/site/content/faq/200-are-there-any-video-courses.md b/site/content/faq/200-are-there-any-video-courses.md index 1a70cdfcf5..97e0e9d808 100644 --- a/site/content/faq/200-are-there-any-video-courses.md +++ b/site/content/faq/200-are-there-any-video-courses.md @@ -6,9 +6,9 @@ Rich Harris, the creator of Svelte, taught a course: - [Frontend Masters](https://frontendmasters.com/courses/svelte/) -There are also a couple of third-party courses: +There are also a number of third-party courses: -- [Egghead](https://egghead.io/playlists/getting-started-with-svelte-3-05a8541a) -- [Udemy](https://www.udemy.com/sveltejs-the-complete-guide/) +- [Egghead](https://egghead.io/browse/frameworks/svelte) +- [Udemy](https://www.udemy.com/courses/search/?q=sveltejs+svelte) Note that Udemy very frequently has discounts over 90%. diff --git a/site/content/faq/250-are-there-any-books.md b/site/content/faq/250-are-there-any-books.md new file mode 100644 index 0000000000..80870428ec --- /dev/null +++ b/site/content/faq/250-are-there-any-books.md @@ -0,0 +1,9 @@ +--- +question: Are there any books? +--- + +There are a few books: + +- [Svelte Handbook](https://flaviocopes.com/page/download-svelte-handbook/) by Flavio Copes +- [Svelte 3 Up and Running](https://www.amazon.com/dp/B08D6T6BKS/) by Alessandro Segala +- [Svelte and Sapper in Action](https://www.manning.com/books/svelte-and-sapper-in-action) by R. Mark Volkmann diff --git a/site/content/tutorial/01-introduction/07-making-an-app/text.md b/site/content/tutorial/01-introduction/07-making-an-app/text.md index 4d044272b5..d75a9a626c 100644 --- a/site/content/tutorial/01-introduction/07-making-an-app/text.md +++ b/site/content/tutorial/01-introduction/07-making-an-app/text.md @@ -13,7 +13,7 @@ First, you'll need to integrate Svelte with a build tool. There are officially m Don't worry if you're relatively new to web development and haven't used these tools before. We've prepared a simple step-by-step guide, [Svelte for new developers](blog/svelte-for-new-developers), which walks you through the process. -You'll also want to configure your text editor to treat `.svelte` files the same as `.html` for the sake of syntax highlighting. [Read this guide to learn how](blog/setting-up-your-editor). +You'll also want to configure your text editor. If you're using VS Code, install the [Svelte extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), otherwise follow [this guide](blog/setting-up-your-editor) to configure your text editor to treat `.svelte` files the same as `.html` for the sake of syntax highlighting. Then, once you've got your project set up, using Svelte components is easy. The compiler turns each component into a regular JavaScript class — just import it and instantiate with `new`: diff --git a/site/content/tutorial/05-events/03-event-modifiers/text.md b/site/content/tutorial/05-events/03-event-modifiers/text.md index 41154cafcd..2b2d6e6b31 100644 --- a/site/content/tutorial/05-events/03-event-modifiers/text.md +++ b/site/content/tutorial/05-events/03-event-modifiers/text.md @@ -21,6 +21,7 @@ The full list of modifiers: * `preventDefault` — calls `event.preventDefault()` before running the handler. Useful for client-side form handling, for example. * `stopPropagation` — calls `event.stopPropagation()`, preventing the event reaching the next element * `passive` — improves scrolling performance on touch/wheel events (Svelte will add it automatically where it's safe to do so) +* `nonpassive` — explicitly set `passive: false` * `capture` — fires the handler during the *capture* phase instead of the *bubbling* phase ([MDN docs](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture)) * `once` — remove the handler after the first time it runs * `self` — only trigger handler if event.target is the element itself diff --git a/site/src/routes/_layout.svelte b/site/src/routes/_layout.svelte index 07445de0a0..55f4861880 100644 --- a/site/src/routes/_layout.svelte +++ b/site/src/routes/_layout.svelte @@ -62,7 +62,6 @@ diff --git a/test/css/samples/child-combinator/expected.css b/test/css/samples/child-combinator/expected.css new file mode 100644 index 0000000000..5d50ae16d7 --- /dev/null +++ b/test/css/samples/child-combinator/expected.css @@ -0,0 +1 @@ +main.svelte-xyz button.svelte-xyz.svelte-xyz{background-color:red}main.svelte-xyz div.svelte-xyz>button.svelte-xyz{background-color:blue} \ No newline at end of file diff --git a/test/css/samples/child-combinator/input.svelte b/test/css/samples/child-combinator/input.svelte new file mode 100644 index 0000000000..9d5d8d27e0 --- /dev/null +++ b/test/css/samples/child-combinator/input.svelte @@ -0,0 +1,14 @@ + +
+
+ +
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-await-not-exhaustive/_config.js b/test/css/samples/general-siblings-combinator-await-not-exhaustive/_config.js new file mode 100644 index 0000000000..c81f1a9f82 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await-not-exhaustive/_config.js @@ -0,0 +1,3 @@ +export default { + warnings: [] +}; diff --git a/test/css/samples/general-siblings-combinator-await-not-exhaustive/expected.css b/test/css/samples/general-siblings-combinator-await-not-exhaustive/expected.css new file mode 100644 index 0000000000..54eefc6088 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await-not-exhaustive/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.b.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.e.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.f.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.g.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.h.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz~.e.svelte-xyz~.f.svelte-xyz~.h.svelte-xyz{color:green}.b.svelte-xyz~.d.svelte-xyz~.h.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.g.svelte-xyz.svelte-xyz.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-await-not-exhaustive/expected.html b/test/css/samples/general-siblings-combinator-await-not-exhaustive/expected.html new file mode 100644 index 0000000000..de97b02a5e --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await-not-exhaustive/expected.html @@ -0,0 +1,4 @@ +
+
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-await-not-exhaustive/input.svelte b/test/css/samples/general-siblings-combinator-await-not-exhaustive/input.svelte new file mode 100644 index 0000000000..a677077c33 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await-not-exhaustive/input.svelte @@ -0,0 +1,41 @@ + + + + +
+ +{#await promise then value} +
+{:catch error} +
+{/await} + +{#await promise} +
+{:catch error} +
+{/await} + +{#await promise} +
+{:then error} +
+{/await} + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-await/_config.js b/test/css/samples/general-siblings-combinator-await/_config.js new file mode 100644 index 0000000000..b4ebe41828 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await/_config.js @@ -0,0 +1,46 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 13: + 14: /* no match */ + 15: .b ~ .c { color: green; } + ^ + 16: .c ~ .d { color: green; } + 17: .b ~ .d { color: green; }`, + message: 'Unused CSS selector ".b ~ .c"', + pos: 269, + start: { character: 269, column: 1, line: 15 }, + end: { character: 276, column: 8, line: 15 } + }, + { + code: "css-unused-selector", + frame: ` + 14: /* no match */ + 15: .b ~ .c { color: green; } + 16: .c ~ .d { color: green; } + ^ + 17: .b ~ .d { color: green; } + 18: `, + message: 'Unused CSS selector ".c ~ .d"', + pos: 296, + start: { character: 296, column: 1, line: 16 }, + end: { character: 303, column: 8, line: 16 } + }, + { + code: "css-unused-selector", + frame: ` + 15: .b ~ .c { color: green; } + 16: .c ~ .d { color: green; } + 17: .b ~ .d { color: green; } + ^ + 18: + 19:`, + message: 'Unused CSS selector ".b ~ .d"', + pos: 323, + start: { character: 323, column: 1, line: 17 }, + end: { character: 330, column: 8, line: 17 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-await/expected.css b/test/css/samples/general-siblings-combinator-await/expected.css new file mode 100644 index 0000000000..94a5494597 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.b.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz{color:green}.a.svelte-xyz~.d.svelte-xyz{color:green}.b.svelte-xyz~.e.svelte-xyz{color:green}.c.svelte-xyz~.e.svelte-xyz{color:green}.d.svelte-xyz~.e.svelte-xyz{color:green}.a.svelte-xyz~.e.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-await/expected.html b/test/css/samples/general-siblings-combinator-await/expected.html new file mode 100644 index 0000000000..3d8ac9f966 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-await/input.svelte b/test/css/samples/general-siblings-combinator-await/input.svelte new file mode 100644 index 0000000000..8aeadab170 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-await/input.svelte @@ -0,0 +1,30 @@ + + + + +
+ +{#await promise} +
+{:then value} +
+{:catch error} +
+{/await} + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-2/_config.js b/test/css/samples/general-siblings-combinator-each-2/_config.js new file mode 100644 index 0000000000..c81f1a9f82 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-2/_config.js @@ -0,0 +1,3 @@ +export default { + warnings: [] +}; diff --git a/test/css/samples/general-siblings-combinator-each-2/expected.css b/test/css/samples/general-siblings-combinator-each-2/expected.css new file mode 100644 index 0000000000..d197058b24 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-2/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.b.svelte-xyz{color:green}.c.svelte-xyz~.d.svelte-xyz{color:green}.a.svelte-xyz~.d.svelte-xyz{color:green}.c.svelte-xyz~.b.svelte-xyz{color:green}.b.svelte-xyz~.c.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-2/expected.html b/test/css/samples/general-siblings-combinator-each-2/expected.html new file mode 100644 index 0000000000..331a5e4317 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-2/expected.html @@ -0,0 +1,4 @@ +
+
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-2/input.svelte b/test/css/samples/general-siblings-combinator-each-2/input.svelte new file mode 100644 index 0000000000..5bbdbdef66 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-2/input.svelte @@ -0,0 +1,37 @@ + + + + +
+ +{#each array as item} +
+
+{/each} + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-else-nested/_config.js b/test/css/samples/general-siblings-combinator-each-else-nested/_config.js new file mode 100644 index 0000000000..cf241d856d --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else-nested/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 33: + 34: /* no match */ + 35: .e ~ .f { color: green; } + ^ + 36: + 37:`, + message: 'Unused CSS selector ".e ~ .f"', + pos: 812, + start: { character: 812, column: 1, line: 35 }, + end: { character: 819, column: 8, line: 35 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-each-else-nested/expected.css b/test/css/samples/general-siblings-combinator-each-else-nested/expected.css new file mode 100644 index 0000000000..b055f35ecd --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else-nested/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.e.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.f.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz~.c.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.e.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.f.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz~.e.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz~.f.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz~.e.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz~.j.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.h.svelte-xyz~.j.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.i.svelte-xyz~.j.svelte-xyz.svelte-xyz{color:green}.m.svelte-xyz~.m.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.m.svelte-xyz~.l.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz~.m.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.g.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz~.e.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.g.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.k.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.g.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.h.svelte-xyz~.h.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz~.i.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.j.svelte-xyz~.j.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.j.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.h.svelte-xyz~.i.svelte-xyz~.j.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-else-nested/expected.html b/test/css/samples/general-siblings-combinator-each-else-nested/expected.html new file mode 100644 index 0000000000..67dd05f677 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else-nested/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-else-nested/input.svelte b/test/css/samples/general-siblings-combinator-each-else-nested/input.svelte new file mode 100644 index 0000000000..63a1123708 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else-nested/input.svelte @@ -0,0 +1,77 @@ + + + + +
+ +{#each array as a} +
+ {#each array as b} +
+ {:else} +
+ {/each} +{/each} + +{#each array as c} + {#each array as d} +
+ {/each} +{:else} +
+{/each} + +{#each array as x} +
+ {#each array as y} + {#each array as z} +
+ {/each} + {:else} +
+ {/each} +
+{/each} + +
+ +{#each array as item} + {#each array as item} +
+ {:else} +
+ {/each} +{/each} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-else/_config.js b/test/css/samples/general-siblings-combinator-each-else/_config.js new file mode 100644 index 0000000000..4d9beceeb2 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 11: + 12: /* no match */ + 13: .b ~ .c { color: green; } + ^ + 14: + 15:`, + message: 'Unused CSS selector ".b ~ .c"', + pos: 199, + start: { character: 199, column: 1, line: 13 }, + end: { character: 206, column: 8, line: 13 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-each-else/expected.css b/test/css/samples/general-siblings-combinator-each-else/expected.css new file mode 100644 index 0000000000..31fafa3243 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.b.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz{color:green}.b.svelte-xyz~.d.svelte-xyz{color:green}.c.svelte-xyz~.d.svelte-xyz{color:green}.a.svelte-xyz~.d.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-else/expected.html b/test/css/samples/general-siblings-combinator-each-else/expected.html new file mode 100644 index 0000000000..fb838a55fd --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-else/input.svelte b/test/css/samples/general-siblings-combinator-each-else/input.svelte new file mode 100644 index 0000000000..5cd78853ca --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-else/input.svelte @@ -0,0 +1,24 @@ + + + + +
+ +{#each array as item} +
+{:else} +
+{/each} + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-nested/_config.js b/test/css/samples/general-siblings-combinator-each-nested/_config.js new file mode 100644 index 0000000000..c81f1a9f82 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-nested/_config.js @@ -0,0 +1,3 @@ +export default { + warnings: [] +}; diff --git a/test/css/samples/general-siblings-combinator-each-nested/expected.css b/test/css/samples/general-siblings-combinator-each-nested/expected.css new file mode 100644 index 0000000000..5bf1f832ae --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-nested/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.d.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.e.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.f.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.g.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.d.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.e.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.f.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.g.svelte-xyz.svelte-xyz{color:green}.j.svelte-xyz~.m.svelte-xyz.svelte-xyz{color:green}.j.svelte-xyz~.n.svelte-xyz.svelte-xyz{color:green}.j.svelte-xyz~.o.svelte-xyz.svelte-xyz{color:green}.k.svelte-xyz~.m.svelte-xyz.svelte-xyz{color:green}.k.svelte-xyz~.n.svelte-xyz.svelte-xyz{color:green}.k.svelte-xyz~.o.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz~.m.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz~.n.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz~.o.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz~.e.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz~.f.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.h.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz~.d.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz~.e.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz~.f.svelte-xyz.svelte-xyz{color:green}.h.svelte-xyz~.g.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz~.h.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz~.g.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz~.d.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz~.e.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz~.f.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.g.svelte-xyz.svelte-xyz{color:green}.h.svelte-xyz~.h.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz~.i.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz~.e.svelte-xyz~.f.svelte-xyz{color:green}.e.svelte-xyz~.e.svelte-xyz~.d.svelte-xyz{color:green}.h.svelte-xyz~.h.svelte-xyz~.i.svelte-xyz{color:green}.h.svelte-xyz~.h.svelte-xyz~.g.svelte-xyz{color:green}.a.svelte-xyz~.h.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.i.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.h.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.i.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz~.f.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz~.g.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz~.g.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz~.i.svelte-xyz.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-nested/expected.html b/test/css/samples/general-siblings-combinator-each-nested/expected.html new file mode 100644 index 0000000000..340d6fc4c8 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-nested/expected.html @@ -0,0 +1,15 @@ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each-nested/input.svelte b/test/css/samples/general-siblings-combinator-each-nested/input.svelte new file mode 100644 index 0000000000..b7c7377015 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each-nested/input.svelte @@ -0,0 +1,113 @@ + + + + +
+ +{#each array as item} +
+
+{/each} + +{#each array as item} + {#each array as item} + {#each array as item} +
+ {/each} +
+ {/each} +
+{/each} + +{#each array as item} +
+ {#each array as item} +
+ {#each array as item} +
+ {/each} + {/each} +{/each} + +{#each array as item} +
+ {#each array as item} +
+ {#each array as item} +
+ {/each} + {/each} +{/each} + +{#each array as item} + {#each array as item} + {#each array as item} +
+ {/each} +
+ {/each} +
+{/each} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each/expected.css b/test/css/samples/general-siblings-combinator-each/expected.css new file mode 100644 index 0000000000..8c48251bdd --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each/expected.css @@ -0,0 +1 @@ +div.svelte-xyz~span.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-each/expected.html b/test/css/samples/general-siblings-combinator-each/expected.html new file mode 100644 index 0000000000..9d0416f01b --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each/expected.html @@ -0,0 +1,6 @@ +
+ +
+ +
+ diff --git a/test/css/samples/general-siblings-combinator-each/input.svelte b/test/css/samples/general-siblings-combinator-each/input.svelte new file mode 100644 index 0000000000..ce65da109d --- /dev/null +++ b/test/css/samples/general-siblings-combinator-each/input.svelte @@ -0,0 +1,20 @@ + + + + +
+ +{#each array as item} + +
+ +
+{/each} + + \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/_config.js b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/_config.js new file mode 100644 index 0000000000..0b5d391f50 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 16: + 17: /* no match */ + 18: .b ~ .c { color: green; } + ^ + 19: + 20:`, + message: 'Unused CSS selector ".b ~ .c"', + pos: 319, + start: { character: 319, column: 1, line: 18 }, + end: { character: 326, column: 8, line: 18 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/expected.css b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/expected.css new file mode 100644 index 0000000000..e6a974efca --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.b.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz~.c.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz~.c.svelte-xyz~.d.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz~.c.svelte-xyz~.d.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/expected.html b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/expected.html new file mode 100644 index 0000000000..fb838a55fd --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/input.svelte b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/input.svelte new file mode 100644 index 0000000000..2b53f7b5b8 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive-with-each/input.svelte @@ -0,0 +1,31 @@ + + + + +
+ +{#if foo} +
+{:else} + {#each array as item} +
+ {/each} +{/if} + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive/_config.js b/test/css/samples/general-siblings-combinator-if-not-exhaustive/_config.js new file mode 100644 index 0000000000..81fb595d68 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 12: + 13: /* no match */ + 14: .b ~ .c { color: green; } + ^ + 15: + 16:`, + message: 'Unused CSS selector ".b ~ .c"', + pos: 215, + start: { character: 215, column: 1, line: 14 }, + end: { character: 222, column: 8, line: 14 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive/expected.css b/test/css/samples/general-siblings-combinator-if-not-exhaustive/expected.css new file mode 100644 index 0000000000..dc7ee1b62b --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.b.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz{color:green}.a.svelte-xyz~.d.svelte-xyz{color:green}.b.svelte-xyz~.d.svelte-xyz{color:green}.c.svelte-xyz~.d.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive/expected.html b/test/css/samples/general-siblings-combinator-if-not-exhaustive/expected.html new file mode 100644 index 0000000000..813e778dc6 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if-not-exhaustive/input.svelte b/test/css/samples/general-siblings-combinator-if-not-exhaustive/input.svelte new file mode 100644 index 0000000000..3e5c5af7a2 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if-not-exhaustive/input.svelte @@ -0,0 +1,25 @@ + + + + +
+ +{#if foo} +
+{:else if bar} +
+{/if} + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if/_config.js b/test/css/samples/general-siblings-combinator-if/_config.js new file mode 100644 index 0000000000..cbc3d8a784 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if/_config.js @@ -0,0 +1,46 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 14: + 15: /* no match */ + 16: .b ~ .c { color: green; } + ^ + 17: .b ~ .d { color: green; } + 18: .c ~ .d { color: green; }`, + message: 'Unused CSS selector ".b ~ .c"', + pos: 269, + start: { character: 269, column: 1, line: 16 }, + end: { character: 276, column: 8, line: 16 } + }, + { + code: "css-unused-selector", + frame: ` + 15: /* no match */ + 16: .b ~ .c { color: green; } + 17: .b ~ .d { color: green; } + ^ + 18: .c ~ .d { color: green; } + 19: `, + message: 'Unused CSS selector ".b ~ .d"', + pos: 296, + start: { character: 296, column: 1, line: 17 }, + end: { character: 303, column: 8, line: 17 } + }, + { + code: "css-unused-selector", + frame: ` + 16: .b ~ .c { color: green; } + 17: .b ~ .d { color: green; } + 18: .c ~ .d { color: green; } + ^ + 19: + 20:`, + message: 'Unused CSS selector ".c ~ .d"', + pos: 323, + start: { character: 323, column: 1, line: 18 }, + end: { character: 330, column: 8, line: 18 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-if/expected.css b/test/css/samples/general-siblings-combinator-if/expected.css new file mode 100644 index 0000000000..94a5494597 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz~.b.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz{color:green}.a.svelte-xyz~.d.svelte-xyz{color:green}.b.svelte-xyz~.e.svelte-xyz{color:green}.c.svelte-xyz~.e.svelte-xyz{color:green}.d.svelte-xyz~.e.svelte-xyz{color:green}.a.svelte-xyz~.e.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if/expected.html b/test/css/samples/general-siblings-combinator-if/expected.html new file mode 100644 index 0000000000..3d8ac9f966 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-if/input.svelte b/test/css/samples/general-siblings-combinator-if/input.svelte new file mode 100644 index 0000000000..fca5499f2e --- /dev/null +++ b/test/css/samples/general-siblings-combinator-if/input.svelte @@ -0,0 +1,31 @@ + + + + +
+ +{#if foo} +
+{:else if bar} +
+{:else} +
+{/if} + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-slot/_config.js b/test/css/samples/general-siblings-combinator-slot/_config.js new file mode 100644 index 0000000000..4cf743c0a0 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-slot/_config.js @@ -0,0 +1,88 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 8: + 9: /* no match */ + 10: .a ~ .b { color: green; } + ^ + 11: .b ~ .c { color: green; } + 12: .c ~ .f { color: green; }`, + message: 'Unused CSS selector ".a ~ .b"', + pos: 111, + start: { character: 111, column: 1, line: 10 }, + end: { character: 118, column: 8, line: 10 } + }, + { + code: "css-unused-selector", + frame: ` + 9: /* no match */ + 10: .a ~ .b { color: green; } + 11: .b ~ .c { color: green; } + ^ + 12: .c ~ .f { color: green; } + 13: .f ~ .g { color: green; }`, + message: 'Unused CSS selector ".b ~ .c"', + pos: 138, + start: { character: 138, column: 1, line: 11 }, + end: { character: 145, column: 8, line: 11 } + }, + { + code: "css-unused-selector", + frame: ` + 10: .a ~ .b { color: green; } + 11: .b ~ .c { color: green; } + 12: .c ~ .f { color: green; } + ^ + 13: .f ~ .g { color: green; } + 14: .b ~ .f { color: green; }`, + message: 'Unused CSS selector ".c ~ .f"', + pos: 165, + start: { character: 165, column: 1, line: 12 }, + end: { character: 172, column: 8, line: 12 } + }, + { + code: "css-unused-selector", + frame: ` + 11: .b ~ .c { color: green; } + 12: .c ~ .f { color: green; } + 13: .f ~ .g { color: green; } + ^ + 14: .b ~ .f { color: green; } + 15: .b ~ .g { color: green; }`, + message: 'Unused CSS selector ".f ~ .g"', + pos: 192, + start: { character: 192, column: 1, line: 13 }, + end: { character: 199, column: 8, line: 13 } + }, + { + code: "css-unused-selector", + frame: ` + 12: .c ~ .f { color: green; } + 13: .f ~ .g { color: green; } + 14: .b ~ .f { color: green; } + ^ + 15: .b ~ .g { color: green; } + 16: `, + message: 'Unused CSS selector ".b ~ .f"', + pos: 219, + start: { character: 219, column: 1, line: 14 }, + end: { character: 226, column: 8, line: 14 } + }, + { + code: "css-unused-selector", + frame: ` + 13: .f ~ .g { color: green; } + 14: .b ~ .f { color: green; } + 15: .b ~ .g { color: green; } + ^ + 16: + 17:`, + message: 'Unused CSS selector ".b ~ .g"', + pos: 246, + start: { character: 246, column: 1, line: 15 }, + end: { character: 253, column: 8, line: 15 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-slot/expected.css b/test/css/samples/general-siblings-combinator-slot/expected.css new file mode 100644 index 0000000000..29325e0cef --- /dev/null +++ b/test/css/samples/general-siblings-combinator-slot/expected.css @@ -0,0 +1 @@ +.d.svelte-xyz~.e.svelte-xyz{color:green}.a.svelte-xyz~.g.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-slot/input.svelte b/test/css/samples/general-siblings-combinator-slot/input.svelte new file mode 100644 index 0000000000..e5af4c0962 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-slot/input.svelte @@ -0,0 +1,30 @@ + + + + +
+ +
+ +
+
+
+
+ +
+ + +
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-star/_config.js b/test/css/samples/general-siblings-combinator-star/_config.js new file mode 100644 index 0000000000..64e5baad19 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-star/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 3: margin-left: 4px; + 4: } + 5: .not-match > * ~ * { + ^ + 6: margin-left: 4px; + 7: }`, + message: 'Unused CSS selector ".not-match > * ~ *"', + pos: 50, + start: { character: 50, column: 1, line: 5 }, + end: { character: 68, column: 19, line: 5 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator-star/expected.css b/test/css/samples/general-siblings-combinator-star/expected.css new file mode 100644 index 0000000000..de947fa47e --- /dev/null +++ b/test/css/samples/general-siblings-combinator-star/expected.css @@ -0,0 +1 @@ +.match.svelte-xyz>.svelte-xyz~.svelte-xyz{margin-left:4px} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-star/expected.html b/test/css/samples/general-siblings-combinator-star/expected.html new file mode 100644 index 0000000000..1cfae6e6f7 --- /dev/null +++ b/test/css/samples/general-siblings-combinator-star/expected.html @@ -0,0 +1,7 @@ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator-star/input.svelte b/test/css/samples/general-siblings-combinator-star/input.svelte new file mode 100644 index 0000000000..a069685d4f --- /dev/null +++ b/test/css/samples/general-siblings-combinator-star/input.svelte @@ -0,0 +1,17 @@ + + +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator/_config.js b/test/css/samples/general-siblings-combinator/_config.js new file mode 100644 index 0000000000..6513366549 --- /dev/null +++ b/test/css/samples/general-siblings-combinator/_config.js @@ -0,0 +1,60 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 10: + 11: /* no match */ + 12: article ~ div { color: green; } + ^ + 13: span ~ article { color: green; } + 14: b ~ article { color: green; }`, + message: 'Unused CSS selector "article ~ div"', + pos: 275, + start: { character: 275, column: 1, line: 12 }, + end: { character: 288, column: 14, line: 12 } + }, + { + code: "css-unused-selector", + frame: ` + 11: /* no match */ + 12: article ~ div { color: green; } + 13: span ~ article { color: green; } + ^ + 14: b ~ article { color: green; } + 15: span ~ div { color: green; }`, + message: 'Unused CSS selector "span ~ article"', + pos: 308, + start: { character: 308, column: 1, line: 13 }, + end: { character: 322, column: 15, line: 13 } + }, + { + code: "css-unused-selector", + frame: ` + 12: article ~ div { color: green; } + 13: span ~ article { color: green; } + 14: b ~ article { color: green; } + ^ + 15: span ~ div { color: green; } + 16: `, + message: 'Unused CSS selector "b ~ article"', + pos: 342, + start: { character: 342, column: 1, line: 14 }, + end: { character: 353, column: 12, line: 14 } + }, + { + code: "css-unused-selector", + frame: ` + 13: span ~ article { color: green; } + 14: b ~ article { color: green; } + 15: span ~ div { color: green; } + ^ + 16: + 17:`, + message: 'Unused CSS selector "span ~ div"', + pos: 373, + start: { character: 373, column: 1, line: 15 }, + end: { character: 383, column: 11, line: 15 } + } + ] +}; diff --git a/test/css/samples/general-siblings-combinator/expected.css b/test/css/samples/general-siblings-combinator/expected.css new file mode 100644 index 0000000000..647a53f778 --- /dev/null +++ b/test/css/samples/general-siblings-combinator/expected.css @@ -0,0 +1 @@ +div.svelte-xyz~article.svelte-xyz.svelte-xyz{color:green}span.svelte-xyz~b.svelte-xyz.svelte-xyz{color:green}div.svelte-xyz span.svelte-xyz~b.svelte-xyz{color:green}.a.svelte-xyz~article.svelte-xyz.svelte-xyz{color:green}div.svelte-xyz~.b.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~.c.svelte-xyz.svelte-xyz{color:green}article.svelte-xyz~details.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz~details.svelte-xyz.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator/expected.html b/test/css/samples/general-siblings-combinator/expected.html new file mode 100644 index 0000000000..01fbffcae4 --- /dev/null +++ b/test/css/samples/general-siblings-combinator/expected.html @@ -0,0 +1,7 @@ +
+ + +
+
+

+
\ No newline at end of file diff --git a/test/css/samples/general-siblings-combinator/input.svelte b/test/css/samples/general-siblings-combinator/input.svelte new file mode 100644 index 0000000000..533702a3a3 --- /dev/null +++ b/test/css/samples/general-siblings-combinator/input.svelte @@ -0,0 +1,24 @@ + + +
+ + +
+
+

+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-await-not-exhaustive/_config.js b/test/css/samples/siblings-combinator-await-not-exhaustive/_config.js new file mode 100644 index 0000000000..c81f1a9f82 --- /dev/null +++ b/test/css/samples/siblings-combinator-await-not-exhaustive/_config.js @@ -0,0 +1,3 @@ +export default { + warnings: [] +}; diff --git a/test/css/samples/siblings-combinator-await-not-exhaustive/expected.css b/test/css/samples/siblings-combinator-await-not-exhaustive/expected.css new file mode 100644 index 0000000000..60bb8e92dc --- /dev/null +++ b/test/css/samples/siblings-combinator-await-not-exhaustive/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.b.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.e.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.f.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.g.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.h.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz+.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz+.e.svelte-xyz+.f.svelte-xyz+.h.svelte-xyz{color:green}.b.svelte-xyz+.d.svelte-xyz+.h.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.g.svelte-xyz.svelte-xyz.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-await-not-exhaustive/expected.html b/test/css/samples/siblings-combinator-await-not-exhaustive/expected.html new file mode 100644 index 0000000000..de97b02a5e --- /dev/null +++ b/test/css/samples/siblings-combinator-await-not-exhaustive/expected.html @@ -0,0 +1,4 @@ +
+
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-await-not-exhaustive/input.svelte b/test/css/samples/siblings-combinator-await-not-exhaustive/input.svelte new file mode 100644 index 0000000000..d3345c6edc --- /dev/null +++ b/test/css/samples/siblings-combinator-await-not-exhaustive/input.svelte @@ -0,0 +1,41 @@ + + + + +
+ +{#await promise then value} +
+{:catch error} +
+{/await} + +{#await promise} +
+{:catch error} +
+{/await} + +{#await promise} +
+{:then error} +
+{/await} + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-await/_config.js b/test/css/samples/siblings-combinator-await/_config.js new file mode 100644 index 0000000000..5af12d38e5 --- /dev/null +++ b/test/css/samples/siblings-combinator-await/_config.js @@ -0,0 +1,60 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 12: + 13: /* no match */ + 14: .a + .e { color: green; } + ^ + 15: .b + .c { color: green; } + 16: .c + .d { color: green; }`, + message: 'Unused CSS selector ".a + .e"', + pos: 242, + start: { character: 242, column: 1, line: 14 }, + end: { character: 249, column: 8, line: 14 } + }, + { + code: "css-unused-selector", + frame: ` + 13: /* no match */ + 14: .a + .e { color: green; } + 15: .b + .c { color: green; } + ^ + 16: .c + .d { color: green; } + 17: .b + .d { color: green; }`, + message: 'Unused CSS selector ".b + .c"', + pos: 269, + start: { character: 269, column: 1, line: 15 }, + end: { character: 276, column: 8, line: 15 } + }, + { + code: "css-unused-selector", + frame: ` + 14: .a + .e { color: green; } + 15: .b + .c { color: green; } + 16: .c + .d { color: green; } + ^ + 17: .b + .d { color: green; } + 18: `, + message: 'Unused CSS selector ".c + .d"', + pos: 296, + start: { character: 296, column: 1, line: 16 }, + end: { character: 303, column: 8, line: 16 } + }, + { + code: "css-unused-selector", + frame: ` + 15: .b + .c { color: green; } + 16: .c + .d { color: green; } + 17: .b + .d { color: green; } + ^ + 18: + 19:`, + message: 'Unused CSS selector ".b + .d"', + pos: 323, + start: { character: 323, column: 1, line: 17 }, + end: { character: 330, column: 8, line: 17 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-await/expected.css b/test/css/samples/siblings-combinator-await/expected.css new file mode 100644 index 0000000000..5ea39be7c2 --- /dev/null +++ b/test/css/samples/siblings-combinator-await/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.b.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz{color:green}.a.svelte-xyz+.d.svelte-xyz{color:green}.b.svelte-xyz+.e.svelte-xyz{color:green}.c.svelte-xyz+.e.svelte-xyz{color:green}.d.svelte-xyz+.e.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-await/expected.html b/test/css/samples/siblings-combinator-await/expected.html new file mode 100644 index 0000000000..3d8ac9f966 --- /dev/null +++ b/test/css/samples/siblings-combinator-await/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-await/input.svelte b/test/css/samples/siblings-combinator-await/input.svelte new file mode 100644 index 0000000000..07698c2a30 --- /dev/null +++ b/test/css/samples/siblings-combinator-await/input.svelte @@ -0,0 +1,30 @@ + + + + +
+ +{#await promise} +
+{:then value} +
+{:catch error} +
+{/await} + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-2/_config.js b/test/css/samples/siblings-combinator-each-2/_config.js new file mode 100644 index 0000000000..e4799f1055 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-2/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 24: } + 25: /* not match */ + 26: .a + .c { + ^ + 27: color: green; + 28: }`, + message: 'Unused CSS selector ".a + .c"', + pos: 320, + start: { character: 320, column: 1, line: 26 }, + end: { character: 327, column: 8, line: 26 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-each-2/expected.css b/test/css/samples/siblings-combinator-each-2/expected.css new file mode 100644 index 0000000000..60fa224269 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-2/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.b.svelte-xyz{color:green}.c.svelte-xyz+.d.svelte-xyz{color:green}.a.svelte-xyz+.d.svelte-xyz{color:green}.c.svelte-xyz+.b.svelte-xyz{color:green}.b.svelte-xyz+.c.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-2/expected.html b/test/css/samples/siblings-combinator-each-2/expected.html new file mode 100644 index 0000000000..331a5e4317 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-2/expected.html @@ -0,0 +1,4 @@ +
+
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-2/input.svelte b/test/css/samples/siblings-combinator-each-2/input.svelte new file mode 100644 index 0000000000..bbad045fbc --- /dev/null +++ b/test/css/samples/siblings-combinator-each-2/input.svelte @@ -0,0 +1,38 @@ + + + + +
+ +{#each array as item} +
+
+{/each} + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-else-nested/_config.js b/test/css/samples/siblings-combinator-each-else-nested/_config.js new file mode 100644 index 0000000000..ab3fac6abe --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else-nested/_config.js @@ -0,0 +1,144 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 21: + 22: /* no match */ + 23: .a + .c { color: green; } + ^ + 24: .a + .g { color: green; } + 25: .b + .e { color: green; }`, + message: 'Unused CSS selector ".a + .c"', + pos: 479, + start: { character: 479, column: 1, line: 23 }, + end: { character: 486, column: 8, line: 23 } + }, + { + code: "css-unused-selector", + frame: ` + 22: /* no match */ + 23: .a + .c { color: green; } + 24: .a + .g { color: green; } + ^ + 25: .b + .e { color: green; } + 26: .c + .g { color: green; }`, + message: 'Unused CSS selector ".a + .g"', + pos: 506, + start: { character: 506, column: 1, line: 24 }, + end: { character: 513, column: 8, line: 24 } + }, + { + code: "css-unused-selector", + frame: ` + 23: .a + .c { color: green; } + 24: .a + .g { color: green; } + 25: .b + .e { color: green; } + ^ + 26: .c + .g { color: green; } + 27: .c + .k { color: green; }`, + message: 'Unused CSS selector ".b + .e"', + pos: 533, + start: { character: 533, column: 1, line: 25 }, + end: { character: 540, column: 8, line: 25 } + }, + { + code: "css-unused-selector", + frame: ` + 24: .a + .g { color: green; } + 25: .b + .e { color: green; } + 26: .c + .g { color: green; } + ^ + 27: .c + .k { color: green; } + 28: .d + .d { color: green; }`, + message: 'Unused CSS selector ".c + .g"', + pos: 560, + start: { character: 560, column: 1, line: 26 }, + end: { character: 567, column: 8, line: 26 } + }, + { + code: "css-unused-selector", + frame: ` + 25: .b + .e { color: green; } + 26: .c + .g { color: green; } + 27: .c + .k { color: green; } + ^ + 28: .d + .d { color: green; } + 29: .e + .f { color: green; }`, + message: 'Unused CSS selector ".c + .k"', + pos: 587, + start: { character: 587, column: 1, line: 27 }, + end: { character: 594, column: 8, line: 27 } + }, + { + code: "css-unused-selector", + frame: ` + 26: .c + .g { color: green; } + 27: .c + .k { color: green; } + 28: .d + .d { color: green; } + ^ + 29: .e + .f { color: green; } + 30: .f + .f { color: green; }`, + message: 'Unused CSS selector ".d + .d"', + pos: 614, + start: { character: 614, column: 1, line: 28 }, + end: { character: 621, column: 8, line: 28 } + }, + { + code: "css-unused-selector", + frame: ` + 27: .c + .k { color: green; } + 28: .d + .d { color: green; } + 29: .e + .f { color: green; } + ^ + 30: .f + .f { color: green; } + 31: .g + .j { color: green; }`, + message: 'Unused CSS selector ".e + .f"', + pos: 641, + start: { character: 641, column: 1, line: 29 }, + end: { character: 648, column: 8, line: 29 } + }, + { + code: "css-unused-selector", + frame: ` + 28: .d + .d { color: green; } + 29: .e + .f { color: green; } + 30: .f + .f { color: green; } + ^ + 31: .g + .j { color: green; } + 32: .g + .h + .i + .j { color: green; }`, + message: 'Unused CSS selector ".f + .f"', + pos: 668, + start: { character: 668, column: 1, line: 30 }, + end: { character: 675, column: 8, line: 30 } + }, + { + code: "css-unused-selector", + frame: ` + 29: .e + .f { color: green; } + 30: .f + .f { color: green; } + 31: .g + .j { color: green; } + ^ + 32: .g + .h + .i + .j { color: green; } + 33: `, + message: 'Unused CSS selector ".g + .j"', + pos: 695, + start: { character: 695, column: 1, line: 31 }, + end: { character: 702, column: 8, line: 31 } + }, + { + code: "css-unused-selector", + frame: ` + 30: .f + .f { color: green; } + 31: .g + .j { color: green; } + 32: .g + .h + .i + .j { color: green; } + ^ + 33: + 34:`, + message: 'Unused CSS selector ".g + .h + .i + .j"', + pos: 722, + start: { character: 722, column: 1, line: 32 }, + end: { character: 739, column: 18, line: 32 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-each-else-nested/expected.css b/test/css/samples/siblings-combinator-each-else-nested/expected.css new file mode 100644 index 0000000000..aa4e04081d --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else-nested/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz+.c.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz+.d.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz+.j.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz+.h.svelte-xyz+.j.svelte-xyz{color:green}.g.svelte-xyz+.i.svelte-xyz+.j.svelte-xyz{color:green}.m.svelte-xyz+.m.svelte-xyz.svelte-xyz{color:green}.m.svelte-xyz+.l.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz+.m.svelte-xyz.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-else-nested/expected.html b/test/css/samples/siblings-combinator-each-else-nested/expected.html new file mode 100644 index 0000000000..5f25a2d38a --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else-nested/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-else-nested/input.svelte b/test/css/samples/siblings-combinator-each-else-nested/input.svelte new file mode 100644 index 0000000000..bee9c6b1dc --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else-nested/input.svelte @@ -0,0 +1,74 @@ + + + + +
+ +{#each array as a} +
+ {#each array as b} +
+ {:else} +
+ {/each} +{/each} + +{#each array as c} + {#each array as d} +
+ {/each} +{:else} +
+{/each} + +{#each array as item} +
+ {#each array as item} + {#each array as item} +
+ {/each} + {:else} +
+ {/each} +
+{/each} + +
+ +{#each array as item} + {#each array as item} +
+ {:else} +
+ {/each} +{/each} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-else/_config.js b/test/css/samples/siblings-combinator-each-else/_config.js new file mode 100644 index 0000000000..fcd961d5fe --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else/_config.js @@ -0,0 +1,32 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 10: + 11: /* no match */ + 12: .a + .d { color: green; } + ^ + 13: .b + .c { color: green; } + 14: `, + message: 'Unused CSS selector ".a + .d"', + pos: 172, + start: { character: 172, column: 1, line: 12 }, + end: { character: 179, column: 8, line: 12 } + }, + { + code: "css-unused-selector", + frame: ` + 11: /* no match */ + 12: .a + .d { color: green; } + 13: .b + .c { color: green; } + ^ + 14: + 15:`, + message: 'Unused CSS selector ".b + .c"', + pos: 199, + start: { character: 199, column: 1, line: 13 }, + end: { character: 206, column: 8, line: 13 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-each-else/expected.css b/test/css/samples/siblings-combinator-each-else/expected.css new file mode 100644 index 0000000000..f82bca8215 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.b.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz{color:green}.b.svelte-xyz+.d.svelte-xyz{color:green}.c.svelte-xyz+.d.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-else/expected.html b/test/css/samples/siblings-combinator-each-else/expected.html new file mode 100644 index 0000000000..fb838a55fd --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-else/input.svelte b/test/css/samples/siblings-combinator-each-else/input.svelte new file mode 100644 index 0000000000..ecd48968c2 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-else/input.svelte @@ -0,0 +1,24 @@ + + + + +
+ +{#each array as item} +
+{:else} +
+{/each} + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-nested/_config.js b/test/css/samples/siblings-combinator-each-nested/_config.js new file mode 100644 index 0000000000..ce9c46fb06 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-nested/_config.js @@ -0,0 +1,116 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 56: + 57: /* no match */ + 58: .a + .h { color: green; } + ^ + 59: .a + .i { color: green; } + 60: .c + .h { color: green; }`, + message: 'Unused CSS selector ".a + .h"', + pos: 1229, + start: { character: 1229, column: 1, line: 58 }, + end: { character: 1236, column: 8, line: 58 } + }, + { + code: "css-unused-selector", + frame: ` + 57: /* no match */ + 58: .a + .h { color: green; } + 59: .a + .i { color: green; } + ^ + 60: .c + .h { color: green; } + 61: .c + .i { color: green; }`, + message: 'Unused CSS selector ".a + .i"', + pos: 1256, + start: { character: 1256, column: 1, line: 59 }, + end: { character: 1263, column: 8, line: 59 } + }, + { + code: "css-unused-selector", + frame: ` + 58: .a + .h { color: green; } + 59: .a + .i { color: green; } + 60: .c + .h { color: green; } + ^ + 61: .c + .i { color: green; } + 62: .d + .f { color: green; }`, + message: 'Unused CSS selector ".c + .h"', + pos: 1283, + start: { character: 1283, column: 1, line: 60 }, + end: { character: 1290, column: 8, line: 60 } + }, + { + code: "css-unused-selector", + frame: ` + 59: .a + .i { color: green; } + 60: .c + .h { color: green; } + 61: .c + .i { color: green; } + ^ + 62: .d + .f { color: green; } + 63: .d + .g { color: green; }`, + message: 'Unused CSS selector ".c + .i"', + pos: 1310, + start: { character: 1310, column: 1, line: 61 }, + end: { character: 1317, column: 8, line: 61 } + }, + { + code: "css-unused-selector", + frame: ` + 60: .c + .h { color: green; } + 61: .c + .i { color: green; } + 62: .d + .f { color: green; } + ^ + 63: .d + .g { color: green; } + 64: .e + .g { color: green; }`, + message: 'Unused CSS selector ".d + .f"', + pos: 1337, + start: { character: 1337, column: 1, line: 62 }, + end: { character: 1344, column: 8, line: 62 } + }, + { + code: "css-unused-selector", + frame: ` + 61: .c + .i { color: green; } + 62: .d + .f { color: green; } + 63: .d + .g { color: green; } + ^ + 64: .e + .g { color: green; } + 65: .g + .i { color: green; }`, + message: 'Unused CSS selector ".d + .g"', + pos: 1364, + start: { character: 1364, column: 1, line: 63 }, + end: { character: 1371, column: 8, line: 63 } + }, + { + code: "css-unused-selector", + frame: ` + 62: .d + .f { color: green; } + 63: .d + .g { color: green; } + 64: .e + .g { color: green; } + ^ + 65: .g + .i { color: green; } + 66: `, + message: 'Unused CSS selector ".e + .g"', + pos: 1391, + start: { character: 1391, column: 1, line: 64 }, + end: { character: 1398, column: 8, line: 64 } + }, + { + code: "css-unused-selector", + frame: ` + 63: .d + .g { color: green; } + 64: .e + .g { color: green; } + 65: .g + .i { color: green; } + ^ + 66: + 67:`, + message: 'Unused CSS selector ".g + .i"', + pos: 1418, + start: { character: 1418, column: 1, line: 65 }, + end: { character: 1425, column: 8, line: 65 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-each-nested/expected.css b/test/css/samples/siblings-combinator-each-nested/expected.css new file mode 100644 index 0000000000..616d739670 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-nested/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.d.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.g.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.d.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.g.svelte-xyz.svelte-xyz{color:green}.j.svelte-xyz+.m.svelte-xyz.svelte-xyz{color:green}.j.svelte-xyz+.n.svelte-xyz.svelte-xyz{color:green}.j.svelte-xyz+.o.svelte-xyz.svelte-xyz{color:green}.k.svelte-xyz+.m.svelte-xyz.svelte-xyz{color:green}.k.svelte-xyz+.n.svelte-xyz.svelte-xyz{color:green}.k.svelte-xyz+.o.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz+.m.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz+.n.svelte-xyz.svelte-xyz{color:green}.l.svelte-xyz+.o.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz+.h.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz+.d.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.h.svelte-xyz+.g.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz+.h.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz+.g.svelte-xyz.svelte-xyz{color:green}.d.svelte-xyz+.d.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz+.e.svelte-xyz.svelte-xyz{color:green}.f.svelte-xyz+.f.svelte-xyz.svelte-xyz{color:green}.g.svelte-xyz+.g.svelte-xyz.svelte-xyz{color:green}.h.svelte-xyz+.h.svelte-xyz.svelte-xyz{color:green}.i.svelte-xyz+.i.svelte-xyz.svelte-xyz{color:green}.e.svelte-xyz+.e.svelte-xyz+.f.svelte-xyz{color:green}.e.svelte-xyz+.e.svelte-xyz+.d.svelte-xyz{color:green}.h.svelte-xyz+.h.svelte-xyz+.i.svelte-xyz{color:green}.h.svelte-xyz+.h.svelte-xyz+.g.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-nested/expected.html b/test/css/samples/siblings-combinator-each-nested/expected.html new file mode 100644 index 0000000000..340d6fc4c8 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-nested/expected.html @@ -0,0 +1,15 @@ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each-nested/input.svelte b/test/css/samples/siblings-combinator-each-nested/input.svelte new file mode 100644 index 0000000000..b5b9242675 --- /dev/null +++ b/test/css/samples/siblings-combinator-each-nested/input.svelte @@ -0,0 +1,113 @@ + + + + +
+ +{#each array as item} +
+
+{/each} + +{#each array as item} + {#each array as item} + {#each array as item} +
+ {/each} +
+ {/each} +
+{/each} + +{#each array as item} +
+ {#each array as item} +
+ {#each array as item} +
+ {/each} + {/each} +{/each} + +{#each array as item} +
+ {#each array as item} +
+ {#each array as item} +
+ {/each} + {/each} +{/each} + +{#each array as item} + {#each array as item} + {#each array as item} +
+ {/each} +
+ {/each} +
+{/each} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each/expected.css b/test/css/samples/siblings-combinator-each/expected.css new file mode 100644 index 0000000000..a46fc4ed4e --- /dev/null +++ b/test/css/samples/siblings-combinator-each/expected.css @@ -0,0 +1 @@ +div.svelte-xyz+span.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-each/expected.html b/test/css/samples/siblings-combinator-each/expected.html new file mode 100644 index 0000000000..9d0416f01b --- /dev/null +++ b/test/css/samples/siblings-combinator-each/expected.html @@ -0,0 +1,6 @@ +
+ +
+ +
+ diff --git a/test/css/samples/siblings-combinator-each/input.svelte b/test/css/samples/siblings-combinator-each/input.svelte new file mode 100644 index 0000000000..de77a25180 --- /dev/null +++ b/test/css/samples/siblings-combinator-each/input.svelte @@ -0,0 +1,20 @@ + + + + +
+ +{#each array as item} + +
+ +
+{/each} + + \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/_config.js b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/_config.js new file mode 100644 index 0000000000..0155bf0cf1 --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 16: + 17: /* no match */ + 18: .b + .c { color: green; } + ^ + 19: + 20:`, + message: 'Unused CSS selector ".b + .c"', + pos: 319, + start: { character: 319, column: 1, line: 18 }, + end: { character: 326, column: 8, line: 18 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/expected.css b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/expected.css new file mode 100644 index 0000000000..93cd539f00 --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.b.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.b.svelte-xyz+.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.d.svelte-xyz.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz+.c.svelte-xyz.svelte-xyz{color:green}.c.svelte-xyz+.c.svelte-xyz+.d.svelte-xyz.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz+.c.svelte-xyz+.d.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/expected.html b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/expected.html new file mode 100644 index 0000000000..fb838a55fd --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/input.svelte b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/input.svelte new file mode 100644 index 0000000000..ff9f10dc1c --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive-with-each/input.svelte @@ -0,0 +1,31 @@ + + + + +
+ +{#if foo} +
+{:else} + {#each array as item} +
+ {/each} +{/if} + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive/_config.js b/test/css/samples/siblings-combinator-if-not-exhaustive/_config.js new file mode 100644 index 0000000000..e01c358eff --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 12: + 13: /* no match */ + 14: .b + .c { color: green; } + ^ + 15: + 16:`, + message: 'Unused CSS selector ".b + .c"', + pos: 215, + start: { character: 215, column: 1, line: 14 }, + end: { character: 222, column: 8, line: 14 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive/expected.css b/test/css/samples/siblings-combinator-if-not-exhaustive/expected.css new file mode 100644 index 0000000000..b1225e36a1 --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.b.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz{color:green}.a.svelte-xyz+.d.svelte-xyz{color:green}.b.svelte-xyz+.d.svelte-xyz{color:green}.c.svelte-xyz+.d.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive/expected.html b/test/css/samples/siblings-combinator-if-not-exhaustive/expected.html new file mode 100644 index 0000000000..813e778dc6 --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if-not-exhaustive/input.svelte b/test/css/samples/siblings-combinator-if-not-exhaustive/input.svelte new file mode 100644 index 0000000000..4f832b3b47 --- /dev/null +++ b/test/css/samples/siblings-combinator-if-not-exhaustive/input.svelte @@ -0,0 +1,25 @@ + + + + +
+ +{#if foo} +
+{:else if bar} +
+{/if} + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if/_config.js b/test/css/samples/siblings-combinator-if/_config.js new file mode 100644 index 0000000000..c2396f08ef --- /dev/null +++ b/test/css/samples/siblings-combinator-if/_config.js @@ -0,0 +1,60 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 13: + 14: /* no match */ + 15: .a + .e { color: green; } + ^ + 16: .b + .c { color: green; } + 17: .b + .d { color: green; }`, + message: 'Unused CSS selector ".a + .e"', + pos: 242, + start: { character: 242, column: 1, line: 15 }, + end: { character: 249, column: 8, line: 15 } + }, + { + code: "css-unused-selector", + frame: ` + 14: /* no match */ + 15: .a + .e { color: green; } + 16: .b + .c { color: green; } + ^ + 17: .b + .d { color: green; } + 18: .c + .d { color: green; }`, + message: 'Unused CSS selector ".b + .c"', + pos: 269, + start: { character: 269, column: 1, line: 16 }, + end: { character: 276, column: 8, line: 16 } + }, + { + code: "css-unused-selector", + frame: ` + 15: .a + .e { color: green; } + 16: .b + .c { color: green; } + 17: .b + .d { color: green; } + ^ + 18: .c + .d { color: green; } + 19: `, + message: 'Unused CSS selector ".b + .d"', + pos: 296, + start: { character: 296, column: 1, line: 17 }, + end: { character: 303, column: 8, line: 17 } + }, + { + code: "css-unused-selector", + frame: ` + 16: .b + .c { color: green; } + 17: .b + .d { color: green; } + 18: .c + .d { color: green; } + ^ + 19: + 20:`, + message: 'Unused CSS selector ".c + .d"', + pos: 323, + start: { character: 323, column: 1, line: 18 }, + end: { character: 330, column: 8, line: 18 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-if/expected.css b/test/css/samples/siblings-combinator-if/expected.css new file mode 100644 index 0000000000..5ea39be7c2 --- /dev/null +++ b/test/css/samples/siblings-combinator-if/expected.css @@ -0,0 +1 @@ +.a.svelte-xyz+.b.svelte-xyz{color:green}.a.svelte-xyz+.c.svelte-xyz{color:green}.a.svelte-xyz+.d.svelte-xyz{color:green}.b.svelte-xyz+.e.svelte-xyz{color:green}.c.svelte-xyz+.e.svelte-xyz{color:green}.d.svelte-xyz+.e.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if/expected.html b/test/css/samples/siblings-combinator-if/expected.html new file mode 100644 index 0000000000..3d8ac9f966 --- /dev/null +++ b/test/css/samples/siblings-combinator-if/expected.html @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-if/input.svelte b/test/css/samples/siblings-combinator-if/input.svelte new file mode 100644 index 0000000000..6cfc436876 --- /dev/null +++ b/test/css/samples/siblings-combinator-if/input.svelte @@ -0,0 +1,31 @@ + + + + +
+ +{#if foo} +
+{:else if bar} +
+{:else} +
+{/if} + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-slot/_config.js b/test/css/samples/siblings-combinator-slot/_config.js new file mode 100644 index 0000000000..c0a00500d4 --- /dev/null +++ b/test/css/samples/siblings-combinator-slot/_config.js @@ -0,0 +1,46 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 7: + 8: /* no match */ + 9: .a + .b { color: green; } + ^ + 10: .b + .c { color: green; } + 11: .c + .f { color: green; }`, + message: 'Unused CSS selector ".a + .b"', + pos: 84, + start: { character: 84, column: 1, line: 9 }, + end: { character: 91, column: 8, line: 9 } + }, + { + code: "css-unused-selector", + frame: ` + 8: /* no match */ + 9: .a + .b { color: green; } + 10: .b + .c { color: green; } + ^ + 11: .c + .f { color: green; } + 12: `, + message: 'Unused CSS selector ".b + .c"', + pos: 111, + start: { character: 111, column: 1, line: 10 }, + end: { character: 118, column: 8, line: 10 } + }, + { + code: "css-unused-selector", + frame: ` + 9: .a + .b { color: green; } + 10: .b + .c { color: green; } + 11: .c + .f { color: green; } + ^ + 12: + 13:`, + message: 'Unused CSS selector ".c + .f"', + pos: 138, + start: { character: 138, column: 1, line: 11 }, + end: { character: 145, column: 8, line: 11 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-slot/expected.css b/test/css/samples/siblings-combinator-slot/expected.css new file mode 100644 index 0000000000..bbdd03f274 --- /dev/null +++ b/test/css/samples/siblings-combinator-slot/expected.css @@ -0,0 +1 @@ +.d.svelte-xyz+.e.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-slot/input.svelte b/test/css/samples/siblings-combinator-slot/input.svelte new file mode 100644 index 0000000000..42fe0e4c30 --- /dev/null +++ b/test/css/samples/siblings-combinator-slot/input.svelte @@ -0,0 +1,24 @@ + + + + +
+ +
+ +
+
+
+
+ + +
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-star/_config.js b/test/css/samples/siblings-combinator-star/_config.js new file mode 100644 index 0000000000..32ff416981 --- /dev/null +++ b/test/css/samples/siblings-combinator-star/_config.js @@ -0,0 +1,18 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 3: margin-left: 4px; + 4: } + 5: .not-match > * + * { + ^ + 6: margin-left: 4px; + 7: }`, + message: 'Unused CSS selector ".not-match > * + *"', + pos: 50, + start: { character: 50, column: 1, line: 5 }, + end: { character: 68, column: 19, line: 5 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator-star/expected.css b/test/css/samples/siblings-combinator-star/expected.css new file mode 100644 index 0000000000..c1a06945f9 --- /dev/null +++ b/test/css/samples/siblings-combinator-star/expected.css @@ -0,0 +1 @@ +.match.svelte-xyz>.svelte-xyz+.svelte-xyz{margin-left:4px} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator-star/expected.html b/test/css/samples/siblings-combinator-star/expected.html new file mode 100644 index 0000000000..1cfae6e6f7 --- /dev/null +++ b/test/css/samples/siblings-combinator-star/expected.html @@ -0,0 +1,7 @@ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator-star/input.svelte b/test/css/samples/siblings-combinator-star/input.svelte new file mode 100644 index 0000000000..ca837f2239 --- /dev/null +++ b/test/css/samples/siblings-combinator-star/input.svelte @@ -0,0 +1,17 @@ + + +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator/_config.js b/test/css/samples/siblings-combinator/_config.js new file mode 100644 index 0000000000..2285b5a837 --- /dev/null +++ b/test/css/samples/siblings-combinator/_config.js @@ -0,0 +1,62 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + frame: ` + 3: color: green; + 4: } + 5: article + div { + ^ + 6: color: green; + 7: }`, + message: 'Unused CSS selector "article + div"', + pos: 45, + start: { character: 45, column: 1, line: 5 }, + end: { character: 58, column: 14, line: 5 } + }, + { + code: "css-unused-selector", + + frame:` + 6: color: green; + 7: } + 8: span + article { + ^ + 9: color: green; + 10: }`, + message: 'Unused CSS selector "span + article"', + pos: 81, + start: { character: 81, column: 1, line: 8 }, + end: { character: 95, column: 15, line: 8 } + }, + { + code: "css-unused-selector", + + frame: ` + 9: color: green; + 10: } + 11: b + article { + ^ + 12: color: green; + 13: }`, + message: 'Unused CSS selector "b + article"', + pos: 118, + start: { character: 118, column: 1, line: 11 }, + end: { character: 129, column: 12, line: 11 } + }, + { + code: "css-unused-selector", + frame: ` + 12: color: green; + 13: } + 14: span + div { + ^ + 15: color: green; + 16: }`, + message: 'Unused CSS selector "span + div"', + pos: 152, + start: { character: 152, column: 1, line: 14 }, + end: { character: 162, column: 11, line: 14 } + } + ] +}; diff --git a/test/css/samples/siblings-combinator/expected.css b/test/css/samples/siblings-combinator/expected.css new file mode 100644 index 0000000000..be01048cf1 --- /dev/null +++ b/test/css/samples/siblings-combinator/expected.css @@ -0,0 +1 @@ +div.svelte-xyz+article.svelte-xyz.svelte-xyz{color:green}span.svelte-xyz+b.svelte-xyz.svelte-xyz{color:green}div.svelte-xyz span.svelte-xyz+b.svelte-xyz{color:green}.a.svelte-xyz+article.svelte-xyz.svelte-xyz{color:green}div.svelte-xyz+.b.svelte-xyz.svelte-xyz{color:green} \ No newline at end of file diff --git a/test/css/samples/siblings-combinator/expected.html b/test/css/samples/siblings-combinator/expected.html new file mode 100644 index 0000000000..f4692365dd --- /dev/null +++ b/test/css/samples/siblings-combinator/expected.html @@ -0,0 +1,5 @@ +
+ + +
+
\ No newline at end of file diff --git a/test/css/samples/siblings-combinator/input.svelte b/test/css/samples/siblings-combinator/input.svelte new file mode 100644 index 0000000000..3e22076d52 --- /dev/null +++ b/test/css/samples/siblings-combinator/input.svelte @@ -0,0 +1,35 @@ + + +
+ + +
+
\ No newline at end of file diff --git a/test/css/samples/unused-selector-child-combinator/_config.js b/test/css/samples/unused-selector-child-combinator/_config.js new file mode 100644 index 0000000000..becf382147 --- /dev/null +++ b/test/css/samples/unused-selector-child-combinator/_config.js @@ -0,0 +1,45 @@ +export default { + warnings: [ + { + code: "css-unused-selector", + message: 'Unused CSS selector "article > *"', + frame: ` + 1: + +
+

+ Svelte REPLs are svelte. +

+
\ No newline at end of file diff --git a/test/js/samples/event-modifiers/expected.js b/test/js/samples/event-modifiers/expected.js index 6aa3c161f9..3901753661 100644 --- a/test/js/samples/event-modifiers/expected.js +++ b/test/js/samples/event-modifiers/expected.js @@ -16,41 +16,49 @@ import { } from "svelte/internal"; function create_fragment(ctx) { - let div; - let button0; + let div1; + let div0; let t1; - let button1; + let button0; let t3; + let button1; + let t5; let button2; let mounted; let dispose; return { c() { - div = element("div"); + div1 = element("div"); + div0 = element("div"); + div0.textContent = "touch me"; + t1 = space(); button0 = element("button"); button0.textContent = "click me"; - t1 = space(); + t3 = space(); button1 = element("button"); button1.textContent = "or me"; - t3 = space(); + t5 = space(); button2 = element("button"); button2.textContent = "or me!"; }, m(target, anchor) { - insert(target, div, anchor); - append(div, button0); - append(div, t1); - append(div, button1); - append(div, t3); - append(div, button2); + insert(target, div1, anchor); + append(div1, div0); + append(div1, t1); + append(div1, button0); + append(div1, t3); + append(div1, button1); + append(div1, t5); + append(div1, button2); if (!mounted) { dispose = [ + listen(div0, "touchstart", handleTouchstart, { passive: false }), listen(button0, "click", stop_propagation(prevent_default(handleClick))), listen(button1, "click", handleClick, { once: true, capture: true }), listen(button2, "click", handleClick, true), - listen(div, "touchstart", handleTouchstart, { passive: true }) + listen(div1, "touchstart", handleTouchstart, { passive: true }) ]; mounted = true; @@ -60,7 +68,7 @@ function create_fragment(ctx) { i: noop, o: noop, d(detaching) { - if (detaching) detach(div); + if (detaching) detach(div1); mounted = false; run_all(dispose); } diff --git a/test/js/samples/event-modifiers/input.svelte b/test/js/samples/event-modifiers/input.svelte index 225134f598..c72d58dabb 100644 --- a/test/js/samples/event-modifiers/input.svelte +++ b/test/js/samples/event-modifiers/input.svelte @@ -9,6 +9,7 @@
+
touch me
diff --git a/test/js/samples/import-meta/expected.js b/test/js/samples/import-meta/expected.js new file mode 100644 index 0000000000..ba77398321 --- /dev/null +++ b/test/js/samples/import-meta/expected.js @@ -0,0 +1,53 @@ +/* generated by Svelte vX.Y.Z */ +import { + SvelteComponent, + detach, + init, + insert, + noop, + safe_not_equal, + space, + text +} from "svelte/internal"; + +function create_fragment(ctx) { + let t0; + let t1; + let t2_value = import.meta.url + ""; + let t2; + + return { + c() { + t0 = text(/*url*/ ctx[0]); + t1 = space(); + t2 = text(t2_value); + }, + m(target, anchor) { + insert(target, t0, anchor); + insert(target, t1, anchor); + insert(target, t2, anchor); + }, + p: noop, + i: noop, + o: noop, + d(detaching) { + if (detaching) detach(t0); + if (detaching) detach(t1); + if (detaching) detach(t2); + } + }; +} + +function instance($$self) { + const url = import.meta.url; + return [url]; +} + +class Component extends SvelteComponent { + constructor(options) { + super(); + init(this, options, instance, create_fragment, safe_not_equal, {}); + } +} + +export default Component; \ No newline at end of file diff --git a/test/js/samples/import-meta/input.svelte b/test/js/samples/import-meta/input.svelte new file mode 100644 index 0000000000..a5ce32dd77 --- /dev/null +++ b/test/js/samples/import-meta/input.svelte @@ -0,0 +1,6 @@ + + +{url} +{import.meta.url} diff --git a/test/runtime/samples/action-object/_config.js b/test/runtime/samples/action-object/_config.js new file mode 100644 index 0000000000..7fdc11af2b --- /dev/null +++ b/test/runtime/samples/action-object/_config.js @@ -0,0 +1,8 @@ +export default { + html: ` + + `, + async test({ assert, target, window }) { + assert.equal(target.querySelector('button').foo, 'bar1337'); + } +}; diff --git a/test/runtime/samples/action-object/main.svelte b/test/runtime/samples/action-object/main.svelte new file mode 100644 index 0000000000..f15e319e6f --- /dev/null +++ b/test/runtime/samples/action-object/main.svelte @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/await-without-catch/_config.js b/test/runtime/samples/await-without-catch/_config.js index 2030ed7949..1b7da5c0be 100644 --- a/test/runtime/samples/await-without-catch/_config.js +++ b/test/runtime/samples/await-without-catch/_config.js @@ -39,6 +39,7 @@ export default { }) .catch((err) => { assert.equal(err.message, 'this error should be thrown'); + assert.htmlEqual(target.innerHTML, ''); }); } }; \ No newline at end of file diff --git a/test/runtime/samples/each-block-keyed-dyanmic-key/_config.js b/test/runtime/samples/each-block-keyed-dyanmic-key/_config.js new file mode 100644 index 0000000000..0aed1b0e07 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-dyanmic-key/_config.js @@ -0,0 +1,27 @@ +let count = 0; +let value = 'foo'; + +export default { + props: { + value() { + count++; + return value; + } + }, + + html: ` +
foo
+
foo
+ `, + + test({ assert, component, target }) { + value = 'bar'; + component.id = 1; + + assert.equal(count, 4); + assert.htmlEqual(target.innerHTML, ` +
bar
+
bar
+ `); + } +}; diff --git a/test/runtime/samples/each-block-keyed-dyanmic-key/main.svelte b/test/runtime/samples/each-block-keyed-dyanmic-key/main.svelte new file mode 100644 index 0000000000..9a15c7d98e --- /dev/null +++ b/test/runtime/samples/each-block-keyed-dyanmic-key/main.svelte @@ -0,0 +1,8 @@ + + +{#each ['foo', 'bar'] as key (id + key)} +
{value()}
+{/each} \ No newline at end of file diff --git a/test/runtime/samples/numeric-seperator/_config.js b/test/runtime/samples/numeric-seperator/_config.js new file mode 100644 index 0000000000..bc6d7c04f3 --- /dev/null +++ b/test/runtime/samples/numeric-seperator/_config.js @@ -0,0 +1,3 @@ +export default { + html: `2048 2048` +}; diff --git a/test/runtime/samples/numeric-seperator/main.svelte b/test/runtime/samples/numeric-seperator/main.svelte new file mode 100644 index 0000000000..e491b8a107 --- /dev/null +++ b/test/runtime/samples/numeric-seperator/main.svelte @@ -0,0 +1,5 @@ + + +{num} {2_048} \ No newline at end of file diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_config.js b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_config.js new file mode 100644 index 0000000000..f737cad2aa --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_config.js @@ -0,0 +1,9 @@ +// destructure to store value +export default { + skip_if_ssr: true, // pending https://github.com/sveltejs/svelte/issues/3582 + html: `

2 2 xxx 5 6 9 10 2

`, + async test({ assert, target, component }) { + await component.update(); + assert.htmlEqual(target.innerHTML, `

11 11 yyy 12 13 14 15 11

`); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/main.svelte b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/main.svelte new file mode 100644 index 0000000000..c1bf63d9cd --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/main.svelte @@ -0,0 +1,29 @@ + + +

{foo} {$eid} {$u.name} {$v} {$w} {$x} {$y} {$z}

diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js new file mode 100644 index 0000000000..0318e63b0a --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js @@ -0,0 +1,9 @@ +// destructure to store +export default { + html: `

2 2 xxx 5 6 9 10 2

`, + skip_if_ssr: true, + async test({ assert, target, component }) { + await component.update(); + assert.htmlEqual(target.innerHTML, `

11 11 yyy 12 13 14 15 11

`); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte new file mode 100644 index 0000000000..cd49223535 --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte @@ -0,0 +1,29 @@ + + +

{foo} {$eid} {u.name} {v} {$w} {$x} {$y} {$z}

diff --git a/test/runtime/samples/reactive-assignment-in-declaration/main.svelte b/test/runtime/samples/reactive-assignment-in-declaration/main.svelte index 8aa05964dd..edac4427bb 100644 --- a/test/runtime/samples/reactive-assignment-in-declaration/main.svelte +++ b/test/runtime/samples/reactive-assignment-in-declaration/main.svelte @@ -1,6 +1,9 @@

{foo} {bar}

diff --git a/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte b/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte index 1c24f364ac..b007f6fe8b 100644 --- a/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte +++ b/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte @@ -1,9 +1,14 @@

{foo1} {foo2}

diff --git a/test/runtime/samples/store-assignment-updates-property/_config.js b/test/runtime/samples/store-assignment-updates-property/_config.js new file mode 100644 index 0000000000..65df38f9e4 --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-property/_config.js @@ -0,0 +1,32 @@ +export default { + html: ` +

a: {"foo":3,"bar":2}

+

b: {"foo":3}

+ + + `, + skip_if_ssr: true, + + async test({ assert, component, target, window }) { + const [btn1, btn2] = target.querySelectorAll('button'); + const click = new window.MouseEvent('click'); + + await btn1.dispatchEvent(click); + + assert.htmlEqual(target.innerHTML, ` +

a: {"foo":4,"bar":2}

+

b: {"foo":4,"baz":0}

+ + + `); + + await btn2.dispatchEvent(click); + + assert.htmlEqual(target.innerHTML, ` +

a: {"foo":5,"bar":2}

+

b: {"foo":5,"qux":0}

+ + + `); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/store-assignment-updates-property/main.svelte b/test/runtime/samples/store-assignment-updates-property/main.svelte new file mode 100644 index 0000000000..c3196a278c --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-property/main.svelte @@ -0,0 +1,24 @@ + + +

a: {JSON.stringify($a)}

+

b: {JSON.stringify($b)}

+ + + \ No newline at end of file diff --git a/test/validator/samples/action-object/warnings.json b/test/validator/samples/action-object/warnings.json new file mode 100644 index 0000000000..e1ccbb55a2 --- /dev/null +++ b/test/validator/samples/action-object/warnings.json @@ -0,0 +1,17 @@ +[ + { + "code": "missing-declaration", + "end": { + "character": 217, + "column": 39, + "line": 11 + }, + "message": "'foo' is not defined", + "pos": 186, + "start": { + "character": 186, + "column": 8, + "line": 11 + } + } +] diff --git a/test/validator/samples/event-modifiers-invalid-nonpassive/errors.json b/test/validator/samples/event-modifiers-invalid-nonpassive/errors.json new file mode 100644 index 0000000000..a7e5a2a76c --- /dev/null +++ b/test/validator/samples/event-modifiers-invalid-nonpassive/errors.json @@ -0,0 +1,15 @@ +[{ + "message": "The 'passive' and 'nonpassive' modifiers cannot be used together", + "code": "invalid-event-modifier", + "start": { + "line": 1, + "column": 5, + "character": 5 + }, + "end": { + "line": 1, + "column": 51, + "character": 51 + }, + "pos": 5 +}] diff --git a/test/validator/samples/event-modifiers-invalid-nonpassive/input.svelte b/test/validator/samples/event-modifiers-invalid-nonpassive/input.svelte new file mode 100644 index 0000000000..3557aa4b1d --- /dev/null +++ b/test/validator/samples/event-modifiers-invalid-nonpassive/input.svelte @@ -0,0 +1,3 @@ +
+ oops +
\ No newline at end of file diff --git a/test/validator/samples/event-modifiers-invalid/errors.json b/test/validator/samples/event-modifiers-invalid/errors.json index 8be2ca7348..59a142d632 100644 --- a/test/validator/samples/event-modifiers-invalid/errors.json +++ b/test/validator/samples/event-modifiers-invalid/errors.json @@ -1,5 +1,5 @@ [{ - "message": "Valid event modifiers are preventDefault, stopPropagation, capture, once, passive or self", + "message": "Valid event modifiers are preventDefault, stopPropagation, capture, once, passive, nonpassive or self", "code": "invalid-event-modifier", "start": { "line": 1, diff --git a/test/validator/samples/import-meta/errors.json b/test/validator/samples/import-meta/errors.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/test/validator/samples/import-meta/errors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/validator/samples/import-meta/input.svelte b/test/validator/samples/import-meta/input.svelte new file mode 100644 index 0000000000..a5ce32dd77 --- /dev/null +++ b/test/validator/samples/import-meta/input.svelte @@ -0,0 +1,6 @@ + + +{url} +{import.meta.url}