From 1ea7dd12535f9e66955f2388559b6079ac929a11 Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Wed, 5 Jun 2019 23:00:08 +0100 Subject: [PATCH] fix strict typescript unused checks --- .eslintignore | 1 + src/compiler/compile/Component.ts | 20 +++++++++---------- .../compile/nodes/shared/Expression.ts | 6 +++--- src/compiler/compile/nodes/shared/Node.ts | 2 +- src/compiler/compile/render-dom/Block.ts | 2 +- .../render-dom/wrappers/Element/index.ts | 6 +++--- .../compile/render-dom/wrappers/IfBlock.ts | 8 ++++---- src/compiler/compile/utils/scope.ts | 2 +- src/runtime/animate/index.ts | 2 +- src/runtime/internal/Component.ts | 2 +- src/runtime/internal/dom.ts | 3 ++- src/runtime/transition/index.ts | 2 +- 12 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.eslintignore b/.eslintignore index 241306d23c..97a855e951 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ **/_actual.js **/expected.js +test/*/samples/*/output.js diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 29b51297d3..352154bc73 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -363,7 +363,7 @@ export default class Component { result = result .replace(/__svelte:self__/g, this.name) - .replace(compile_options.generate === 'ssr' ? /(@+|#+)(\w*(?:-\w*)?)/g : /(@+)(\w*(?:-\w*)?)/g, (match: string, sigil: string, name: string) => { + .replace(compile_options.generate === 'ssr' ? /(@+|#+)(\w*(?:-\w*)?)/g : /(@+)(\w*(?:-\w*)?)/g, (_match: string, sigil: string, name: string) => { if (sigil === '@') { if (internal_exports.has(name)) { if (compile_options.dev && internal_exports.has(`${name}Dev`)) name = `${name}Dev`; @@ -398,7 +398,7 @@ export default class Component { this.source ); - const parts = module.split('✂]'); + const parts = module.split('✂]'); const final_chunk = parts.pop(); const compiled = new Bundle({ separator: '' }); @@ -411,7 +411,7 @@ export default class Component { const { filename } = compile_options; - // special case — the source file doesn't actually get used anywhere. we need + // special case — the source file doesn't actually get used anywhere. we need // to add an empty file to populate map.sources and map.sourcesContent if (!parts.length) { compiled.addSource({ @@ -420,7 +420,7 @@ export default class Component { }); } - const pattern = /\[✂(\d+)-(\d+)$/; + const pattern = /\[✂(\d+)-(\d+)$/; parts.forEach((str: string) => { const chunk = str.replace(pattern, ''); @@ -494,7 +494,7 @@ export default class Component { reserved.forEach(add); internal_exports.forEach(add); - this.var_lookup.forEach((value, key) => add(key)); + this.var_lookup.forEach((_value, key) => add(key)); return (name: string) => { if (test) name = `${name}$`; @@ -644,7 +644,7 @@ export default class Component { script.content.body.forEach((node) => { if (this.hoistable_nodes.has(node) || this.reactive_declaration_nodes.has(node)) { - if (a !== b) result += `[✂${a}-${b}✂]`; + if (a !== b) result += `[✂${a}-${b}✂]`; a = node.end; } @@ -656,7 +656,7 @@ export default class Component { b = script.content.end; while (/\s/.test(this.source[b - 1])) b -= 1; - if (a < b) result += `[✂${a}-${b}✂]`; + if (a < b) result += `[✂${a}-${b}✂]`; return result || null; } @@ -761,7 +761,7 @@ export default class Component { this.node_for_declaration.set(name, node); }); - globals.forEach((node, name) => { + globals.forEach((_node, name) => { if (this.var_lookup.has(name)) return; if (this.injected_reactive_declaration_vars.has(name)) { @@ -1107,7 +1107,7 @@ export default class Component { }); hoistable_nodes.add(node); - this.fully_hoisted.push(`[✂${node.start}-${node.end}✂]`); + this.fully_hoisted.push(`[✂${node.start}-${node.end}✂]`); } } @@ -1199,7 +1199,7 @@ export default class Component { remove_indentation(this.code, node); - this.fully_hoisted.push(`[✂${node.start}-${node.end}✂]`); + this.fully_hoisted.push(`[✂${node.start}-${node.end}✂]`); } } } diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts index 421c2c8972..92fa418e07 100644 --- a/src/compiler/compile/nodes/shared/Expression.ts +++ b/src/compiler/compile/nodes/shared/Expression.ts @@ -64,7 +64,7 @@ const precedence: Record number> = { type Owner = Wrapper | INode; -function get_function_name(node, parent) { +function get_function_name(_node, parent) { if (parent.type === 'EventHandler') { return `${parent.name}_handler`; } @@ -374,7 +374,7 @@ export default class Expression { throw new Error(`Well that's odd`); } - // TOOD optimisation — if this is an event handler, + // TOOD optimisation — if this is an event handler, // the return value doesn't matter } @@ -513,6 +513,6 @@ export default class Expression { }); } - return this.rendered = `[✂${this.node.start}-${this.node.end}✂]`; + return this.rendered = `[✂${this.node.start}-${this.node.end}✂]`; } } diff --git a/src/compiler/compile/nodes/shared/Node.ts b/src/compiler/compile/nodes/shared/Node.ts index 8fa0ec0c97..7435f1eab8 100644 --- a/src/compiler/compile/nodes/shared/Node.ts +++ b/src/compiler/compile/nodes/shared/Node.ts @@ -17,7 +17,7 @@ export default class Node { var: string; attributes: Attribute[]; - constructor(component: Component, parent, scope, info: any) { + constructor(component: Component, parent, _scope, info: any) { this.start = info.start; this.end = info.end; this.type = info.type; diff --git a/src/compiler/compile/render-dom/Block.ts b/src/compiler/compile/render-dom/Block.ts index 25702e3bc7..0bcc3ff7ed 100644 --- a/src/compiler/compile/render-dom/Block.ts +++ b/src/compiler/compile/render-dom/Block.ts @@ -371,7 +371,7 @@ export default class Block { return { ${properties} }; - `.replace(/(#+)(\w*)/g, (match: string, sigil: string, name: string) => { + `.replace(/(#+)(\w*)/g, (_match: string, sigil: string, name: string) => { return sigil === '#' ? this.alias(name) : sigil.slice(1) + name; }); } diff --git a/src/compiler/compile/render-dom/wrappers/Element/index.ts b/src/compiler/compile/render-dom/wrappers/Element/index.ts index abb13dde77..03ba41c1ad 100644 --- a/src/compiler/compile/render-dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render-dom/wrappers/Element/index.ts @@ -41,7 +41,7 @@ const events = [ { event_names: ['resize'], - filter: (node: Element, name: string) => + filter: (_node: Element, name: string) => dimensions.test(name) }, @@ -440,7 +440,7 @@ export default class ElementWrapper extends Wrapper { binding.render(block, lock); }); - // media bindings — awkward special case. The native timeupdate events + // media bindings — awkward special case. The native timeupdate events // fire too infrequently, so we need to take matters into our // own hands let animation_frame; @@ -453,7 +453,7 @@ export default class ElementWrapper extends Wrapper { let callee; - // TODO dry this out — similar code for event handlers and component bindings + // TODO dry this out — similar code for event handlers and component bindings if (has_local_function) { // need to create a block-local function that calls an instance-level function block.builders.init.add_block(deindent` diff --git a/src/compiler/compile/render-dom/wrappers/IfBlock.ts b/src/compiler/compile/render-dom/wrappers/IfBlock.ts index 1eb3253f27..cfa28033fe 100644 --- a/src/compiler/compile/render-dom/wrappers/IfBlock.ts +++ b/src/compiler/compile/render-dom/wrappers/IfBlock.ts @@ -201,7 +201,7 @@ export default class IfBlockWrapper extends Wrapper { render_compound( block: Block, parent_node: string, - parent_nodes: string, + _parent_nodes: string, dynamic, { name, anchor, has_else, if_name, has_transitions }, detaching @@ -265,7 +265,7 @@ export default class IfBlockWrapper extends Wrapper { render_compound_with_outros( block: Block, parent_node: string, - parent_nodes: string, + _parent_nodes: string, dynamic, { name, anchor, has_else, has_transitions }, detaching @@ -386,7 +386,7 @@ export default class IfBlockWrapper extends Wrapper { render_simple( block: Block, parent_node: string, - parent_nodes: string, + _parent_nodes: string, dynamic, { name, anchor, if_name, has_transitions }, detaching @@ -429,7 +429,7 @@ export default class IfBlockWrapper extends Wrapper { } `; - // no `p()` here — we don't want to update outroing nodes, + // no `p()` here — we don't want to update outroing nodes, // as that will typically result in glitching const exit = branch.block.has_outro_method ? deindent` diff --git a/src/compiler/compile/utils/scope.ts b/src/compiler/compile/utils/scope.ts index 45a355d1a1..ad198da037 100644 --- a/src/compiler/compile/utils/scope.ts +++ b/src/compiler/compile/utils/scope.ts @@ -132,7 +132,7 @@ export function create_scopes(expression: Node) { }, }); - scope.declarations.forEach((node, name) => { + scope.declarations.forEach((_node, name) => { globals.delete(name); }); diff --git a/src/runtime/animate/index.ts b/src/runtime/animate/index.ts index 0518417ab8..d00d23c98d 100644 --- a/src/runtime/animate/index.ts +++ b/src/runtime/animate/index.ts @@ -35,6 +35,6 @@ export function flip(node: Element, animation: { from: DOMRect; to: DOMRect }, p delay, duration: is_function(duration) ? duration(d) : duration, easing, - css: (t, u) => `transform: ${transform} translate(${u * dx}px, ${u * dy}px);` + css: (_t, u) => `transform: ${transform} translate(${u * dx}px, ${u * dy}px);` }; } diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index eb2b6208cf..7624d5c829 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -148,7 +148,7 @@ if (typeof HTMLElement !== 'undefined') { } } - attributeChangedCallback(attr, oldValue, newValue) { + attributeChangedCallback(attr, _oldValue, newValue) { this[attr] = newValue; } diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 2cd7090b23..f65d07117c 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -39,7 +39,8 @@ export function element(name: K) { } export function object_without_properties(obj: T, exclude: K[]) { - const target: Pick> = {}; + // eslint-disable-next-line @typescript-eslint/no-object-literal-type-assertion + const target = {} as Pick>; for (const k in obj) { if ( Object.prototype.hasOwnProperty.call(obj, k) diff --git a/src/runtime/transition/index.ts b/src/runtime/transition/index.ts index 7fe5153e44..3aaa19ef3b 100644 --- a/src/runtime/transition/index.ts +++ b/src/runtime/transition/index.ts @@ -124,7 +124,7 @@ export function scale(node: Element, { delay, duration, easing, - css: (t, u) => ` + css: (_t, u) => ` transform: ${transform} scale(${1 - (sd * u)}); opacity: ${target_opacity - (od * u)} `