From b62fc8c8fd2640c9b99168f01b9d958cb2f7574f Mon Sep 17 00:00:00 2001 From: Yeom suyun <60684815+Artxe2@users.noreply.github.com> Date: Sat, 16 Sep 2023 03:12:53 +0900 Subject: [PATCH] chore: eslint rule for naming convention (#9208) --- packages/svelte/package.json | 3 +- packages/svelte/scripts/.eslintrc.json | 6 ++ packages/svelte/scripts/compile-test.js | 4 +- packages/svelte/scripts/generate-dts.js | 12 +-- packages/svelte/scripts/globals-extractor.js | 4 +- packages/svelte/src/.eslintrc.json | 6 ++ .../svelte/src/compiler/compile/Component.js | 4 +- .../src/compiler/compile/create_module.js | 20 ++--- .../src/compiler/compile/nodes/Binding.js | 4 +- .../src/compiler/compile/nodes/EachBlock.js | 8 +- .../src/compiler/compile/nodes/Element.js | 2 +- .../compile/nodes/shared/get_const_tags.js | 4 +- .../compile/render_dom/wrappers/Window.js | 16 ++-- .../parse/read/css-tree-cq/css_tree_parse.js | 8 +- .../css-tree-cq/node/query_feature_range.js | 6 +- packages/svelte/src/runtime/internal/dom.js | 68 ++++++++-------- packages/svelte/test/.eslintrc.json | 4 +- .../compiler-errors/compiler-errors.test.js | 4 +- .../css/samples/custom-css-hash/_config.js | 4 +- packages/svelte/test/helpers.js | 9 ++- .../svelte/test/hydration/hydration.test.js | 4 +- .../samples/dynamic-text-nil/_config.js | 8 +- packages/svelte/test/parser/parser.test.js | 16 ++-- .../svelte/test/runtime-browser/assert.js | 10 +-- .../test/runtime-browser/browser.test.js | 8 +- .../reflect-attributes/test.js | 20 ++--- .../svelte/test/runtime-browser/driver.js | 4 +- .../_config.js | 16 ++-- .../_config.js | 16 ++-- .../_config.js | 40 +++++----- .../_config.js | 40 +++++----- .../_config.js | 40 +++++----- .../_config.js | 80 +++++++++---------- .../svelte/test/runtime/runtime.shared.js | 18 ++--- .../samples/$$rest-without-props/_config.js | 10 +-- .../test/runtime/samples/$$rest/_config.js | 10 +-- .../samples/action-function/_config.js | 8 +- .../runtime/samples/action-update/_config.js | 4 +- .../test/runtime/samples/action/_config.js | 8 +- .../samples/await-function-promise/_config.js | 6 +- .../runtime/samples/await-in-each/_config.js | 6 +- .../samples/await-then-catch-event/_config.js | 6 +- .../samples/await-then-catch-if/_config.js | 8 +- .../samples/await-then-catch-order/_config.js | 6 +- .../runtime/samples/await-then-if/_config.js | 6 +- .../_config.js | 6 +- .../binding-input-group-each-7/_config.js | 8 +- .../_config.js | 16 ++-- .../_config.js | 12 +-- .../samples/binding-input-number-2/_config.js | 8 +- .../component-binding-deep-b/_config.js | 4 +- .../_config.js | 4 +- .../_config.js | 4 +- .../component-slot-fallback-2/_config.js | 4 +- .../component-slot-fallback-5/_config.js | 6 +- .../dynamic-element-animation-2/_config.js | 26 +++--- .../_config.js | 4 +- .../_config.js | 6 +- .../each-blocks-assignment-2/_config.js | 4 +- .../samples/each-blocks-assignment/_config.js | 18 ++--- .../event-handler-dynamic-hash/_config.js | 6 +- .../event-handler-dynamic-invalid/_config.js | 8 +- .../samples/event-handler-dynamic/_config.js | 6 +- .../event-handler-each-modifier/_config.js | 14 ++-- .../samples/flush-before-bindings/_config.js | 6 +- .../fragment-trailing-whitespace/_config.js | 12 ++- .../samples/if-block-else-update/_config.js | 10 +-- .../test/runtime/samples/nbsp-div/_config.js | 18 ++--- .../samples/noscript-removal/_config.js | 4 +- .../samples/props-reactive-slot/_config.js | 4 +- .../samples/raw-mustache-as-root/_config.js | 6 +- .../raw-mustache-inside-head/_config.js | 6 +- .../raw-mustache-inside-slot/_config.js | 6 +- .../reactive-import-statement/_config.js | 6 +- .../spread-element-input-value/_config.js | 16 ++-- .../spread-element-input-value/utils.js | 4 +- .../_config.js | 4 +- .../_config.js | 10 +-- .../_config.js | 10 +-- .../store-resubscribe-export/_config.js | 12 +-- .../svg-foreignobject-namespace/_config.js | 4 +- .../samples/textarea-content/_config.js | 35 ++++---- .../this-in-function-expressions/_config.js | 4 +- .../window-bind-scroll-update/_config.js | 6 +- .../test/server-side-rendering/ssr-1.test.js | 16 ++-- .../test/server-side-rendering/ssr-2.test.js | 10 +-- .../samples/compile-option-dev/test.js | 8 +- .../sourcemaps/samples/each-block/test.js | 4 +- .../samples/preprocessed-markup/test.js | 12 +-- .../samples/preprocessed-multiple/test.js | 12 +-- .../samples/preprocessed-script/test.js | 12 +-- .../samples/preprocessed-styles/test.js | 12 +-- .../samples/sourcemap-names/test.js | 6 +- .../svelte/test/sourcemaps/sourcemaps.test.js | 35 ++++---- packages/svelte/test/stats/stats.test.js | 18 ++--- packages/svelte/test/store/store.test.js | 18 ++--- packages/svelte/test/tsconfig.json | 7 +- packages/svelte/test/vars/vars.test.js | 16 ++-- pnpm-lock.yaml | 9 +++ 99 files changed, 585 insertions(+), 551 deletions(-) create mode 100644 packages/svelte/scripts/.eslintrc.json create mode 100644 packages/svelte/src/.eslintrc.json diff --git a/packages/svelte/package.json b/packages/svelte/package.json index 357bfba31b..5599dbeaf1 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -83,7 +83,7 @@ "posttest": "agadoo src/internal/index.js", "prepublishOnly": "pnpm build", "types": "node ./scripts/generate-dts.js", - "lint": "prettier . --cache --plugin-search-dir=. --check && eslint \"{src,test}/**/*.{ts,js}\" --cache" + "lint": "prettier . --cache --plugin-search-dir=. --check && eslint \"{scripts,src,test}/**/*.js\" --cache --fix" }, "repository": { "type": "git", @@ -129,6 +129,7 @@ "agadoo": "^3.0.0", "dts-buddy": "^0.1.7", "esbuild": "^0.18.11", + "eslint-plugin-lube": "^0.1.7", "happy-dom": "^9.20.3", "jsdom": "^21.1.2", "kleur": "^4.1.5", diff --git a/packages/svelte/scripts/.eslintrc.json b/packages/svelte/scripts/.eslintrc.json new file mode 100644 index 0000000000..9138b8ea0b --- /dev/null +++ b/packages/svelte/scripts/.eslintrc.json @@ -0,0 +1,6 @@ +{ + "plugins": ["lube"], + "rules": { + "lube/svelte-naming-convention": ["error", { "fixSameNames": true }] + } +} diff --git a/packages/svelte/scripts/compile-test.js b/packages/svelte/scripts/compile-test.js index 9a83708b38..9c9d0efcd5 100644 --- a/packages/svelte/scripts/compile-test.js +++ b/packages/svelte/scripts/compile-test.js @@ -1,8 +1,8 @@ // Compile all Svelte files in a directory to JS and CSS files // Usage: node scripts/compile-test.js -import { mkdirSync, readFileSync, writeFileSync } from 'fs'; -import path from 'path'; +import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import path from 'node:path'; import glob from 'tiny-glob/sync.js'; import { compile } from '../src/compiler/index.js'; diff --git a/packages/svelte/scripts/generate-dts.js b/packages/svelte/scripts/generate-dts.js index 0ecf7127df..9342eae75f 100644 --- a/packages/svelte/scripts/generate-dts.js +++ b/packages/svelte/scripts/generate-dts.js @@ -1,18 +1,18 @@ -import * as fs from 'fs'; +import * as fs from 'node:fs'; import { createBundle } from 'dts-buddy'; // It may look weird, but the imports MUST be ending with index.js to be properly resolved in all TS modes for (const name of ['action', 'animate', 'easing', 'motion', 'store', 'transition']) { - fs.writeFileSync(`${name}.d.ts`, `import './types/index.js';`); + fs.writeFileSync(`${name}.d.ts`, "import './types/index.js';"); } -fs.writeFileSync('index.d.ts', `import './types/index.js';`); -fs.writeFileSync('compiler.d.ts', `import './types/index.js';`); +fs.writeFileSync('index.d.ts', "import './types/index.js';"); +fs.writeFileSync('compiler.d.ts', "import './types/index.js';"); // TODO: some way to mark these as deprecated fs.mkdirSync('./types/compiler', { recursive: true }); -fs.writeFileSync('./types/compiler/preprocess.d.ts', `import '../index.js';`); -fs.writeFileSync('./types/compiler/interfaces.d.ts', `import '../index.js';`); +fs.writeFileSync('./types/compiler/preprocess.d.ts', "import '../index.js';"); +fs.writeFileSync('./types/compiler/interfaces.d.ts', "import '../index.js';"); await createBundle({ output: 'types/index.d.ts', diff --git a/packages/svelte/scripts/globals-extractor.js b/packages/svelte/scripts/globals-extractor.js index c35a39a84f..bd94cc501f 100644 --- a/packages/svelte/scripts/globals-extractor.js +++ b/packages/svelte/scripts/globals-extractor.js @@ -6,8 +6,8 @@ Please run `node scripts/globals-extractor.js` at the project root. see: https://github.com/microsoft/TypeScript/tree/main/lib ---------------------------------------------------------------------- */ -import http from 'https'; -import fs from 'fs'; +import http from 'node:https'; +import fs from 'node:fs'; const GLOBAL_TS_PATH = './src/compiler/utils/globals.js'; diff --git a/packages/svelte/src/.eslintrc.json b/packages/svelte/src/.eslintrc.json new file mode 100644 index 0000000000..9138b8ea0b --- /dev/null +++ b/packages/svelte/src/.eslintrc.json @@ -0,0 +1,6 @@ +{ + "plugins": ["lube"], + "rules": { + "lube/svelte-naming-convention": ["error", { "fixSameNames": true }] + } +} diff --git a/packages/svelte/src/compiler/compile/Component.js b/packages/svelte/src/compiler/compile/Component.js index 7598e60967..4071006836 100644 --- a/packages/svelte/src/compiler/compile/Component.js +++ b/packages/svelte/src/compiler/compile/Component.js @@ -1555,8 +1555,8 @@ export default class Component { }, []) ); if (cycle && cycle.length) { - const declarationList = lookup.get(cycle[0]); - const declaration = declarationList[0]; + const declaration_list = lookup.get(cycle[0]); + const declaration = declaration_list[0]; return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle)); } diff --git a/packages/svelte/src/compiler/compile/create_module.js b/packages/svelte/src/compiler/compile/create_module.js index 7c9ff37109..30a088c7ec 100644 --- a/packages/svelte/src/compiler/compile/create_module.js +++ b/packages/svelte/src/compiler/compile/create_module.js @@ -4,7 +4,7 @@ import { b } from 'code-red'; * @param {any} program * @param {import('estree').Identifier} name * @param {string} banner - * @param {any} sveltePath + * @param {any} svelte_path * @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers * @param {Array<{ name: string; alias: import('estree').Identifier }>} globals * @param {import('estree').ImportDeclaration[]} imports @@ -15,21 +15,21 @@ export default function create_module( program, name, banner, - sveltePath = 'svelte', + svelte_path = 'svelte', helpers, globals, imports, module_exports, exports_from ) { - const internal_path = `${sveltePath}/internal`; + const internal_path = `${svelte_path}/internal`; helpers.sort((a, b) => (a.name < b.name ? -1 : 1)); globals.sort((a, b) => (a.name < b.name ? -1 : 1)); return esm( program, name, banner, - sveltePath, + svelte_path, internal_path, helpers, globals, @@ -41,11 +41,11 @@ export default function create_module( /** * @param {any} source - * @param {any} sveltePath + * @param {any} svelte_path */ -function edit_source(source, sveltePath) { +function edit_source(source, svelte_path) { return source === 'svelte' || source.startsWith('svelte/') - ? source.replace('svelte', sveltePath) + ? source.replace('svelte', svelte_path) : source; } @@ -84,7 +84,7 @@ function get_internal_globals(globals, helpers) { * @param {any} program * @param {import('estree').Identifier} name * @param {string} banner - * @param {string} sveltePath + * @param {string} svelte_path * @param {string} internal_path * @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers * @param {Array<{ name: string; alias: import('estree').Identifier }>} globals @@ -96,7 +96,7 @@ function esm( program, name, banner, - sveltePath, + svelte_path, internal_path, helpers, globals, @@ -118,7 +118,7 @@ function esm( /** @param {any} node */ function rewrite_import(node) { - const value = edit_source(node.source.value, sveltePath); + const value = edit_source(node.source.value, svelte_path); if (node.source.value !== value) { node.source.value = value; node.source.raw = null; diff --git a/packages/svelte/src/compiler/compile/nodes/Binding.js b/packages/svelte/src/compiler/compile/nodes/Binding.js index 0c69ada0d7..d43ea98766 100644 --- a/packages/svelte/src/compiler/compile/nodes/Binding.js +++ b/packages/svelte/src/compiler/compile/nodes/Binding.js @@ -98,7 +98,7 @@ export default class Binding extends Node { this.is_readonly = regex_dimensions.test(this.name) || regex_box_size.test(this.name) || - (isElement(parent) && + (is_element(parent) && ((parent.is_media_node() && read_only_media_attributes.has(this.name)) || (parent.name === 'input' && type === 'file'))) /* TODO others? */; } @@ -127,6 +127,6 @@ export default class Binding extends Node { * @param {import('./shared/Node.js').default} node * @returns {node is import('./Element.js').default} */ -function isElement(node) { +function is_element(node) { return !!(/** @type {any} */ (node).is_media_node); } diff --git a/packages/svelte/src/compiler/compile/nodes/EachBlock.js b/packages/svelte/src/compiler/compile/nodes/EachBlock.js index 3effb263b6..e54f0af139 100644 --- a/packages/svelte/src/compiler/compile/nodes/EachBlock.js +++ b/packages/svelte/src/compiler/compile/nodes/EachBlock.js @@ -84,7 +84,9 @@ export default class EachBlock extends AbstractBlock { this.has_animation = false; [this.const_tags, this.children] = get_const_tags(info.children, component, this, this); if (this.has_animation) { - this.children = this.children.filter((child) => !isEmptyNode(child) && !isCommentNode(child)); + this.children = this.children.filter( + (child) => !is_empty_node(child) && !is_comment_node(child) + ); if (this.children.length !== 1) { const child = this.children.find( (child) => !!(/** @type {import('./Element.js').default} */ (child).animation) @@ -102,11 +104,11 @@ export default class EachBlock extends AbstractBlock { } /** @param {import('./interfaces.js').INode} node */ -function isEmptyNode(node) { +function is_empty_node(node) { return node.type === 'Text' && node.data.trim() === ''; } /** @param {import('./interfaces.js').INode} node */ -function isCommentNode(node) { +function is_comment_node(node) { return node.type === 'Comment'; } diff --git a/packages/svelte/src/compiler/compile/nodes/Element.js b/packages/svelte/src/compiler/compile/nodes/Element.js index 654c2c48f0..0ee4f26d5f 100644 --- a/packages/svelte/src/compiler/compile/nodes/Element.js +++ b/packages/svelte/src/compiler/compile/nodes/Element.js @@ -875,7 +875,7 @@ export default class Element extends Node { ) { const interactive_handlers = handlers .map((handler) => handler.name) - .filter((handlerName) => a11y_interactive_handlers.has(handlerName)); + .filter((handler_name) => a11y_interactive_handlers.has(handler_name)); if (interactive_handlers.length > 0) { component.warn( this, diff --git a/packages/svelte/src/compiler/compile/nodes/shared/get_const_tags.js b/packages/svelte/src/compiler/compile/nodes/shared/get_const_tags.js index 8001420664..b766089359 100644 --- a/packages/svelte/src/compiler/compile/nodes/shared/get_const_tags.js +++ b/packages/svelte/src/compiler/compile/nodes/shared/get_const_tags.js @@ -73,8 +73,8 @@ function sort_consts_nodes(consts_nodes, component) { }, []) ); if (cycle && cycle.length) { - const nodeList = lookup.get(cycle[0]); - const node = nodeList[0]; + const node_list = lookup.get(cycle[0]); + const node = node_list[0]; component.error(node.node, compiler_errors.cyclical_const_tags(cycle)); } diff --git a/packages/svelte/src/compiler/compile/render_dom/wrappers/Window.js b/packages/svelte/src/compiler/compile/render_dom/wrappers/Window.js index ff59cb23d3..7b0ffa982e 100644 --- a/packages/svelte/src/compiler/compile/render_dom/wrappers/Window.js +++ b/packages/svelte/src/compiler/compile/render_dom/wrappers/Window.js @@ -94,14 +94,14 @@ export default class WindowWrapper extends Wrapper { bindings.scrollX && bindings.scrollY ? x`"${bindings.scrollX}" in this._state || "${bindings.scrollY}" in this._state` : x`"${bindings.scrollX || bindings.scrollY}" in this._state`; - const scrollX = bindings.scrollX && x`this._state.${bindings.scrollX}`; - const scrollY = bindings.scrollY && x`this._state.${bindings.scrollY}`; + const scroll_x = bindings.scrollX && x`this._state.${bindings.scrollX}`; + const scroll_y = bindings.scrollY && x`this._state.${bindings.scrollY}`; renderer.meta_bindings.push(b` if (${condition}) { - @_scrollTo(${scrollX || '@_window.pageXOffset'}, ${scrollY || '@_window.pageYOffset'}); + @_scrollTo(${scroll_x || '@_window.pageXOffset'}, ${scroll_y || '@_window.pageYOffset'}); } - ${scrollX && `${scrollX} = @_window.pageXOffset;`} - ${scrollY && `${scrollY} = @_window.pageYOffset;`} + ${scroll_x && `${scroll_x} = @_window.pageXOffset;`} + ${scroll_y && `${scroll_y} = @_window.pageYOffset;`} `); block.event_listeners.push(x` @listen(@_window, "${event}", () => { @@ -132,17 +132,17 @@ export default class WindowWrapper extends Wrapper { // special case... might need to abstract this out if we add more special cases if (bindings.scrollX || bindings.scrollY) { const condition = renderer.dirty([bindings.scrollX, bindings.scrollY].filter(Boolean)); - const scrollX = bindings.scrollX + const scroll_x = bindings.scrollX ? renderer.reference(bindings.scrollX) : x`@_window.pageXOffset`; - const scrollY = bindings.scrollY + const scroll_y = bindings.scrollY ? renderer.reference(bindings.scrollY) : x`@_window.pageYOffset`; block.chunks.update.push(b` if (${condition} && !${scrolling}) { ${scrolling} = true; @_clearTimeout(${scrolling_timeout}); - @_scrollTo(${scrollX}, ${scrollY}); + @_scrollTo(${scroll_x}, ${scroll_y}); ${scrolling_timeout} = @_setTimeout(${clear_scrolling}, 100); } `); diff --git a/packages/svelte/src/compiler/parse/read/css-tree-cq/css_tree_parse.js b/packages/svelte/src/compiler/parse/read/css-tree-cq/css_tree_parse.js index bacb4cc334..0e019ca0d2 100644 --- a/packages/svelte/src/compiler/parse/read/css-tree-cq/css_tree_parse.js +++ b/packages/svelte/src/compiler/parse/read/css-tree-cq/css_tree_parse.js @@ -8,7 +8,7 @@ import * as node from './node/index.js'; * * The new nodes are located in `./node`. */ -const cqSyntax = fork({ +const cq_syntax = fork({ atrule: { // extend or override at-rule dictionary container: { @@ -16,8 +16,8 @@ const cqSyntax = fork({ prelude() { return this.createSingleNodeList(this.ContainerQuery()); }, - block(isStyleBlock = false) { - return this.Block(isStyleBlock); + block(is_style_block = false) { + return this.Block(is_style_block); } } } @@ -25,4 +25,4 @@ const cqSyntax = fork({ node }); -export const parse = cqSyntax.parse; +export const parse = cq_syntax.parse; diff --git a/packages/svelte/src/compiler/parse/read/css-tree-cq/node/query_feature_range.js b/packages/svelte/src/compiler/parse/read/css-tree-cq/node/query_feature_range.js index ee8f14abea..8553693d66 100644 --- a/packages/svelte/src/compiler/parse/read/css-tree-cq/node/query_feature_range.js +++ b/packages/svelte/src/compiler/parse/read/css-tree-cq/node/query_feature_range.js @@ -16,7 +16,7 @@ export const structure = { value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null] }; -function lookup_non_WS_type_and_value(offset, type, referenceStr) { +function lookup_non_ws_type_and_value(offset, type, reference_str) { let current_type; do { @@ -26,7 +26,7 @@ function lookup_non_WS_type_and_value(offset, type, referenceStr) { } } while (current_type !== 0); // NULL -> 0 - return current_type === type ? this.lookupValue(offset - 1, referenceStr) : false; + return current_type === type ? this.lookupValue(offset - 1, reference_str) : false; } export function parse() { @@ -40,7 +40,7 @@ export function parse() { while (!this.eof && this.tokenType !== RightParenthesis) { switch (this.tokenType) { case Number: - if (lookup_non_WS_type_and_value.call(this, 1, Delim, '/')) { + if (lookup_non_ws_type_and_value.call(this, 1, Delim, '/')) { child = this.Ratio(); } else { child = this.Number(); diff --git a/packages/svelte/src/runtime/internal/dom.js b/packages/svelte/src/runtime/internal/dom.js index 18a5d5d278..9e1fd7e261 100644 --- a/packages/svelte/src/runtime/internal/dom.js +++ b/packages/svelte/src/runtime/internal/dom.js @@ -1,5 +1,7 @@ -import { ResizeObserverSingleton } from './ResizeObserverSingleton.js'; import { contenteditable_truthy_values, has_prop } from './utils.js'; + +import { ResizeObserverSingleton } from './ResizeObserverSingleton.js'; + // Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM // at the end of hydration without touching the remaining nodes. let is_hydrating = false; @@ -50,14 +52,14 @@ function init_hydrate(target) { let children = /** @type {ArrayLike} */ (target.childNodes); // If target is , there may be children without claim_order if (target.nodeName === 'HEAD') { - const myChildren = []; + const my_children = []; for (let i = 0; i < children.length; i++) { const node = children[i]; if (node.claim_order !== undefined) { - myChildren.push(node); + my_children.push(node); } } - children = myChildren; + children = my_children; } /* * Reorder claimed children optimally. @@ -87,15 +89,15 @@ function init_hydrate(target) { // Find the largest subsequence length such that it ends in a value less than our current value // upper_bound returns first greater value, so we subtract one // with fast path for when we are on the current longest subsequence - const seqLen = + const seq_len = (longest > 0 && children[m[longest]].claim_order <= current ? longest + 1 : upper_bound(1, longest, (idx) => children[m[idx]].claim_order, current)) - 1; - p[i] = m[seqLen] + 1; - const newLen = seqLen + 1; + p[i] = m[seq_len] + 1; + const new_len = seq_len + 1; // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence. - m[newLen] = i; - longest = Math.max(newLen, longest); + m[new_len] = i; + longest = Math.max(new_len, longest); } // The longest increasing subsequence of nodes (initially reversed) @@ -108,28 +110,28 @@ function init_hydrate(target) { /** * @type {NodeEx2[]} */ - const toMove = []; + const to_move = []; let last = children.length - 1; for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) { lis.push(children[cur - 1]); for (; last >= cur; last--) { - toMove.push(children[last]); + to_move.push(children[last]); } last--; } for (; last >= 0; last--) { - toMove.push(children[last]); + to_move.push(children[last]); } lis.reverse(); // We sort the nodes being moved to guarantee that their insertion order matches the claim order - toMove.sort((a, b) => a.claim_order - b.claim_order); + to_move.sort((a, b) => a.claim_order - b.claim_order); // Finally, we move the nodes - for (let i = 0, j = 0; i < toMove.length; i++) { - while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) { + for (let i = 0, j = 0; i < to_move.length; i++) { + while (j < lis.length && to_move[i].claim_order >= lis[j].claim_order) { j++; } const anchor = j < lis.length ? lis[j] : null; - target.insertBefore(toMove[i], anchor); + target.insertBefore(to_move[i], anchor); } } @@ -624,26 +626,26 @@ function init_claim_info(nodes) { * @template {ChildNodeEx} R * @param {ChildNodeArray} nodes * @param {(node: ChildNodeEx) => node is R} predicate - * @param {(node: ChildNodeEx) => ChildNodeEx | undefined} processNode - * @param {() => R} createNode - * @param {boolean} dontUpdateLastIndex + * @param {(node: ChildNodeEx) => ChildNodeEx | undefined} process_node + * @param {() => R} create_node + * @param {boolean} dont_update_last_index * @returns {R} */ -function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) { +function claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) { // Try to find nodes in an order such that we lengthen the longest increasing subsequence init_claim_info(nodes); - const resultNode = (() => { + const result_node = (() => { // We first try to find an element after the previous one for (let i = nodes.claim_info.last_index; i < nodes.length; i++) { const node = nodes[i]; if (predicate(node)) { - const replacement = processNode(node); + const replacement = process_node(node); if (replacement === undefined) { nodes.splice(i, 1); } else { nodes[i] = replacement; } - if (!dontUpdateLastIndex) { + if (!dont_update_last_index) { nodes.claim_info.last_index = i; } return node; @@ -654,13 +656,13 @@ function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastInd for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) { const node = nodes[i]; if (predicate(node)) { - const replacement = processNode(node); + const replacement = process_node(node); if (replacement === undefined) { nodes.splice(i, 1); } else { nodes[i] = replacement; } - if (!dontUpdateLastIndex) { + if (!dont_update_last_index) { nodes.claim_info.last_index = i; } else if (replacement === undefined) { // Since we spliced before the last_index, we decrease it @@ -670,11 +672,11 @@ function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastInd } } // If we can't find any matching node, we create a new one - return createNode(); + return create_node(); })(); - resultNode.claim_order = nodes.claim_info.total_claimed; + result_node.claim_order = nodes.claim_info.total_claimed; nodes.claim_info.total_claimed += 1; - return resultNode; + return result_node; } /** @@ -736,13 +738,13 @@ export function claim_text(nodes, data) { (node) => node.nodeType === 3, /** @param {Text} node */ (node) => { - const dataStr = '' + data; - if (node.data.startsWith(dataStr)) { - if (node.data.length !== dataStr.length) { - return node.splitText(dataStr.length); + const data_str = '' + data; + if (node.data.startsWith(data_str)) { + if (node.data.length !== data_str.length) { + return node.splitText(data_str.length); } } else { - node.data = dataStr; + node.data = data_str; } }, () => text(data), diff --git a/packages/svelte/test/.eslintrc.json b/packages/svelte/test/.eslintrc.json index 89ee14da16..6075b89ae6 100644 --- a/packages/svelte/test/.eslintrc.json +++ b/packages/svelte/test/.eslintrc.json @@ -1,6 +1,8 @@ { + "plugins": ["lube"], "rules": { "no-console": "off", - "@typescript-eslint/no-var-requires": "off" + "@typescript-eslint/no-var-requires": "off", + "lube/svelte-naming-convention": ["error", { "fixSameNames": true }] } } diff --git a/packages/svelte/test/compiler-errors/compiler-errors.test.js b/packages/svelte/test/compiler-errors/compiler-errors.test.js index 065e9cc01d..e97e556087 100644 --- a/packages/svelte/test/compiler-errors/compiler-errors.test.js +++ b/packages/svelte/test/compiler-errors/compiler-errors.test.js @@ -20,14 +20,14 @@ describe('compiler-errors', () => { it_fn(dir, () => { const cwd = path.resolve(`${__dirname}/samples/${dir}`); - const compileOptions = Object.assign({}, config.compileOptions || {}, { + const compile_options = Object.assign({}, config.compileOptions || {}, { immutable: config.immutable, accessors: 'accessors' in config ? config.accessors : true, generate: 'dom' }); try { - compile(fs.readFileSync(`${cwd}/main.svelte`, 'utf-8'), compileOptions); + compile(fs.readFileSync(`${cwd}/main.svelte`, 'utf-8'), compile_options); } catch (error) { if (typeof config.error === 'function') { config.error(assert, error); diff --git a/packages/svelte/test/css/samples/custom-css-hash/_config.js b/packages/svelte/test/css/samples/custom-css-hash/_config.js index e6a60f059d..3d55fa1b3c 100644 --- a/packages/svelte/test/css/samples/custom-css-hash/_config.js +++ b/packages/svelte/test/css/samples/custom-css-hash/_config.js @@ -2,11 +2,11 @@ export default { compileOptions: { filename: 'src/components/FooSwitcher.svelte', cssHash({ hash, css, name, filename }) { - const minFilename = filename + const min_filename = filename .split('/') .map((i) => i.charAt(0).toLowerCase()) .join(''); - return `sv-${name}-${minFilename}-${hash(css)}`; + return `sv-${name}-${min_filename}-${hash(css)}`; } } }; diff --git a/packages/svelte/test/helpers.js b/packages/svelte/test/helpers.js index b5ee539be8..c306cae8ba 100644 --- a/packages/svelte/test/helpers.js +++ b/packages/svelte/test/helpers.js @@ -1,10 +1,11 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; -import glob from 'tiny-glob/sync'; -import colors from 'kleur'; + import { assert } from 'vitest'; +import colors from 'kleur'; import { compile } from 'svelte/compiler'; import { fileURLToPath } from 'node:url'; +import glob from 'tiny-glob/sync'; export function try_load_json(file) { try { @@ -158,8 +159,8 @@ export function create_loader(compileOptions, cwd) { ) .replace( /^import (\w+, )?{([^}]+)} from ['"](.+)['"];?/gm, - (_, default_, names, source) => { - const d = default_ ? `default: ${default_}` : ''; + (_, _default, names, source) => { + const d = _default ? `default: ${_default}` : ''; return `const { ${d} ${names.replaceAll( ' as ', ': ' diff --git a/packages/svelte/test/hydration/hydration.test.js b/packages/svelte/test/hydration/hydration.test.js index 48e9f3b751..fc12802e82 100644 --- a/packages/svelte/test/hydration/hydration.test.js +++ b/packages/svelte/test/hydration/hydration.test.js @@ -18,12 +18,12 @@ describe('hydration', async () => { it_fn(dir, async () => { const cwd = path.resolve(`${__dirname}/samples/${dir}`); - const compileOptions = Object.assign({}, config.compileOptions, { + const compile_options = Object.assign({}, config.compileOptions, { accessors: 'accessors' in config ? config.accessors : true, hydratable: true }); - const { default: SvelteComponent } = await create_loader(compileOptions, cwd)('main.svelte'); + const { default: SvelteComponent } = await create_loader(compile_options, cwd)('main.svelte'); const target = window.document.body; const head = window.document.head; diff --git a/packages/svelte/test/hydration/samples/dynamic-text-nil/_config.js b/packages/svelte/test/hydration/samples/dynamic-text-nil/_config.js index 35583f7fca..13196cbbe9 100644 --- a/packages/svelte/test/hydration/samples/dynamic-text-nil/_config.js +++ b/packages/svelte/test/hydration/samples/dynamic-text-nil/_config.js @@ -2,12 +2,12 @@ export default { props: {}, snapshot(target) { - const nullText = target.querySelectorAll('p')[0].textContent; - const undefinedText = target.querySelectorAll('p')[1].textContent; + const null_text = target.querySelectorAll('p')[0].textContent; + const undefined_text = target.querySelectorAll('p')[1].textContent; return { - nullText, - undefinedText + nullText: null_text, + undefinedText: undefined_text }; } }; diff --git a/packages/svelte/test/parser/parser.test.js b/packages/svelte/test/parser/parser.test.js index 67a621582a..7826e00251 100644 --- a/packages/svelte/test/parser/parser.test.js +++ b/packages/svelte/test/parser/parser.test.js @@ -26,8 +26,8 @@ describe('parse', () => { .trimEnd() .replace(/\r/g, ''); - const expectedOutput = try_load_json(`${__dirname}/samples/${dir}/output.json`); - const expectedError = try_load_json(`${__dirname}/samples/${dir}/error.json`); + const expected_output = try_load_json(`${__dirname}/samples/${dir}/output.json`); + const expected_error = try_load_json(`${__dirname}/samples/${dir}/error.json`); try { const { ast } = svelte.compile( @@ -42,16 +42,16 @@ describe('parse', () => { JSON.stringify(ast, null, '\t') ); - assert.deepEqual(ast.html, expectedOutput.html); - assert.deepEqual(ast.css, expectedOutput.css); - assert.deepEqual(ast.instance, expectedOutput.instance); - assert.deepEqual(ast.module, expectedOutput.module); + assert.deepEqual(ast.html, expected_output.html); + assert.deepEqual(ast.css, expected_output.css); + assert.deepEqual(ast.instance, expected_output.instance); + assert.deepEqual(ast.module, expected_output.module); } catch (err) { if (err.name !== 'ParseError') throw err; - if (!expectedError) throw err; + if (!expected_error) throw err; const { code, message, pos, start } = err; - assert.deepEqual({ code, message, pos, start }, expectedError); + assert.deepEqual({ code, message, pos, start }, expected_error); } }); }); diff --git a/packages/svelte/test/runtime-browser/assert.js b/packages/svelte/test/runtime-browser/assert.js index 55058d2057..3b7863b519 100644 --- a/packages/svelte/test/runtime-browser/assert.js +++ b/packages/svelte/test/runtime-browser/assert.js @@ -33,10 +33,10 @@ export function ok(condition, message) { } export function htmlEqual(actual, expected, message) { - return deepEqual(normalizeHtml(window, actual), normalizeHtml(window, expected), message); + return deepEqual(normalize_html(window, actual), normalize_html(window, expected), message); } -function normalizeHtml(window, html) { +function normalize_html(window, html) { try { const node = window.document.createElement('div'); node.innerHTML = html @@ -44,7 +44,7 @@ function normalizeHtml(window, html) { .replace(/>[\s\r\n]+<') .trim(); - normalizeStyles(node); + normalize_styles(node); return node.innerHTML.replace(/<\/?noscript\/?>/g, ''); } catch (err) { @@ -52,14 +52,14 @@ function normalizeHtml(window, html) { } } -function normalizeStyles(node) { +function normalize_styles(node) { if (node.nodeType === 1) { if (node.hasAttribute('style')) { node.style = node.style.cssText; } for (const child of node.childNodes) { - normalizeStyles(child); + normalize_styles(child); } } } diff --git a/packages/svelte/test/runtime-browser/browser.test.js b/packages/svelte/test/runtime-browser/browser.test.js index 00ecaa6522..01f2cdb9b1 100644 --- a/packages/svelte/test/runtime-browser/browser.test.js +++ b/packages/svelte/test/runtime-browser/browser.test.js @@ -93,7 +93,7 @@ async function run_browser_test(dir) { globalName: 'test' }); - function assertWarnings() { + function assert_warnings() { if (config.warnings) { assert.deepStrictEqual( warnings.map((w) => ({ @@ -112,7 +112,7 @@ async function run_browser_test(dir) { } } - assertWarnings(); + assert_warnings(); try { const page = await browser.newPage(); @@ -191,7 +191,7 @@ async function run_custom_elements_test(dir) { globalName: 'test' }); - function assertWarnings() { + function assert_warnings() { if (expected_warnings) { assert.deepStrictEqual( warnings.map((w) => ({ @@ -205,7 +205,7 @@ async function run_custom_elements_test(dir) { ); } } - assertWarnings(); + assert_warnings(); const page = await browser.newPage(); page.on('console', (type) => { diff --git a/packages/svelte/test/runtime-browser/custom-elements-samples/reflect-attributes/test.js b/packages/svelte/test/runtime-browser/custom-elements-samples/reflect-attributes/test.js index c66f9f3b97..e869e7bff9 100644 --- a/packages/svelte/test/runtime-browser/custom-elements-samples/reflect-attributes/test.js +++ b/packages/svelte/test/runtime-browser/custom-elements-samples/reflect-attributes/test.js @@ -6,25 +6,25 @@ export default async function (target) { target.innerHTML = ''; await tick(); await tick(); - const ceRoot = target.querySelector('custom-element').shadowRoot; - const div = ceRoot.querySelector('div'); - const p = ceRoot.querySelector('p'); - const button = ceRoot.querySelector('button'); + const ce_root = target.querySelector('custom-element').shadowRoot; + const div = ce_root.querySelector('div'); + const p = ce_root.querySelector('p'); + const button = ce_root.querySelector('button'); assert.equal(getComputedStyle(div).color, 'rgb(255, 0, 0)'); assert.equal(getComputedStyle(p).color, 'rgb(255, 255, 255)'); - const innerRoot = ceRoot.querySelector('my-widget').shadowRoot; - const innerDiv = innerRoot.querySelector('div'); - const innerP = innerRoot.querySelector('p'); + const inner_root = ce_root.querySelector('my-widget').shadowRoot; + const inner_div = inner_root.querySelector('div'); + const inner_p = inner_root.querySelector('p'); - assert.equal(getComputedStyle(innerDiv).color, 'rgb(255, 0, 0)'); - assert.equal(getComputedStyle(innerP).color, 'rgb(255, 255, 255)'); + assert.equal(getComputedStyle(inner_div).color, 'rgb(255, 0, 0)'); + assert.equal(getComputedStyle(inner_p).color, 'rgb(255, 255, 255)'); button.click(); await tick(); await tick(); assert.equal(getComputedStyle(div).color, 'rgb(0, 0, 0)'); - assert.equal(getComputedStyle(innerDiv).color, 'rgb(0, 0, 0)'); + assert.equal(getComputedStyle(inner_div).color, 'rgb(0, 0, 0)'); } diff --git a/packages/svelte/test/runtime-browser/driver.js b/packages/svelte/test/runtime-browser/driver.js index 286ddbe62d..349181a2dc 100644 --- a/packages/svelte/test/runtime-browser/driver.js +++ b/packages/svelte/test/runtime-browser/driver.js @@ -30,7 +30,7 @@ export default async function (target) { const component = new SvelteComponent(options); - const waitUntil = async (fn, ms = 500) => { + const wait_until = async (fn, ms = 500) => { const start = new Date().getTime(); do { if (fn()) return; @@ -48,7 +48,7 @@ export default async function (target) { component, target, window, - waitUntil + waitUntil: wait_until }); component.$destroy(); diff --git a/packages/svelte/test/runtime-browser/samples/component-css-custom-properties-dynamic-svg/_config.js b/packages/svelte/test/runtime-browser/samples/component-css-custom-properties-dynamic-svg/_config.js index a17e6e939d..4b2c5b8c34 100644 --- a/packages/svelte/test/runtime-browser/samples/component-css-custom-properties-dynamic-svg/_config.js +++ b/packages/svelte/test/runtime-browser/samples/component-css-custom-properties-dynamic-svg/_config.js @@ -45,14 +45,14 @@ export default { ` ); - const circleColor1 = target.querySelector('#svg-1 circle'); - const rectColor1 = target.querySelector('#svg-1 rect'); - const circleColor2 = target.querySelector('#svg-2 circle'); - const rectColor2 = target.querySelector('#svg-2 rect'); + const circle_color1 = target.querySelector('#svg-1 circle'); + const rect_color1 = target.querySelector('#svg-1 rect'); + const circle_color2 = target.querySelector('#svg-2 circle'); + const rect_color2 = target.querySelector('#svg-2 rect'); - assert.htmlEqual(window.getComputedStyle(circleColor1).fill, 'rgb(255, 0, 0)'); - assert.htmlEqual(window.getComputedStyle(rectColor1).fill, 'rgb(255, 255, 0)'); - assert.htmlEqual(window.getComputedStyle(circleColor2).fill, 'rgb(0, 255, 255)'); - assert.htmlEqual(window.getComputedStyle(rectColor2).fill, 'rgb(0, 0, 0)'); + assert.htmlEqual(window.getComputedStyle(circle_color1).fill, 'rgb(255, 0, 0)'); + assert.htmlEqual(window.getComputedStyle(rect_color1).fill, 'rgb(255, 255, 0)'); + assert.htmlEqual(window.getComputedStyle(circle_color2).fill, 'rgb(0, 255, 255)'); + assert.htmlEqual(window.getComputedStyle(rect_color2).fill, 'rgb(0, 0, 0)'); } }; diff --git a/packages/svelte/test/runtime-browser/samples/component-css-custom-properties/_config.js b/packages/svelte/test/runtime-browser/samples/component-css-custom-properties/_config.js index 9c3b7cbdea..04c0f0a20b 100644 --- a/packages/svelte/test/runtime-browser/samples/component-css-custom-properties/_config.js +++ b/packages/svelte/test/runtime-browser/samples/component-css-custom-properties/_config.js @@ -14,14 +14,14 @@ export default { `, test({ target, window, assert }) { - const railColor1 = target.querySelector('#slider-1 p'); - const trackColor1 = target.querySelector('#slider-1 span'); - const railColor2 = target.querySelector('#slider-2 p'); - const trackColor2 = target.querySelector('#slider-2 span'); + const rail_color1 = target.querySelector('#slider-1 p'); + const track_color1 = target.querySelector('#slider-1 span'); + const rail_color2 = target.querySelector('#slider-2 p'); + const track_color2 = target.querySelector('#slider-2 span'); - assert.htmlEqual(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.htmlEqual(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.htmlEqual(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.htmlEqual(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); + assert.htmlEqual(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.htmlEqual(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.htmlEqual(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.htmlEqual(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); } }; diff --git a/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties/_config.js b/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties/_config.js index 8e423af308..53ff398e8f 100644 --- a/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties/_config.js +++ b/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties/_config.js @@ -18,31 +18,31 @@ export default { `, test({ target, window, assert, component }) { function assert_slider_1() { - const railColor1 = target.querySelector('#component1 p'); - const trackColor1 = target.querySelector('#component1 span'); - const railColor2 = target.querySelector('#component2 p'); - const trackColor2 = target.querySelector('#component2 span'); + const rail_color1 = target.querySelector('#component1 p'); + const track_color1 = target.querySelector('#component1 span'); + const rail_color2 = target.querySelector('#component2 p'); + const track_color2 = target.querySelector('#component2 span'); - assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); - assert.equal(railColor1.textContent, 'Slider1'); - assert.equal(railColor2.textContent, 'Slider1'); + assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); + assert.equal(rail_color1.textContent, 'Slider1'); + assert.equal(rail_color2.textContent, 'Slider1'); } function assert_slider_2() { - const railColor1 = target.querySelector('#component1 p'); - const trackColor1 = target.querySelector('#component1 span'); - const railColor2 = target.querySelector('#component2 p'); - const trackColor2 = target.querySelector('#component2 span'); + const rail_color1 = target.querySelector('#component1 p'); + const track_color1 = target.querySelector('#component1 span'); + const rail_color2 = target.querySelector('#component2 p'); + const track_color2 = target.querySelector('#component2 span'); - assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); - assert.equal(railColor1.textContent, 'Slider2'); - assert.equal(railColor2.textContent, 'Slider2'); + assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); + assert.equal(rail_color1.textContent, 'Slider2'); + assert.equal(rail_color2.textContent, 'Slider2'); } assert_slider_1(); diff --git a/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties2/_config.js b/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties2/_config.js index 6bc789035d..6c3656f630 100644 --- a/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties2/_config.js +++ b/packages/svelte/test/runtime-browser/samples/svelte-component-css-custom-properties2/_config.js @@ -20,31 +20,31 @@ export default { `, test({ target, window, assert, component }) { function assert_slider_1() { - const railColor1 = target.querySelector('#component1 p'); - const trackColor1 = target.querySelector('#component1 span'); - const railColor2 = target.querySelector('#component2 p'); - const trackColor2 = target.querySelector('#component2 span'); + const rail_color1 = target.querySelector('#component1 p'); + const track_color1 = target.querySelector('#component1 span'); + const rail_color2 = target.querySelector('#component2 p'); + const track_color2 = target.querySelector('#component2 span'); - assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); - assert.equal(railColor1.textContent, 'Slider1'); - assert.equal(railColor2.textContent, 'Slider1'); + assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); + assert.equal(rail_color1.textContent, 'Slider1'); + assert.equal(rail_color2.textContent, 'Slider1'); } function assert_slider_2() { - const railColor1 = target.querySelector('#component1 p'); - const trackColor1 = target.querySelector('#component1 span'); - const railColor2 = target.querySelector('#component2 p'); - const trackColor2 = target.querySelector('#component2 span'); + const rail_color1 = target.querySelector('#component1 p'); + const track_color1 = target.querySelector('#component1 span'); + const rail_color2 = target.querySelector('#component2 p'); + const track_color2 = target.querySelector('#component2 span'); - assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); - assert.equal(railColor1.textContent, 'Slider2'); - assert.equal(railColor2.textContent, 'Slider2'); + assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); + assert.equal(rail_color1.textContent, 'Slider2'); + assert.equal(rail_color2.textContent, 'Slider2'); } assert_slider_1(); diff --git a/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties/_config.js b/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties/_config.js index f3023db3c4..7350db32ca 100644 --- a/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties/_config.js +++ b/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties/_config.js @@ -22,26 +22,26 @@ export default { `, test({ target, window, assert }) { - const railColor1 = target.querySelector('#component1 p'); - const trackColor1 = target.querySelector('#component1 span'); - const railColor2 = target.querySelector('#component2 p'); - const trackColor2 = target.querySelector('#component2 span'); - const nestRailColor1 = target.querySelector('#nest-component1 p'); - const nestTrackColor1 = target.querySelector('#nest-component1 span'); - const nestRailColor2 = target.querySelector('#nest-component2 p'); - const nestTrackColor2 = target.querySelector('#nest-component2 span'); + const rail_color1 = target.querySelector('#component1 p'); + const track_color1 = target.querySelector('#component1 span'); + const rail_color2 = target.querySelector('#component2 p'); + const track_color2 = target.querySelector('#component2 span'); + const nest_rail_color1 = target.querySelector('#nest-component1 p'); + const nest_track_color1 = target.querySelector('#nest-component1 span'); + const nest_rail_color2 = target.querySelector('#nest-component2 p'); + const nest_track_color2 = target.querySelector('#nest-component2 span'); - assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); - assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(255, 255, 0)'); - assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 0, 255)'); - assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(0, 255, 255)'); - assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 255, 255)'); - assert.equal(railColor1.textContent, 'Slider1'); - assert.equal(railColor2.textContent, 'Slider2'); - assert.equal(nestRailColor1.textContent, 'Slider1'); - assert.equal(nestRailColor2.textContent, 'Slider2'); + assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); + assert.equal(window.getComputedStyle(nest_rail_color1).color, 'rgb(255, 255, 0)'); + assert.equal(window.getComputedStyle(nest_track_color1).color, 'rgb(255, 0, 255)'); + assert.equal(window.getComputedStyle(nest_rail_color2).color, 'rgb(0, 255, 255)'); + assert.equal(window.getComputedStyle(nest_track_color2).color, 'rgb(255, 255, 255)'); + assert.equal(rail_color1.textContent, 'Slider1'); + assert.equal(rail_color2.textContent, 'Slider2'); + assert.equal(nest_rail_color1.textContent, 'Slider1'); + assert.equal(nest_rail_color2.textContent, 'Slider2'); } }; diff --git a/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties2/_config.js b/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties2/_config.js index 6a976a141c..58ff163f9b 100644 --- a/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties2/_config.js +++ b/packages/svelte/test/runtime-browser/samples/svelte-self-css-custom-properties2/_config.js @@ -25,51 +25,51 @@ export default { `, test({ target, window, assert, component }) { function assert_slider_1() { - const railColor1 = target.querySelector('#component1 p'); - const trackColor1 = target.querySelector('#component1 span'); - const railColor2 = target.querySelector('#component2 p'); - const trackColor2 = target.querySelector('#component2 span'); - const nestRailColor1 = target.querySelector('#nest-component1 p'); - const nestTrackColor1 = target.querySelector('#nest-component1 span'); - const nestRailColor2 = target.querySelector('#nest-component2 p'); - const nestTrackColor2 = target.querySelector('#nest-component2 span'); + const rail_color1 = target.querySelector('#component1 p'); + const track_color1 = target.querySelector('#component1 span'); + const rail_color2 = target.querySelector('#component2 p'); + const track_color2 = target.querySelector('#component2 span'); + const nest_rail_color1 = target.querySelector('#nest-component1 p'); + const nest_track_color1 = target.querySelector('#nest-component1 span'); + const nest_rail_color2 = target.querySelector('#nest-component2 p'); + const nest_track_color2 = target.querySelector('#nest-component2 span'); - assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); - assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(255, 255, 0)'); - assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 0, 255)'); - assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(255, 255, 0)'); - assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 0, 255)'); - assert.equal(railColor1.textContent, 'Slider1'); - assert.equal(railColor2.textContent, 'Slider1'); - assert.equal(nestRailColor1.textContent, 'Slider1'); - assert.equal(nestRailColor2.textContent, 'Slider1'); + assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); + assert.equal(window.getComputedStyle(nest_rail_color1).color, 'rgb(255, 255, 0)'); + assert.equal(window.getComputedStyle(nest_track_color1).color, 'rgb(255, 0, 255)'); + assert.equal(window.getComputedStyle(nest_rail_color2).color, 'rgb(255, 255, 0)'); + assert.equal(window.getComputedStyle(nest_track_color2).color, 'rgb(255, 0, 255)'); + assert.equal(rail_color1.textContent, 'Slider1'); + assert.equal(rail_color2.textContent, 'Slider1'); + assert.equal(nest_rail_color1.textContent, 'Slider1'); + assert.equal(nest_rail_color2.textContent, 'Slider1'); } function assert_slider_2() { - const railColor1 = target.querySelector('#component1 p'); - const trackColor1 = target.querySelector('#component1 span'); - const railColor2 = target.querySelector('#component2 p'); - const trackColor2 = target.querySelector('#component2 span'); - const nestRailColor1 = target.querySelector('#nest-component1 p'); - const nestTrackColor1 = target.querySelector('#nest-component1 span'); - const nestRailColor2 = target.querySelector('#nest-component2 p'); - const nestTrackColor2 = target.querySelector('#nest-component2 span'); + const rail_color1 = target.querySelector('#component1 p'); + const track_color1 = target.querySelector('#component1 span'); + const rail_color2 = target.querySelector('#component2 p'); + const track_color2 = target.querySelector('#component2 span'); + const nest_rail_color1 = target.querySelector('#nest-component1 p'); + const nest_track_color1 = target.querySelector('#nest-component1 span'); + const nest_rail_color2 = target.querySelector('#nest-component2 p'); + const nest_track_color2 = target.querySelector('#nest-component2 span'); - assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); - assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); - assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); - assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); - assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(0, 255, 255)'); - assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 255, 255)'); - assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(0, 255, 255)'); - assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 255, 255)'); - assert.equal(railColor1.textContent, 'Slider2'); - assert.equal(railColor2.textContent, 'Slider2'); - assert.equal(nestRailColor1.textContent, 'Slider2'); - assert.equal(nestRailColor2.textContent, 'Slider2'); + assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)'); + assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)'); + assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)'); + assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)'); + assert.equal(window.getComputedStyle(nest_rail_color1).color, 'rgb(0, 255, 255)'); + assert.equal(window.getComputedStyle(nest_track_color1).color, 'rgb(255, 255, 255)'); + assert.equal(window.getComputedStyle(nest_rail_color2).color, 'rgb(0, 255, 255)'); + assert.equal(window.getComputedStyle(nest_track_color2).color, 'rgb(255, 255, 255)'); + assert.equal(rail_color1.textContent, 'Slider2'); + assert.equal(rail_color2.textContent, 'Slider2'); + assert.equal(nest_rail_color1.textContent, 'Slider2'); + assert.equal(nest_rail_color2.textContent, 'Slider2'); } assert_slider_1(); diff --git a/packages/svelte/test/runtime/runtime.shared.js b/packages/svelte/test/runtime/runtime.shared.js index b02dfb81ff..09b990b514 100644 --- a/packages/svelte/test/runtime/runtime.shared.js +++ b/packages/svelte/test/runtime/runtime.shared.js @@ -55,18 +55,18 @@ async function run_test(dir) { const cwd = path.resolve(`${__dirname}/samples/${dir}`); - const compileOptions = Object.assign({}, config.compileOptions || {}, { + const compile_options = Object.assign({}, config.compileOptions || {}, { hydratable: hydrate, immutable: config.immutable, accessors: 'accessors' in config ? config.accessors : true }); - const load = create_loader(compileOptions, cwd); + const load = create_loader(compile_options, cwd); let mod; let SvelteComponent; - let unintendedError = null; + let unintended_error = null; if (config.expect_unhandled_rejections) { listeners.forEach((listener) => { @@ -111,7 +111,7 @@ async function run_test(dir) { let snapshot = undefined; if (hydrate && from_ssr_html) { - const load_ssr = create_loader({ ...compileOptions, generate: 'ssr' }, cwd); + const load_ssr = create_loader({ ...compile_options, generate: 'ssr' }, cwd); // ssr into target if (config.before_test) config.before_test(); @@ -152,14 +152,14 @@ async function run_test(dir) { console.warn = warn; if (config.error) { - unintendedError = true; + unintended_error = true; assert.fail('Expected a runtime error'); } if (config.warnings) { assert.deepEqual(warnings, config.warnings); } else if (warnings.length) { - unintendedError = true; + unintended_error = true; assert.fail('Received unexpected warnings'); } @@ -183,7 +183,7 @@ async function run_test(dir) { snapshot, window, raf, - compileOptions, + compileOptions: compile_options, load }); } @@ -201,7 +201,7 @@ async function run_test(dir) { await test() .catch((err) => { - if (config.error && !unintendedError) { + if (config.error && !unintended_error) { if (typeof config.error === 'function') { config.error(assert, err); } else { @@ -217,7 +217,7 @@ async function run_test(dir) { mkdirp(path.dirname(out)); // file could be in subdirectory, therefore don't use dir const { js } = compile(fs.readFileSync(`${cwd}/${file}`, 'utf-8').replace(/\r/g, ''), { - ...compileOptions, + ...compile_options, filename: file }); fs.writeFileSync(out, js.code); diff --git a/packages/svelte/test/runtime/samples/$$rest-without-props/_config.js b/packages/svelte/test/runtime/samples/$$rest-without-props/_config.js index 9412aa99df..fb1d4f23ce 100644 --- a/packages/svelte/test/runtime/samples/$$rest-without-props/_config.js +++ b/packages/svelte/test/runtime/samples/$$rest-without-props/_config.js @@ -10,9 +10,9 @@ export default { `, async test({ assert, target, window }) { const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn1.dispatchEvent(clickEvent); + await btn1.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -24,7 +24,7 @@ export default { ` ); - await btn2.dispatchEvent(clickEvent); + await btn2.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -36,7 +36,7 @@ export default { ` ); - await btn3.dispatchEvent(clickEvent); + await btn3.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -48,7 +48,7 @@ export default { ` ); - await btn4.dispatchEvent(clickEvent); + await btn4.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/$$rest/_config.js b/packages/svelte/test/runtime/samples/$$rest/_config.js index 4d050059fc..473ad9f9bc 100644 --- a/packages/svelte/test/runtime/samples/$$rest/_config.js +++ b/packages/svelte/test/runtime/samples/$$rest/_config.js @@ -12,9 +12,9 @@ export default { async test({ assert, target, window }) { const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn1.dispatchEvent(clickEvent); + await btn1.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -27,7 +27,7 @@ export default { ` ); - await btn2.dispatchEvent(clickEvent); + await btn2.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -40,7 +40,7 @@ export default { ` ); - await btn3.dispatchEvent(clickEvent); + await btn3.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -53,7 +53,7 @@ export default { ` ); - await btn4.dispatchEvent(clickEvent); + await btn4.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/action-function/_config.js b/packages/svelte/test/runtime/samples/action-function/_config.js index f8cf390550..1bc45788e5 100644 --- a/packages/svelte/test/runtime/samples/action-function/_config.js +++ b/packages/svelte/test/runtime/samples/action-function/_config.js @@ -5,10 +5,10 @@ export default { async test({ assert, target, window }) { const button = target.querySelector('button'); - const eventEnter = new window.MouseEvent('mouseenter'); - const eventLeave = new window.MouseEvent('mouseleave'); + const event_enter = new window.MouseEvent('mouseenter'); + const event_leave = new window.MouseEvent('mouseleave'); - await button.dispatchEvent(eventEnter); + await button.dispatchEvent(event_enter); assert.htmlEqual( target.innerHTML, ` @@ -17,7 +17,7 @@ export default { ` ); - await button.dispatchEvent(eventLeave); + await button.dispatchEvent(event_leave); assert.htmlEqual( target.innerHTML, ` diff --git a/packages/svelte/test/runtime/samples/action-update/_config.js b/packages/svelte/test/runtime/samples/action-update/_config.js index 0de4397418..f8ce663a8f 100644 --- a/packages/svelte/test/runtime/samples/action-update/_config.js +++ b/packages/svelte/test/runtime/samples/action-update/_config.js @@ -7,7 +7,7 @@ export default { const button = target.querySelector('button'); const enter = new window.MouseEvent('mouseenter'); const leave = new window.MouseEvent('mouseleave'); - const ctrlPress = new window.KeyboardEvent('keydown', { ctrlKey: true }); + const ctrl_press = new window.KeyboardEvent('keydown', { ctrlKey: true }); await button.dispatchEvent(enter); assert.htmlEqual( @@ -18,7 +18,7 @@ export default { ` ); - await window.dispatchEvent(ctrlPress); + await window.dispatchEvent(ctrl_press); assert.htmlEqual( target.innerHTML, ` diff --git a/packages/svelte/test/runtime/samples/action/_config.js b/packages/svelte/test/runtime/samples/action/_config.js index f8cf390550..1bc45788e5 100644 --- a/packages/svelte/test/runtime/samples/action/_config.js +++ b/packages/svelte/test/runtime/samples/action/_config.js @@ -5,10 +5,10 @@ export default { async test({ assert, target, window }) { const button = target.querySelector('button'); - const eventEnter = new window.MouseEvent('mouseenter'); - const eventLeave = new window.MouseEvent('mouseleave'); + const event_enter = new window.MouseEvent('mouseenter'); + const event_leave = new window.MouseEvent('mouseleave'); - await button.dispatchEvent(eventEnter); + await button.dispatchEvent(event_enter); assert.htmlEqual( target.innerHTML, ` @@ -17,7 +17,7 @@ export default { ` ); - await button.dispatchEvent(eventLeave); + await button.dispatchEvent(event_leave); assert.htmlEqual( target.innerHTML, ` diff --git a/packages/svelte/test/runtime/samples/await-function-promise/_config.js b/packages/svelte/test/runtime/samples/await-function-promise/_config.js index 01fe60cd0b..44cf13160b 100644 --- a/packages/svelte/test/runtime/samples/await-function-promise/_config.js +++ b/packages/svelte/test/runtime/samples/await-function-promise/_config.js @@ -1,8 +1,8 @@ -const realPromise = Promise.resolve(42); +const real_promise = Promise.resolve(42); const promise = () => {}; -promise.then = realPromise.then.bind(realPromise); -promise.catch = realPromise.catch.bind(realPromise); +promise.then = real_promise.then.bind(real_promise); +promise.catch = real_promise.catch.bind(real_promise); export default { get props() { diff --git a/packages/svelte/test/runtime/samples/await-in-each/_config.js b/packages/svelte/test/runtime/samples/await-in-each/_config.js index 0e4109ea49..73dbb01e87 100644 --- a/packages/svelte/test/runtime/samples/await-in-each/_config.js +++ b/packages/svelte/test/runtime/samples/await-in-each/_config.js @@ -1,13 +1,13 @@ let fulfil; -const thePromise = new Promise((f) => { +const the_promise = new Promise((f) => { fulfil = f; }); const items = [ { title: 'a title', - data: thePromise + data: the_promise } ]; @@ -23,7 +23,7 @@ export default { test({ assert, target }) { fulfil(42); - return thePromise.then(() => { + return the_promise.then(() => { assert.htmlEqual( target.innerHTML, ` diff --git a/packages/svelte/test/runtime/samples/await-then-catch-event/_config.js b/packages/svelte/test/runtime/samples/await-then-catch-event/_config.js index 2705eb7e17..32189e2389 100644 --- a/packages/svelte/test/runtime/samples/await-then-catch-event/_config.js +++ b/packages/svelte/test/runtime/samples/await-then-catch-event/_config.js @@ -28,10 +28,10 @@ export default { assert.equal(component.clicked, 42); - const thePromise = Promise.resolve(43); - component.thePromise = thePromise; + const the_promise = Promise.resolve(43); + component.thePromise = the_promise; - return thePromise; + return the_promise; }) .then(() => { const { button } = component; diff --git a/packages/svelte/test/runtime/samples/await-then-catch-if/_config.js b/packages/svelte/test/runtime/samples/await-then-catch-if/_config.js index 42683c56f8..f6a3e2b981 100644 --- a/packages/svelte/test/runtime/samples/await-then-catch-if/_config.js +++ b/packages/svelte/test/runtime/samples/await-then-catch-if/_config.js @@ -1,12 +1,12 @@ let fulfil; -const thePromise = new Promise((f) => { +const the_promise = new Promise((f) => { fulfil = f; }); export default { get props() { - return { show: true, thePromise }; + return { show: true, thePromise: the_promise }; }, html: ` @@ -16,7 +16,7 @@ export default { test({ assert, component, target }) { fulfil(42); - return thePromise.then(() => { + return the_promise.then(() => { assert.htmlEqual( target.innerHTML, ` @@ -35,7 +35,7 @@ export default { component.show = true; - return thePromise.then(() => { + return the_promise.then(() => { assert.htmlEqual( target.innerHTML, ` diff --git a/packages/svelte/test/runtime/samples/await-then-catch-order/_config.js b/packages/svelte/test/runtime/samples/await-then-catch-order/_config.js index 275d250233..b588d2e150 100644 --- a/packages/svelte/test/runtime/samples/await-then-catch-order/_config.js +++ b/packages/svelte/test/runtime/samples/await-then-catch-order/_config.js @@ -1,12 +1,12 @@ let fulfil; -const thePromise = new Promise((f) => { +const the_promise = new Promise((f) => { fulfil = f; }); export default { get props() { - return { thePromise }; + return { thePromise: the_promise }; }, html: ` @@ -16,7 +16,7 @@ export default { test({ assert, target }) { fulfil(42); - return thePromise.then(() => { + return the_promise.then(() => { assert.htmlEqual( target.innerHTML, ` diff --git a/packages/svelte/test/runtime/samples/await-then-if/_config.js b/packages/svelte/test/runtime/samples/await-then-if/_config.js index b32ba04715..38bf183971 100644 --- a/packages/svelte/test/runtime/samples/await-then-if/_config.js +++ b/packages/svelte/test/runtime/samples/await-then-if/_config.js @@ -1,12 +1,12 @@ let fulfil; -const thePromise = new Promise((f) => { +const the_promise = new Promise((f) => { fulfil = f; }); export default { get props() { - return { thePromise }; + return { thePromise: the_promise }; }, html: ` @@ -16,7 +16,7 @@ export default { async test({ assert, target }) { fulfil([]); - await thePromise; + await the_promise; assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js b/packages/svelte/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js index 85e78d35dc..fb5aa27b91 100644 --- a/packages/svelte/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js +++ b/packages/svelte/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js @@ -15,12 +15,12 @@ export default { test({ assert, component, target, window }) { const { cats } = component; - const newCats = cats.slice(); - newCats.push({ + const new_cats = cats.slice(); + new_cats.push({ name: 'cat ' + cats.length, checked: false }); - component.cats = newCats; + component.cats = new_cats; let inputs = target.querySelectorAll('input'); assert.equal(inputs.length, 3); diff --git a/packages/svelte/test/runtime/samples/binding-input-group-each-7/_config.js b/packages/svelte/test/runtime/samples/binding-input-group-each-7/_config.js index 7535001f67..3de0231f10 100644 --- a/packages/svelte/test/runtime/samples/binding-input-group-each-7/_config.js +++ b/packages/svelte/test/runtime/samples/binding-input-group-each-7/_config.js @@ -23,7 +23,7 @@ export default { async test({ assert, target, window }) { const inputs = target.querySelectorAll('input'); const checked = new Set(); - const checkInbox = async (i) => { + const check_inbox = async (i) => { checked.add(i); inputs[i].checked = true; await inputs[i].dispatchEvent(event); @@ -35,17 +35,17 @@ export default { const event = new window.Event('change'); - await checkInbox(2); + await check_inbox(2); for (let i = 0; i < 18; i++) { assert.equal(inputs[i].checked, checked.has(i)); } - await checkInbox(12); + await check_inbox(12); for (let i = 0; i < 18; i++) { assert.equal(inputs[i].checked, checked.has(i)); } - await checkInbox(8); + await check_inbox(8); for (let i = 0; i < 18; i++) { assert.equal(inputs[i].checked, checked.has(i)); } diff --git a/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-1/_config.js b/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-1/_config.js index bdc4da2d57..29d7b14bca 100644 --- a/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-1/_config.js +++ b/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-1/_config.js @@ -1,8 +1,8 @@ export default { async test({ assert, target, component, window }) { const button = target.querySelector('button'); - const clickEvent = new window.Event('click'); - const changeEvent = new window.Event('change'); + const click_event = new window.Event('click'); + const change_event = new window.Event('change'); const [input1, input2] = target.querySelectorAll('input[type="checkbox"]'); function validate_inputs(v1, v2) { @@ -17,24 +17,24 @@ export default { validate_inputs(true, true); input1.checked = false; - await input1.dispatchEvent(changeEvent); + await input1.dispatchEvent(change_event); assert.deepEqual(component.test, ['b']); input2.checked = false; - await input2.dispatchEvent(changeEvent); + await input2.dispatchEvent(change_event); assert.deepEqual(component.test, []); input1.checked = true; input2.checked = true; - await input1.dispatchEvent(changeEvent); - await input2.dispatchEvent(changeEvent); + await input1.dispatchEvent(change_event); + await input2.dispatchEvent(change_event); assert.deepEqual(component.test, ['b', 'a']); - await button.dispatchEvent(clickEvent); + await button.dispatchEvent(click_event); assert.deepEqual(component.test, ['b', 'a']); // should it be ['a'] only? valid arguments for both outcomes input1.checked = false; - await input1.dispatchEvent(changeEvent); + await input1.dispatchEvent(change_event); assert.deepEqual(component.test, []); } }; diff --git a/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-2/_config.js b/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-2/_config.js index a8d5a7137f..86f391496e 100644 --- a/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-2/_config.js +++ b/packages/svelte/test/runtime/samples/binding-input-group-if-gh-8372-2/_config.js @@ -1,8 +1,8 @@ export default { async test({ assert, target, component, window }) { const button = target.querySelector('button'); - const clickEvent = new window.Event('click'); - const changeEvent = new window.Event('change'); + const click_event = new window.Event('click'); + const change_event = new window.Event('change'); const [input1, input2] = target.querySelectorAll('input[type="radio"]'); function validate_inputs(v1, v2) { @@ -17,18 +17,18 @@ export default { validate_inputs(false, true); input1.checked = true; - await input1.dispatchEvent(changeEvent); + await input1.dispatchEvent(change_event); assert.deepEqual(component.test, 'a'); input2.checked = true; - await input2.dispatchEvent(changeEvent); + await input2.dispatchEvent(change_event); assert.deepEqual(component.test, 'b'); - await button.dispatchEvent(clickEvent); + await button.dispatchEvent(click_event); assert.deepEqual(component.test, 'b'); // should it be undefined? valid arguments for both outcomes input1.checked = true; - await input1.dispatchEvent(changeEvent); + await input1.dispatchEvent(change_event); assert.deepEqual(component.test, 'a'); } }; diff --git a/packages/svelte/test/runtime/samples/binding-input-number-2/_config.js b/packages/svelte/test/runtime/samples/binding-input-number-2/_config.js index 4411eac0b2..d65df9b819 100644 --- a/packages/svelte/test/runtime/samples/binding-input-number-2/_config.js +++ b/packages/svelte/test/runtime/samples/binding-input-number-2/_config.js @@ -1,25 +1,25 @@ export default { test({ assert, target, window, component }) { const input = target.querySelector('input'); - const inputEvent = new window.InputEvent('input'); + const input_event = new window.InputEvent('input'); assert.equal(component.value, 5); assert.equal(input.value, '5'); input.value = '5.'; - input.dispatchEvent(inputEvent); + input.dispatchEvent(input_event); // input type number has value === "" if ends with dot/comma assert.equal(component.value, undefined); assert.equal(input.value, ''); input.value = '5.5'; - input.dispatchEvent(inputEvent); + input.dispatchEvent(input_event); assert.equal(component.value, 5.5); assert.equal(input.value, '5.5'); input.value = '5.50'; - input.dispatchEvent(inputEvent); + input.dispatchEvent(input_event); assert.equal(component.value, 5.5); assert.equal(input.value, '5.50'); diff --git a/packages/svelte/test/runtime/samples/component-binding-deep-b/_config.js b/packages/svelte/test/runtime/samples/component-binding-deep-b/_config.js index 1b0e09f735..fea5ea4151 100644 --- a/packages/svelte/test/runtime/samples/component-binding-deep-b/_config.js +++ b/packages/svelte/test/runtime/samples/component-binding-deep-b/_config.js @@ -9,13 +9,13 @@ const components = [ } ]; -const selectedComponent = components[0]; +const selected_component = components[0]; export default { skip: true, // doesn't reflect real-world bug, maybe a JSDOM quirk get props() { - return { components, selectedComponent }; + return { components, selectedComponent: selected_component }; }, html: ` diff --git a/packages/svelte/test/runtime/samples/component-event-handler-dynamic/_config.js b/packages/svelte/test/runtime/samples/component-event-handler-dynamic/_config.js index 415b860828..775899740e 100644 --- a/packages/svelte/test/runtime/samples/component-event-handler-dynamic/_config.js +++ b/packages/svelte/test/runtime/samples/component-event-handler-dynamic/_config.js @@ -5,13 +5,13 @@ export default { `, async test({ assert, component, target, window }) { - const [updateButton, button] = target.querySelectorAll('button'); + const [update_button, button] = target.querySelectorAll('button'); const event = new window.MouseEvent('click'); await button.dispatchEvent(event); assert.equal(component.count, 1); - await updateButton.dispatchEvent(event); + await update_button.dispatchEvent(event); await button.dispatchEvent(event); assert.equal(component.count, 11); } diff --git a/packages/svelte/test/runtime/samples/component-event-handler-modifier-once-dynamic/_config.js b/packages/svelte/test/runtime/samples/component-event-handler-modifier-once-dynamic/_config.js index 8796e0faf6..47b6c07edc 100644 --- a/packages/svelte/test/runtime/samples/component-event-handler-modifier-once-dynamic/_config.js +++ b/packages/svelte/test/runtime/samples/component-event-handler-modifier-once-dynamic/_config.js @@ -5,10 +5,10 @@ export default { `, async test({ assert, component, target, window }) { - const [updateButton, button] = target.querySelectorAll('button'); + const [update_button, button] = target.querySelectorAll('button'); const event = new window.MouseEvent('click'); - await updateButton.dispatchEvent(event); + await update_button.dispatchEvent(event); await button.dispatchEvent(event); assert.equal(component.count, 10); diff --git a/packages/svelte/test/runtime/samples/component-slot-fallback-2/_config.js b/packages/svelte/test/runtime/samples/component-slot-fallback-2/_config.js index 7c86357a8e..67e464818b 100644 --- a/packages/svelte/test/runtime/samples/component-slot-fallback-2/_config.js +++ b/packages/svelte/test/runtime/samples/component-slot-fallback-2/_config.js @@ -3,7 +3,7 @@ export default { ssrHtml: ' ', async test({ assert, target, component, window }) { - const [input1, input2, inputFallback] = target.querySelectorAll('input'); + const [input1, input2, input_fallback] = target.querySelectorAll('input'); assert.equal(component.getSubscriberCount(), 3); @@ -13,7 +13,7 @@ export default { await input1.dispatchEvent(new window.Event('input')); assert.equal(input1.value, 'ab'); assert.equal(input2.value, 'ab'); - assert.equal(inputFallback.value, 'ab'); + assert.equal(input_fallback.value, 'ab'); component.props = 'hello'; diff --git a/packages/svelte/test/runtime/samples/component-slot-fallback-5/_config.js b/packages/svelte/test/runtime/samples/component-slot-fallback-5/_config.js index 07d09a3be9..1463dcb560 100644 --- a/packages/svelte/test/runtime/samples/component-slot-fallback-5/_config.js +++ b/packages/svelte/test/runtime/samples/component-slot-fallback-5/_config.js @@ -6,9 +6,9 @@ export default { async test({ assert, target, window }) { const btn = target.querySelector('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -18,7 +18,7 @@ export default { ` ); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/dynamic-element-animation-2/_config.js b/packages/svelte/test/runtime/samples/dynamic-element-animation-2/_config.js index d8399cac37..306b282f7a 100644 --- a/packages/svelte/test/runtime/samples/dynamic-element-animation-2/_config.js +++ b/packages/svelte/test/runtime/samples/dynamic-element-animation-2/_config.js @@ -1,6 +1,6 @@ -let originalDivGetBoundingClientRect; -let originalSpanGetBoundingClientRect; -let originalParagraphGetBoundingClientRect; +let original_div_get_bounding_client_rect; +let original_span_get_bounding_client_rect; +let original_paragraph_get_bounding_client_rect; export default { skip_if_ssr: true, @@ -26,16 +26,16 @@ export default { `, before_test() { - originalDivGetBoundingClientRect = window.HTMLDivElement.prototype.getBoundingClientRect; - originalSpanGetBoundingClientRect = window.HTMLSpanElement.prototype.getBoundingClientRect; - originalParagraphGetBoundingClientRect = + original_div_get_bounding_client_rect = window.HTMLDivElement.prototype.getBoundingClientRect; + original_span_get_bounding_client_rect = window.HTMLSpanElement.prototype.getBoundingClientRect; + original_paragraph_get_bounding_client_rect = window.HTMLParagraphElement.prototype.getBoundingClientRect; - window.HTMLDivElement.prototype.getBoundingClientRect = fakeGetBoundingClientRect; - window.HTMLSpanElement.prototype.getBoundingClientRect = fakeGetBoundingClientRect; - window.HTMLParagraphElement.prototype.getBoundingClientRect = fakeGetBoundingClientRect; + window.HTMLDivElement.prototype.getBoundingClientRect = fake_get_bounding_client_rect; + window.HTMLSpanElement.prototype.getBoundingClientRect = fake_get_bounding_client_rect; + window.HTMLParagraphElement.prototype.getBoundingClientRect = fake_get_bounding_client_rect; - function fakeGetBoundingClientRect() { + function fake_get_bounding_client_rect() { const index = [...this.parentNode.children].indexOf(this); const top = index * 30; @@ -48,10 +48,10 @@ export default { } }, after_test() { - window.HTMLDivElement.prototype.getBoundingClientRect = originalDivGetBoundingClientRect; - window.HTMLSpanElement.prototype.getBoundingClientRect = originalSpanGetBoundingClientRect; + window.HTMLDivElement.prototype.getBoundingClientRect = original_div_get_bounding_client_rect; + window.HTMLSpanElement.prototype.getBoundingClientRect = original_span_get_bounding_client_rect; window.HTMLParagraphElement.prototype.getBoundingClientRect = - originalParagraphGetBoundingClientRect; + original_paragraph_get_bounding_client_rect; }, async test({ assert, component, raf }) { diff --git a/packages/svelte/test/runtime/samples/each-block-destructured-default-binding/_config.js b/packages/svelte/test/runtime/samples/each-block-destructured-default-binding/_config.js index 2ba27bff03..a27d56a306 100644 --- a/packages/svelte/test/runtime/samples/each-block-destructured-default-binding/_config.js +++ b/packages/svelte/test/runtime/samples/each-block-destructured-default-binding/_config.js @@ -13,10 +13,10 @@ export default { assert.equal(input1.value, ''); assert.equal(input2.value, 'hello'); - const inputEvent = new window.InputEvent('input'); + const input_event = new window.InputEvent('input'); input2.value = 'world'; - input2.dispatchEvent(inputEvent); + input2.dispatchEvent(input_event); assert.equal(input2.value, 'world'); assert.equal(component.array[1].value, 'world'); } diff --git a/packages/svelte/test/runtime/samples/each-block-keyed-random-permute/_config.js b/packages/svelte/test/runtime/samples/each-block-keyed-random-permute/_config.js index 454ef48d0f..4fcea8d68f 100644 --- a/packages/svelte/test/runtime/samples/each-block-keyed-random-permute/_config.js +++ b/packages/svelte/test/runtime/samples/each-block-keyed-random-permute/_config.js @@ -1,6 +1,6 @@ const VALUES = Array.from('abcdefghijklmnopqrstuvwxyz'); -function toObjects(array) { +function to_objects(array) { return array.split('').map((x) => ({ id: x })); } @@ -17,7 +17,7 @@ function permute() { export default { get props() { - return { values: toObjects('abc') }; + return { values: to_objects('abc') }; }, html: '(a)(b)(c)', @@ -29,7 +29,7 @@ export default { .split('') .map((x) => `(${x})`) .join(''); - component.values = toObjects(sequence); + component.values = to_objects(sequence); assert.htmlEqual( target.innerHTML, expected, diff --git a/packages/svelte/test/runtime/samples/each-blocks-assignment-2/_config.js b/packages/svelte/test/runtime/samples/each-blocks-assignment-2/_config.js index 93f06956d0..4f62f6b66b 100644 --- a/packages/svelte/test/runtime/samples/each-blocks-assignment-2/_config.js +++ b/packages/svelte/test/runtime/samples/each-blocks-assignment-2/_config.js @@ -6,8 +6,8 @@ export default { async test({ assert, target, window }) { const button = target.querySelector('button'); - const clickEvent = new window.MouseEvent('click'); - await button.dispatchEvent(clickEvent); + const click_event = new window.MouseEvent('click'); + await button.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/each-blocks-assignment/_config.js b/packages/svelte/test/runtime/samples/each-blocks-assignment/_config.js index 5e22381e9e..11591cf026 100644 --- a/packages/svelte/test/runtime/samples/each-blocks-assignment/_config.js +++ b/packages/svelte/test/runtime/samples/each-blocks-assignment/_config.js @@ -9,10 +9,10 @@ export default { `, async test({ assert, target, window }) { - let [incrementBtn, ...buttons] = target.querySelectorAll('button'); + let [increment_btn, ...buttons] = target.querySelectorAll('button'); - const clickEvent = new window.MouseEvent('click'); - await buttons[0].dispatchEvent(clickEvent); + const click_event = new window.MouseEvent('click'); + await buttons[0].dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -27,7 +27,7 @@ export default { ` ); - await buttons[0].dispatchEvent(clickEvent); + await buttons[0].dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -42,8 +42,8 @@ export default { ` ); - await buttons[2].dispatchEvent(clickEvent); - await buttons[2].dispatchEvent(clickEvent); + await buttons[2].dispatchEvent(click_event); + await buttons[2].dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -58,7 +58,7 @@ export default { ` ); - await incrementBtn.dispatchEvent(clickEvent); + await increment_btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -75,9 +75,9 @@ export default { ` ); - [incrementBtn, ...buttons] = target.querySelectorAll('button'); + [increment_btn, ...buttons] = target.querySelectorAll('button'); - await buttons[3].dispatchEvent(clickEvent); + await buttons[3].dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/event-handler-dynamic-hash/_config.js b/packages/svelte/test/runtime/samples/event-handler-dynamic-hash/_config.js index 44990524fd..db34d02d12 100644 --- a/packages/svelte/test/runtime/samples/event-handler-dynamic-hash/_config.js +++ b/packages/svelte/test/runtime/samples/event-handler-dynamic-hash/_config.js @@ -9,7 +9,7 @@ export default { `, async test({ assert, target, window }) { - const [updateButton1, updateButton2, button] = target.querySelectorAll('button'); + const [update_button1, update_button2, button] = target.querySelectorAll('button'); const event = new window.MouseEvent('click'); let err = ''; @@ -32,7 +32,7 @@ export default { ` ); - await updateButton1.dispatchEvent(event); + await update_button1.dispatchEvent(event); await button.dispatchEvent(event); assert.htmlEqual( target.innerHTML, @@ -46,7 +46,7 @@ export default { ` ); - await updateButton2.dispatchEvent(event); + await update_button2.dispatchEvent(event); await button.dispatchEvent(event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/event-handler-dynamic-invalid/_config.js b/packages/svelte/test/runtime/samples/event-handler-dynamic-invalid/_config.js index cac6d60f2e..6043d2ba28 100644 --- a/packages/svelte/test/runtime/samples/event-handler-dynamic-invalid/_config.js +++ b/packages/svelte/test/runtime/samples/event-handler-dynamic-invalid/_config.js @@ -4,7 +4,7 @@ export default { `, async test({ assert, target, window }) { - const [buttonUndef, buttonNull, buttonInvalid] = target.querySelectorAll('button'); + const [button_undef, button_null, button_invalid] = target.querySelectorAll('button'); const event = new window.MouseEvent('click'); let err = ''; @@ -14,13 +14,13 @@ export default { }); // All three should not throw if proper checking is done in runtime code - await buttonUndef.dispatchEvent(event); + await button_undef.dispatchEvent(event); assert.equal(err, '', err); - await buttonNull.dispatchEvent(event); + await button_null.dispatchEvent(event); assert.equal(err, '', err); - await buttonInvalid.dispatchEvent(event); + await button_invalid.dispatchEvent(event); assert.equal(err, '', err); } }; diff --git a/packages/svelte/test/runtime/samples/event-handler-dynamic/_config.js b/packages/svelte/test/runtime/samples/event-handler-dynamic/_config.js index 44990524fd..db34d02d12 100644 --- a/packages/svelte/test/runtime/samples/event-handler-dynamic/_config.js +++ b/packages/svelte/test/runtime/samples/event-handler-dynamic/_config.js @@ -9,7 +9,7 @@ export default { `, async test({ assert, target, window }) { - const [updateButton1, updateButton2, button] = target.querySelectorAll('button'); + const [update_button1, update_button2, button] = target.querySelectorAll('button'); const event = new window.MouseEvent('click'); let err = ''; @@ -32,7 +32,7 @@ export default { ` ); - await updateButton1.dispatchEvent(event); + await update_button1.dispatchEvent(event); await button.dispatchEvent(event); assert.htmlEqual( target.innerHTML, @@ -46,7 +46,7 @@ export default { ` ); - await updateButton2.dispatchEvent(event); + await update_button2.dispatchEvent(event); await button.dispatchEvent(event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/event-handler-each-modifier/_config.js b/packages/svelte/test/runtime/samples/event-handler-each-modifier/_config.js index e96cd1a987..72da7a8537 100644 --- a/packages/svelte/test/runtime/samples/event-handler-each-modifier/_config.js +++ b/packages/svelte/test/runtime/samples/event-handler-each-modifier/_config.js @@ -10,21 +10,21 @@ export default { assert.equal(component.updated, 4); const [item1, item2] = target.childNodes; - const [item1Btn1, item1Btn2] = item1.querySelectorAll('button'); - const [item2Btn1, item2Btn2] = item2.querySelectorAll('button'); + const [item1_btn1, item1_btn2] = item1.querySelectorAll('button'); + const [item2_btn1, item2_btn2] = item2.querySelectorAll('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await item1Btn1.dispatchEvent(clickEvent); + await item1_btn1.dispatchEvent(click_event); assert.equal(component.getNormalCount(), 1); - await item1Btn2.dispatchEvent(clickEvent); + await item1_btn2.dispatchEvent(click_event); assert.equal(component.getModifierCount(), 1); - await item2Btn1.dispatchEvent(clickEvent); + await item2_btn1.dispatchEvent(click_event); assert.equal(component.getNormalCount(), 2); - await item2Btn2.dispatchEvent(clickEvent); + await item2_btn2.dispatchEvent(click_event); assert.equal(component.getModifierCount(), 2); } }; diff --git a/packages/svelte/test/runtime/samples/flush-before-bindings/_config.js b/packages/svelte/test/runtime/samples/flush-before-bindings/_config.js index 4f20299771..6848fbd50c 100644 --- a/packages/svelte/test/runtime/samples/flush-before-bindings/_config.js +++ b/packages/svelte/test/runtime/samples/flush-before-bindings/_config.js @@ -11,11 +11,11 @@ export default { `, test({ assert, component }) { - const visibleThings = component.visibleThings; - assert.deepEqual(visibleThings, ['first thing', 'second thing']); + const visible_things = component.visibleThings; + assert.deepEqual(visible_things, ['first thing', 'second thing']); const snapshots = component.snapshots; - assert.deepEqual(snapshots, [visibleThings]); + assert.deepEqual(snapshots, [visible_things]); // TODO minimise the number of recomputations during oncreate // assert.equal(counter.count, 1); diff --git a/packages/svelte/test/runtime/samples/fragment-trailing-whitespace/_config.js b/packages/svelte/test/runtime/samples/fragment-trailing-whitespace/_config.js index d2c59af0de..142cab9229 100644 --- a/packages/svelte/test/runtime/samples/fragment-trailing-whitespace/_config.js +++ b/packages/svelte/test/runtime/samples/fragment-trailing-whitespace/_config.js @@ -7,10 +7,14 @@ export default { }, async test({ assert, target }) { - const firstSpanList = target.children[0]; - assert.htmlEqualWithOptions(firstSpanList.innerHTML, expected, { withoutNormalizeHtml: true }); + const first_span_list = target.children[0]; + assert.htmlEqualWithOptions(first_span_list.innerHTML, expected, { + withoutNormalizeHtml: true + }); - const secondSpanList = target.children[1]; - assert.htmlEqualWithOptions(secondSpanList.innerHTML, expected, { withoutNormalizeHtml: true }); + const second_span_list = target.children[1]; + assert.htmlEqualWithOptions(second_span_list.innerHTML, expected, { + withoutNormalizeHtml: true + }); } }; diff --git a/packages/svelte/test/runtime/samples/if-block-else-update/_config.js b/packages/svelte/test/runtime/samples/if-block-else-update/_config.js index 3ba36906ad..cbbf65aa2c 100644 --- a/packages/svelte/test/runtime/samples/if-block-else-update/_config.js +++ b/packages/svelte/test/runtime/samples/if-block-else-update/_config.js @@ -2,9 +2,9 @@ export default { async test({ assert, target, window }) { const [btn1, btn2] = target.querySelectorAll('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn2.dispatchEvent(clickEvent); + await btn2.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, ` @@ -17,7 +17,7 @@ export default { ` ); - await btn1.dispatchEvent(clickEvent); + await btn1.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, ` @@ -30,7 +30,7 @@ export default { ` ); - await btn2.dispatchEvent(clickEvent); + await btn2.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, ` @@ -43,7 +43,7 @@ export default { ` ); - await btn1.dispatchEvent(clickEvent); + await btn1.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, ` diff --git a/packages/svelte/test/runtime/samples/nbsp-div/_config.js b/packages/svelte/test/runtime/samples/nbsp-div/_config.js index 5489360934..d79db8ee81 100644 --- a/packages/svelte/test/runtime/samples/nbsp-div/_config.js +++ b/packages/svelte/test/runtime/samples/nbsp-div/_config.js @@ -4,14 +4,14 @@ export default {
 hello   hello
`, test({ assert, target }) { - const divList = target.querySelectorAll('div'); - assert.equal(divList[0].textContent.charCodeAt(0), 160); - assert.equal(divList[1].textContent.charCodeAt(0), 160); - assert.equal(divList[1].textContent.charCodeAt(6), 160); - assert.equal(divList[1].textContent.charCodeAt(7), 160); - assert.equal(divList[2].textContent.charCodeAt(0), 160); - assert.equal(divList[2].textContent.charCodeAt(6), 160); - assert.equal(divList[2].textContent.charCodeAt(7), 32); //normal space - assert.equal(divList[2].textContent.charCodeAt(8), 160); + const div_list = target.querySelectorAll('div'); + assert.equal(div_list[0].textContent.charCodeAt(0), 160); + assert.equal(div_list[1].textContent.charCodeAt(0), 160); + assert.equal(div_list[1].textContent.charCodeAt(6), 160); + assert.equal(div_list[1].textContent.charCodeAt(7), 160); + assert.equal(div_list[2].textContent.charCodeAt(0), 160); + assert.equal(div_list[2].textContent.charCodeAt(6), 160); + assert.equal(div_list[2].textContent.charCodeAt(7), 32); //normal space + assert.equal(div_list[2].textContent.charCodeAt(8), 160); } }; diff --git a/packages/svelte/test/runtime/samples/noscript-removal/_config.js b/packages/svelte/test/runtime/samples/noscript-removal/_config.js index a60a4f87b0..69dea81cbd 100644 --- a/packages/svelte/test/runtime/samples/noscript-removal/_config.js +++ b/packages/svelte/test/runtime/samples/noscript-removal/_config.js @@ -14,7 +14,7 @@ export default { // it's okay not to remove the node during hydration // will not be seen by user anyway - removeNoScript(target); + remove_no_script(target); assert.htmlEqual( target.innerHTML, @@ -26,7 +26,7 @@ export default { } }; -function removeNoScript(target) { +function remove_no_script(target) { target.querySelectorAll('noscript').forEach((elem) => { elem.parentNode.removeChild(elem); }); diff --git a/packages/svelte/test/runtime/samples/props-reactive-slot/_config.js b/packages/svelte/test/runtime/samples/props-reactive-slot/_config.js index 6129866605..47effe0d82 100644 --- a/packages/svelte/test/runtime/samples/props-reactive-slot/_config.js +++ b/packages/svelte/test/runtime/samples/props-reactive-slot/_config.js @@ -6,9 +6,9 @@ export default { async test({ assert, target, window }) { const btn = target.querySelector('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/raw-mustache-as-root/_config.js b/packages/svelte/test/runtime/samples/raw-mustache-as-root/_config.js index a38c0b1c81..2f54fd6ab9 100644 --- a/packages/svelte/test/runtime/samples/raw-mustache-as-root/_config.js +++ b/packages/svelte/test/runtime/samples/raw-mustache-as-root/_config.js @@ -6,9 +6,9 @@ export default { `, async test({ assert, target, window }) { const btn = target.querySelector('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -19,7 +19,7 @@ export default { ` ); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/raw-mustache-inside-head/_config.js b/packages/svelte/test/runtime/samples/raw-mustache-inside-head/_config.js index f478d186be..eb0df14136 100644 --- a/packages/svelte/test/runtime/samples/raw-mustache-inside-head/_config.js +++ b/packages/svelte/test/runtime/samples/raw-mustache-inside-head/_config.js @@ -1,7 +1,7 @@ export default { async test({ assert, target, window }) { const btn = target.querySelector('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); assert.equal( window.document.head.innerHTML.includes( @@ -10,7 +10,7 @@ export default { true ); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.equal( window.document.head.innerHTML.includes( @@ -19,7 +19,7 @@ export default { true ); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.equal( window.document.head.innerHTML.includes( diff --git a/packages/svelte/test/runtime/samples/raw-mustache-inside-slot/_config.js b/packages/svelte/test/runtime/samples/raw-mustache-inside-slot/_config.js index a38c0b1c81..2f54fd6ab9 100644 --- a/packages/svelte/test/runtime/samples/raw-mustache-inside-slot/_config.js +++ b/packages/svelte/test/runtime/samples/raw-mustache-inside-slot/_config.js @@ -6,9 +6,9 @@ export default { `, async test({ assert, target, window }) { const btn = target.querySelector('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -19,7 +19,7 @@ export default { ` ); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/reactive-import-statement/_config.js b/packages/svelte/test/runtime/samples/reactive-import-statement/_config.js index 1160919839..59856dca94 100644 --- a/packages/svelte/test/runtime/samples/reactive-import-statement/_config.js +++ b/packages/svelte/test/runtime/samples/reactive-import-statement/_config.js @@ -13,9 +13,9 @@ export default { }, async test({ assert, target, window }) { const btn = target.querySelector('button'); - const clickEvent = new window.MouseEvent('click'); + const click_event = new window.MouseEvent('click'); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, @@ -28,7 +28,7 @@ export default { ` ); - await btn.dispatchEvent(clickEvent); + await btn.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/spread-element-input-value/_config.js b/packages/svelte/test/runtime/samples/spread-element-input-value/_config.js index 64ae0fe469..c09bf7e7fa 100644 --- a/packages/svelte/test/runtime/samples/spread-element-input-value/_config.js +++ b/packages/svelte/test/runtime/samples/spread-element-input-value/_config.js @@ -11,8 +11,8 @@ export default { // and we determine if svelte does not set the `input.value` again by // spying on the setter of `input.value` - const spy1 = spyOnValueSetter(input1, input1.value); - const spy2 = spyOnValueSetter(input2, input2.value); + const spy1 = spy_on_value_setter(input1, input1.value); + const spy2 = spy_on_value_setter(input2, input2.value); const event = new window.Event('input'); @@ -38,25 +38,25 @@ export default { } }; -function spyOnValueSetter(input, initialValue) { - let value = initialValue; - let isSet = false; +function spy_on_value_setter(input, initial_value) { + let value = initial_value; + let is_set = false; Object.defineProperty(input, 'value', { get() { return value; }, set(_value) { value = _value; - isSet = true; + is_set = true; } }); return { isSetCalled() { - return isSet; + return is_set; }, reset() { - isSet = false; + is_set = false; } }; } diff --git a/packages/svelte/test/runtime/samples/spread-element-input-value/utils.js b/packages/svelte/test/runtime/samples/spread-element-input-value/utils.js index ee941bda55..2fc48fe6ae 100644 --- a/packages/svelte/test/runtime/samples/spread-element-input-value/utils.js +++ b/packages/svelte/test/runtime/samples/spread-element-input-value/utils.js @@ -1,6 +1,6 @@ -export function omit(obj, ...keysToOmit) { +export function omit(obj, ...keys_to_omit) { return Object.keys(obj).reduce((acc, key) => { - if (keysToOmit.indexOf(key) === -1) acc[key] = obj[key]; + if (keys_to_omit.indexOf(key) === -1) acc[key] = obj[key]; return acc; }, {}); } diff --git a/packages/svelte/test/runtime/samples/store-auto-subscribe-event-callback/_config.js b/packages/svelte/test/runtime/samples/store-auto-subscribe-event-callback/_config.js index 58b1740f0f..ba0556644d 100644 --- a/packages/svelte/test/runtime/samples/store-auto-subscribe-event-callback/_config.js +++ b/packages/svelte/test/runtime/samples/store-auto-subscribe-event-callback/_config.js @@ -9,9 +9,9 @@ export default { const input = target.querySelector('input'); input.value = 'foo'; - const inputEvent = new window.InputEvent('input'); + const input_event = new window.InputEvent('input'); - await input.dispatchEvent(inputEvent); + await input.dispatchEvent(input_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/store-invalidation-while-update-1/_config.js b/packages/svelte/test/runtime/samples/store-invalidation-while-update-1/_config.js index eaa5b3c92b..00e41c98d7 100644 --- a/packages/svelte/test/runtime/samples/store-invalidation-while-update-1/_config.js +++ b/packages/svelte/test/runtime/samples/store-invalidation-while-update-1/_config.js @@ -16,11 +16,11 @@ export default { const input = target.querySelector('input'); const button = target.querySelector('button'); - const inputEvent = new window.InputEvent('input'); - const clickEvent = new window.MouseEvent('click'); + const input_event = new window.InputEvent('input'); + const click_event = new window.MouseEvent('click'); input.value = 'foo'; - await input.dispatchEvent(inputEvent); + await input.dispatchEvent(input_event); assert.htmlEqual( target.innerHTML, @@ -32,7 +32,7 @@ export default { ` ); - await button.dispatchEvent(clickEvent); + await button.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, ` @@ -44,7 +44,7 @@ export default { ); input.value = 'bar'; - await input.dispatchEvent(inputEvent); + await input.dispatchEvent(input_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/store-invalidation-while-update-2/_config.js b/packages/svelte/test/runtime/samples/store-invalidation-while-update-2/_config.js index 8c318b0faf..882eb46931 100644 --- a/packages/svelte/test/runtime/samples/store-invalidation-while-update-2/_config.js +++ b/packages/svelte/test/runtime/samples/store-invalidation-while-update-2/_config.js @@ -16,11 +16,11 @@ export default { const input = target.querySelector('input'); const button = target.querySelector('button'); - const inputEvent = new window.InputEvent('input'); - const clickEvent = new window.MouseEvent('click'); + const input_event = new window.InputEvent('input'); + const click_event = new window.MouseEvent('click'); input.value = 'foo'; - await input.dispatchEvent(inputEvent); + await input.dispatchEvent(input_event); assert.htmlEqual( target.innerHTML, @@ -32,7 +32,7 @@ export default { ` ); - await button.dispatchEvent(clickEvent); + await button.dispatchEvent(click_event); assert.htmlEqual( target.innerHTML, ` @@ -44,7 +44,7 @@ export default { ); input.value = 'bar'; - await input.dispatchEvent(inputEvent); + await input.dispatchEvent(input_event); assert.htmlEqual( target.innerHTML, diff --git a/packages/svelte/test/runtime/samples/store-resubscribe-export/_config.js b/packages/svelte/test/runtime/samples/store-resubscribe-export/_config.js index b4615a27d1..44c0fb2403 100644 --- a/packages/svelte/test/runtime/samples/store-resubscribe-export/_config.js +++ b/packages/svelte/test/runtime/samples/store-resubscribe-export/_config.js @@ -1,11 +1,11 @@ -let unsubscribeCalled = false; +let unsubscribe_called = false; -const fakeStore = (val) => ({ +const fake_store = (val) => ({ subscribe: (cb) => { cb(val); return { unsubscribe: () => { - unsubscribeCalled = true; + unsubscribe_called = true; } }; } @@ -13,17 +13,17 @@ const fakeStore = (val) => ({ export default { get props() { - return { foo: fakeStore(1) }; + return { foo: fake_store(1) }; }, html: `

1

`, async test({ assert, component, target }) { - component.foo = fakeStore(5); + component.foo = fake_store(5); assert.htmlEqual(target.innerHTML, '

5

'); - assert.ok(unsubscribeCalled); + assert.ok(unsubscribe_called); } }; diff --git a/packages/svelte/test/runtime/samples/svg-foreignobject-namespace/_config.js b/packages/svelte/test/runtime/samples/svg-foreignobject-namespace/_config.js index 950e35e79d..05a7d7d8ec 100644 --- a/packages/svelte/test/runtime/samples/svg-foreignobject-namespace/_config.js +++ b/packages/svelte/test/runtime/samples/svg-foreignobject-namespace/_config.js @@ -8,8 +8,8 @@ export default { `, test({ assert, target }) { - const foreignObject = target.querySelector('foreignObject'); - assert.equal(foreignObject.namespaceURI, 'http://www.w3.org/2000/svg'); + const foreign_object = target.querySelector('foreignObject'); + assert.equal(foreign_object.namespaceURI, 'http://www.w3.org/2000/svg'); const p = target.querySelector('p'); assert.equal(p.namespaceURI, 'http://www.w3.org/1999/xhtml'); diff --git a/packages/svelte/test/runtime/samples/textarea-content/_config.js b/packages/svelte/test/runtime/samples/textarea-content/_config.js index 7d4f8f9493..fd04d5acbe 100644 --- a/packages/svelte/test/runtime/samples/textarea-content/_config.js +++ b/packages/svelte/test/runtime/samples/textarea-content/_config.js @@ -18,50 +18,53 @@ multiple leading newlines
{ it_fn(dir, async () => { const { test } = await import(`./samples/${dir}/test.js`); - const inputFile = path.resolve(`${__dirname}/samples/${dir}/input.svelte`); - const outputName = '_actual'; - const outputBase = path.resolve(`${__dirname}/samples/${dir}/${outputName}`); + const input_file = path.resolve(`${__dirname}/samples/${dir}/input.svelte`); + const output_name = '_actual'; + const output_base = path.resolve(`${__dirname}/samples/${dir}/${output_name}`); - const inputCode = fs.readFileSync(inputFile, 'utf-8'); + const input_code = fs.readFileSync(input_file, 'utf-8'); const input = { - code: inputCode, - locate: getLocator(inputCode), - locate_1: getLocator(inputCode, { offsetLine: 1 }) + code: input_code, + locate: getLocator(input_code), + locate_1: getLocator(input_code, { offsetLine: 1 }) }; const preprocessed = await svelte.preprocess( input.code, @@ -46,8 +46,8 @@ describe('sourcemaps', async () => { filename: 'input.svelte', // filenames for sourcemaps sourcemap: preprocessed.map, - outputFilename: `${outputName}.js`, - cssOutputFilename: `${outputName}.css`, + outputFilename: `${output_name}.js`, + cssOutputFilename: `${output_name}.css`, ...(config.compile_options || {}) }); @@ -55,22 +55,25 @@ describe('sourcemaps', async () => { match.replace(/\d/g, 'x') ); - fs.writeFileSync(`${outputBase}.svelte`, preprocessed.code); + fs.writeFileSync(`${output_base}.svelte`, preprocessed.code); if (preprocessed.map) { fs.writeFileSync( - `${outputBase}.svelte.map`, + `${output_base}.svelte.map`, // TODO encode mappings for output - svelte.preprocess returns decoded mappings JSON.stringify(preprocessed.map, null, 2) ); } - fs.writeFileSync(`${outputBase}.js`, `${js.code}\n//# sourceMappingURL=${outputName}.js.map`); - fs.writeFileSync(`${outputBase}.js.map`, JSON.stringify(js.map, null, 2)); + fs.writeFileSync( + `${output_base}.js`, + `${js.code}\n//# sourceMappingURL=${output_name}.js.map` + ); + fs.writeFileSync(`${output_base}.js.map`, JSON.stringify(js.map, null, 2)); if (css.code) { fs.writeFileSync( - `${outputBase}.css`, - `${css.code}\n/*# sourceMappingURL=${outputName}.css.map */` + `${output_base}.css`, + `${css.code}\n/*# sourceMappingURL=${output_name}.css.map */` ); - fs.writeFileSync(`${outputBase}.css.map`, JSON.stringify(css.map, null, ' ')); + fs.writeFileSync(`${output_base}.css.map`, JSON.stringify(css.map, null, ' ')); } if (js.map) { diff --git a/packages/svelte/test/stats/stats.test.js b/packages/svelte/test/stats/stats.test.js index 4abb771c4c..bebd2b7ebd 100644 --- a/packages/svelte/test/stats/stats.test.js +++ b/packages/svelte/test/stats/stats.test.js @@ -17,7 +17,7 @@ describe('stats', () => { const filename = `${__dirname}/samples/${dir}/input.svelte`; const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, ''); - const expectedError = try_load_json(`${__dirname}/samples/${dir}/error.json`); + const expected_error = try_load_json(`${__dirname}/samples/${dir}/error.json`); let result; let error; @@ -29,19 +29,19 @@ describe('stats', () => { error = e; } - if (error || expectedError) { - if (error && !expectedError) { + if (error || expected_error) { + if (error && !expected_error) { throw error; } - if (expectedError && !error) { - throw new Error(`Expected an error: ${expectedError.message}`); + if (expected_error && !error) { + throw new Error(`Expected an error: ${expected_error.message}`); } - assert.equal(error.message, expectedError.message); - assert.deepEqual(error.start, expectedError.start); - assert.deepEqual(error.end, expectedError.end); - assert.equal(error.pos, expectedError.pos); + assert.equal(error.message, expected_error.message); + assert.deepEqual(error.start, expected_error.start); + assert.deepEqual(error.end, expected_error.end); + assert.equal(error.pos, expected_error.pos); } }); }); diff --git a/packages/svelte/test/store/store.test.js b/packages/svelte/test/store/store.test.js index 1f7d90e50c..82b284de00 100644 --- a/packages/svelte/test/store/store.test.js +++ b/packages/svelte/test/store/store.test.js @@ -293,7 +293,7 @@ describe('store', () => { it('passes optional set and update functions', () => { const number = writable(1); - const evensAndSquaresOf4 = derived( + const evens_and_squares_of4 = derived( number, (n, set, update) => { if (n % 2 === 0) set(n); @@ -304,7 +304,7 @@ describe('store', () => { const values = []; - const unsubscribe = evensAndSquaresOf4.subscribe((value) => { + const unsubscribe = evens_and_squares_of4.subscribe((value) => { values.push(value); }); @@ -542,18 +542,18 @@ describe('store', () => { describe('readonly', () => { it('makes a store readonly', () => { - const writableStore = writable(1); - const readableStore = readonly(writableStore); + const writable_store = writable(1); + const readable_store = readonly(writable_store); - assert.equal(get(readableStore), get(writableStore)); + assert.equal(get(readable_store), get(writable_store)); - writableStore.set(2); + writable_store.set(2); - assert.equal(get(readableStore), 2); - assert.equal(get(readableStore), get(writableStore)); + assert.equal(get(readable_store), 2); + assert.equal(get(readable_store), get(writable_store)); // @ts-ignore - assert.throws(() => readableStore.set(3)); + assert.throws(() => readable_store.set(3)); }); }); }); diff --git a/packages/svelte/test/tsconfig.json b/packages/svelte/test/tsconfig.json index c5f45fe821..71b9d4c6dd 100644 --- a/packages/svelte/test/tsconfig.json +++ b/packages/svelte/test/tsconfig.json @@ -1,15 +1,10 @@ { "extends": "../tsconfig.json", - "include": ["."], "exclude": ["./**/_output/**/*"], "compilerOptions": { "allowJs": true, "checkJs": true, - "noEmit": true, - "paths": { - "svelte": [".."], - "svelte/*": ["../*"] - } + "noEmit": true } } diff --git a/packages/svelte/test/vars/vars.test.js b/packages/svelte/test/vars/vars.test.js index 9e786377ac..3cbcb964f1 100644 --- a/packages/svelte/test/vars/vars.test.js +++ b/packages/svelte/test/vars/vars.test.js @@ -20,7 +20,7 @@ describe('vars', () => { .trimEnd() .replace(/\r/g, ''); - const expectedError = try_load_json(`${__dirname}/samples/${dir}/error.json`); + const expected_error = try_load_json(`${__dirname}/samples/${dir}/error.json`); /** * @type {{ options: any, test: (assert: typeof import('vitest').assert, vars: any[]) => void }}} @@ -31,19 +31,19 @@ describe('vars', () => { const { vars } = compile(input, { ...options, generate }); test(assert, vars); } catch (error) { - if (expectedError) { - assert.equal(error.message, expectedError.message); - assert.deepEqual(error.start, expectedError.start); - assert.deepEqual(error.end, expectedError.end); - assert.equal(error.pos, expectedError.pos); + if (expected_error) { + assert.equal(error.message, expected_error.message); + assert.deepEqual(error.start, expected_error.start); + assert.deepEqual(error.end, expected_error.end); + assert.equal(error.pos, expected_error.pos); return; } else { throw error; } } - if (expectedError) { - assert.fail(`Expected an error: ${JSON.stringify(expectedError)}`); + if (expected_error) { + assert.fail(`Expected an error: ${JSON.stringify(expected_error)}`); } }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 117a8e0338..b0e4a0553f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,6 +111,9 @@ importers: esbuild: specifier: ^0.18.11 version: 0.18.11 + eslint-plugin-lube: + specifier: ^0.1.7 + version: 0.1.7 happy-dom: specifier: ^9.20.3 version: 9.20.3 @@ -3932,6 +3935,12 @@ packages: eslint: 8.47.0 dev: true + /eslint-plugin-lube@0.1.7: + resolution: {integrity: sha512-jqeRZAG3vQWZR6Hue2tSx4bQUfpDYqeSOFf3MlqpUycb5q6av1bhnmfDkxHgsLQoK4Pt7H+puI0cYc/iEvFwfw==} + dependencies: + '@types/estree': 1.0.1 + dev: true + /eslint-plugin-svelte@2.32.2(eslint@8.44.0)(svelte@packages+svelte): resolution: {integrity: sha512-Jgbop2fNZsoxxkklZAIbDNhwAPynvnCtUXLsEC6O2qax7N/pfe2cNqT0ZoBbubXKJitQQDEyVDQ1rZs4ZWcrTA==} engines: {node: ^14.17.0 || >=16.0.0}