Skip to content
Merged
Prev Previous commit
Next Next commit
fix strict typescript unused checks
  • Loading branch information
43081j committed Jun 5, 2019
commit 1ea7dd12535f9e66955f2388559b6079ac929a11
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/_actual.js
**/expected.js
test/*/samples/*/output.js
20 changes: 10 additions & 10 deletions src/compiler/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down Expand Up @@ -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: '' });
Expand All @@ -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({
Expand All @@ -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, '');
Expand Down Expand Up @@ -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}$`;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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}✂]`);
}
}

Expand Down Expand Up @@ -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}✂]`);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/compile/nodes/shared/Expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const precedence: Record<string, (node?: Node) => 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`;
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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}✂]`;
}
}
2 changes: 1 addition & 1 deletion src/compiler/compile/nodes/shared/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/render-dom/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/compile/render-dom/wrappers/Element/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const events = [

{
event_names: ['resize'],
filter: (node: Element, name: string) =>
filter: (_node: Element, name: string) =>
dimensions.test(name)
},

Expand Down Expand Up @@ -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;
Expand All @@ -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`
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/compile/render-dom/wrappers/IfBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/utils/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function create_scopes(expression: Node) {
},
});

scope.declarations.forEach((node, name) => {
scope.declarations.forEach((_node, name) => {
globals.delete(name);
});

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/animate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);`
};
}
2 changes: 1 addition & 1 deletion src/runtime/internal/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ if (typeof HTMLElement !== 'undefined') {
}
}

attributeChangedCallback(attr, oldValue, newValue) {
attributeChangedCallback(attr, _oldValue, newValue) {
this[attr] = newValue;
}

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function element<K extends keyof HTMLElementTagNameMap>(name: K) {
}

export function object_without_properties<T, K extends keyof T>(obj: T, exclude: K[]) {
const target: Pick<T, Exclude<keyof T, K>> = {};
// eslint-disable-next-line @typescript-eslint/no-object-literal-type-assertion
const target = {} as Pick<T, Exclude<keyof T, K>>;
for (const k in obj) {
if (
Object.prototype.hasOwnProperty.call(obj, k)
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/transition/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
`
Expand Down