pull/3539/head
Richard Harris 6 years ago
parent bc066d3562
commit 7efcca82cc

@ -22,14 +22,7 @@ module.exports = {
'arrow-spacing': 2,
'no-inner-declarations': 0,
'require-atomic-updates': 'off',
'@typescript-eslint/indent': [
'error',
'tab',
{
SwitchCase: 1,
ignoredNodes: ['TemplateLiteral']
}
],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/array-type': ['error', 'array-simple'],

@ -71,8 +71,8 @@ export default class Component {
hoistable_nodes: Set<Node> = new Set();
node_for_declaration: Map<string, Node> = new Map();
partly_hoisted: (Node | Node[])[] = [];
fully_hoisted: (Node | Node[])[] = [];
partly_hoisted: Array<(Node | Node[])> = [];
fully_hoisted: Array<(Node | Node[])> = [];
reactive_declarations: Array<{
assignees: Set<string>;
dependencies: Set<string>;

@ -62,7 +62,7 @@ function esm(
imported: { type: 'Identifier', name: h.name }
})),
source: { type: 'Literal', value: internal_path }
}
};
const internal_globals = globals.length > 0 && {
type: 'VariableDeclaration',

@ -1,4 +1,4 @@
export type CssNode = {
export interface CssNode {
type: string;
start: number;
end: number;

@ -37,7 +37,7 @@ function unpack_destructuring(contexts: Context[], node: Node, modifier: (node:
const replacement: RestElement = {
type: 'RestElement',
argument: property.key as Identifier
}
};
node.properties[i] = replacement;

@ -32,7 +32,7 @@ export default class Expression {
// TODO apparently unnecessary?
// is_synthetic: boolean;
declarations: (Node | Node[])[] = [];
declarations: Array<(Node | Node[])> = [];
uses_context = false;
manipulated: Node;

@ -44,18 +44,18 @@ export default class Block {
}>;
chunks: {
init: (Node | Node[])[];
create: (Node | Node[])[];
claim: (Node | Node[])[];
hydrate: (Node | Node[])[];
mount: (Node | Node[])[];
measure: (Node | Node[])[];
fix: (Node | Node[])[];
animate: (Node | Node[])[];
intro: (Node | Node[])[];
update: (Node | Node[])[];
outro: (Node | Node[])[];
destroy: (Node | Node[])[];
init: Array<Node | Node[]>;
create: Array<Node | Node[]>;
claim: Array<Node | Node[]>;
hydrate: Array<Node | Node[]>;
mount: Array<Node | Node[]>;
measure: Array<Node | Node[]>;
fix: Array<Node | Node[]>;
animate: Array<Node | Node[]>;
intro: Array<Node | Node[]>;
update: Array<Node | Node[]>;
outro: Array<Node | Node[]>;
destroy: Array<Node | Node[]>;
};
event_listeners: Node[] = [];
@ -69,7 +69,7 @@ export default class Block {
outros: number;
aliases: Map<string, Identifier>;
variables: Map<string, { id: Identifier, init?: Node }> = new Map();
variables: Map<string, { id: Identifier; init?: Node }> = new Map();
get_unique_name: (name: string) => Identifier;
has_update_method = false;
@ -249,7 +249,7 @@ export default class Block {
const noop = x`@noop`;
properties.key = key
properties.key = key;
if (this.first) {
properties.first = x`null`;

@ -11,7 +11,7 @@ export default class Renderer {
blocks: Array<Block | Node | Node[]> = [];
readonly: Set<string> = new Set();
meta_bindings: (Node | Node[])[] = []; // initial values for e.g. window.innerWidth, if there's a <svelte:window> meta tag
meta_bindings: Array<Node | Node[]> = []; // initial values for e.g. window.innerWidth, if there's a <svelte:window> meta tag
binding_groups: string[] = [];
block: Block;

@ -475,7 +475,7 @@ export default function dom(
value: x`function() {
return [${props.map(prop => x`"${prop.export_name}"`)}];
}` as FunctionExpression
})
});
}
declaration.body.body.push(...accessors);

@ -188,7 +188,7 @@ export default class AwaitBlockWrapper extends Wrapper {
const dependencies = this.node.expression.dynamic_dependencies();
if (dependencies.length > 0) {
let condition = x`
const condition = x`
${changed(dependencies)} &&
${promise} !== (${promise} = ${snippet}) &&
@handle_promise(${promise}, ${info})`;

@ -61,7 +61,7 @@ export default class EachBlockWrapper extends Wrapper {
view_length: string;
}
context_props: (Node | Node[])[];
context_props: Array<Node | Node[]>;
index_name: Identifier;
var: Identifier = { type: 'Identifier', name: 'each' };

@ -84,7 +84,7 @@ export default class AttributeWrapper {
} else {
value = this.node.name === 'class'
? this.get_class_name_text()
: this.render_chunks().reduce((lhs, rhs) => x`${lhs} + ${rhs}`)
: this.render_chunks().reduce((lhs, rhs) => x`${lhs} + ${rhs}`);
// '{foo} {bar}' — treat as string concatenation
if (this.node.chunks[0].type !== 'Text') {

@ -267,7 +267,7 @@ function get_event_handler(
}
}
let mutation = b`
const mutation = b`
${lhs} = ${value};
${set_store}
`;

@ -38,7 +38,7 @@ export default class StyleAttributeWrapper extends AttributeWrapper {
return chunk.manipulate(block);
}
})
.reduce((lhs, rhs) => x`${lhs} + ${rhs}`)
.reduce((lhs, rhs) => x`${lhs} + ${rhs}`);
// TODO is this necessary? style.setProperty always treats value as string, no?
// if (prop.value.length === 1 || prop.value[0].type !== 'Text') {

@ -310,7 +310,7 @@ export default class ElementWrapper extends Wrapper {
quasis: []
};
to_html((this.fragment.nodes as unknown as (ElementWrapper | TextWrapper)[]), block, literal, state);
to_html((this.fragment.nodes as unknown as Array<ElementWrapper | TextWrapper>), block, literal, state);
literal.quasis.push(state.quasi);
block.chunks.create.push(
@ -832,7 +832,7 @@ export default class ElementWrapper extends Wrapper {
}
}
function to_html(wrappers: (ElementWrapper | TextWrapper)[], block: Block, literal: any, state: any) {
function to_html(wrappers: Array<ElementWrapper | TextWrapper>, block: Block, literal: any, state: any) {
wrappers.forEach(wrapper => {
if (wrapper.node.type === 'Text') {
if ((wrapper as TextWrapper).use_space()) state.quasi.value.raw += ' ';
@ -866,7 +866,7 @@ function to_html(wrappers: (ElementWrapper | TextWrapper)[], block: Block, liter
state.quasi.value.raw += chunk.data;
} else {
literal.quasis.push(state.quasi);
literal.expressions.push(chunk.manipulate(block))
literal.expressions.push(chunk.manipulate(block));
state.quasi = {
type: 'TemplateElement',
@ -881,7 +881,7 @@ function to_html(wrappers: (ElementWrapper | TextWrapper)[], block: Block, liter
state.quasi.value.raw += '>';
if (!is_void(wrapper.node.name)) {
to_html((wrapper as ElementWrapper).fragment.nodes as (ElementWrapper | TextWrapper)[], block, literal, state);
to_html((wrapper as ElementWrapper).fragment.nodes as Array<ElementWrapper | TextWrapper>, block, literal, state);
state.quasi.value.raw += `</${wrapper.node.name}>`;
}

@ -261,7 +261,7 @@ export default class IfBlockWrapper extends Wrapper {
const current_block_type = block.get_unique_name(`current_block_type`);
const get_block = has_else
? x`${current_block_type}(#ctx)`
: x`${current_block_type} && ${current_block_type}(#ctx)`
: x`${current_block_type} && ${current_block_type}(#ctx)`;
/* eslint-disable @typescript-eslint/indent,indent */
if (this.needs_update) {

@ -116,8 +116,8 @@ export default class InlineComponentWrapper extends Wrapper {
const component_opts = x`{}` as ObjectExpression;
const statements: (Node | Node[])[] = [];
const updates: (Node | Node[])[] = [];
const statements: Array<Node | Node[]> = [];
const updates: Array<Node | Node[]> = [];
let props;
const name_changes = block.get_unique_name(`${name.name}_changes`);

@ -1,8 +1,7 @@
import { b } from 'code-red';
import { b, x } from 'code-red';
import Block from '../../Block';
import Action from '../../../nodes/Action';
import Component from '../../../Component';
import { x } from 'code-red';
export default function add_actions(
component: Component,

@ -48,7 +48,7 @@ export default class Renderer {
name: Identifier;
stack: { current: { value: string }, literal: TemplateLiteral }[] = [];
stack: Array<{ current: { value: string }; literal: TemplateLiteral }> = [];
current: { value: string }; // TODO can it just be `current: string`?
literal: TemplateLiteral;
@ -59,17 +59,6 @@ export default class Renderer {
this.push();
}
append() {
throw new Error('no more append');
// if (this.targets.length) {
// const target = this.targets[this.targets.length - 1];
// const slot_name = target.slot_stack[target.slot_stack.length - 1];
// target.slots[slot_name] += code;
// } else {
// this.code += code;
// }
}
add_string(str: string) {
this.current.value += escape_template(str);
}
@ -94,7 +83,7 @@ export default class Renderer {
quasis: []
};
this.stack.push({ current, literal })
this.stack.push({ current, literal });
}
pop() {

@ -11,7 +11,7 @@ export default function get_slot_data(values: Map<string, Attribute>, is_ssr: bo
const value = get_value(attribute);
return p`${attribute.name}: ${value}`;
})
}
};
}
// TODO fairly sure this is duplicated at least once

@ -67,7 +67,7 @@ export interface Parser {
}
export interface Script extends BaseNode {
type: 'Script',
type: 'Script';
context: string;
content: Program;
}
@ -80,7 +80,7 @@ export interface Style extends BaseNode {
start: number;
end: number;
styles: string;
}
};
}
export interface Ast {

@ -29,7 +29,7 @@ function get_context(parser: Parser, attributes: any[], start: number): string {
return value;
}
export default function read_script(parser: Parser, start: number, attributes: Node[]) : Script {
export default function read_script(parser: Parser, start: number, attributes: Node[]): Script {
const script_start = parser.index;
const script_end = parser.template.indexOf(script_closing_tag, script_start);

@ -37,8 +37,8 @@ const specials = new Map([
],
]);
const SELF = /^svelte:self(?=[\s\/>])/;
const COMPONENT = /^svelte:component(?=[\s\/>])/;
const SELF = /^svelte:self(?=[\s/>])/;
const COMPONENT = /^svelte:component(?=[\s/>])/;
function parent_is_head(stack) {
let i = stack.length;

Loading…
Cancel
Save