pull/4742/head
pushkine 5 years ago
parent 510ad4da3b
commit 28b160f2fc

@ -15,30 +15,28 @@ module.exports = {
'no-var': 2, 'no-var': 2,
'no-unreachable': 2, 'no-unreachable': 2,
'valid-typeof': 2, 'valid-typeof': 2,
'quote-props': [2, 'as-needed'], 'quote-props': 'off',
'prefer-arrow-callback': 2, 'prefer-arrow-callback': 2,
'prefer-const': [2, { destructuring: 'all' }], 'prefer-const': [2, { destructuring: 'all' }],
'arrow-spacing': 2, 'arrow-spacing': 2,
'no-inner-declarations': 0, 'no-inner-declarations': 0,
'require-atomic-updates': 'off', 'require-atomic-updates': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/indent': 'off', '@typescript-eslint/indent': 'off',
'@typescript-eslint/camelcase': 'off', '@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off', '@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-object-literal-type-assertion': 'off', '@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/prefer-interface': 'off', '@typescript-eslint/prefer-interface': 'off',
}, },
globals: { globals: {
globalThis: false, globalThis: false,
__VERSION__: true,
}, },
env: { env: {
es6: true, es6: true,

@ -82,9 +82,9 @@
"code-red": "0.1.1", "code-red": "0.1.1",
"codecov": "^3.6.5", "codecov": "^3.6.5",
"css-tree": "1.0.0-alpha22", "css-tree": "1.0.0-alpha22",
"eslint": "^7.0.0",
"eslint-plugin-import": "^2.20.2", "eslint-plugin-import": "^2.20.2",
"eslint-plugin-svelte3": "^2.7.3", "eslint-plugin-svelte3": "^2.7.3",
"eslint": "^7.0.0",
"esm": "^3.2.25", "esm": "^3.2.25",
"estree-walker": "^2.0.1", "estree-walker": "^2.0.1",
"is-reference": "^1.1.4", "is-reference": "^1.1.4",
@ -96,8 +96,9 @@
"periscopic": "^2.0.1", "periscopic": "^2.0.1",
"puppeteer": "^3.0.4", "puppeteer": "^3.0.4",
"rollup": "^2.10.2", "rollup": "^2.10.2",
"source-map": "^0.7.3",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"source-map": "^0.7.3",
"tiny-glob": "^0.2.6",
"ts-mocha": "^7.0.0", "ts-mocha": "^7.0.0",
"tslib": "^2.0.0", "tslib": "^2.0.0",
"typescript": "^3.9.2" "typescript": "^3.9.2"

@ -1 +1,2 @@
/* eslint-disable no-var */
declare var __VERSION__: string; declare var __VERSION__: string;

@ -454,7 +454,7 @@ export default class Block {
: fn; : fn;
} }
render_listeners(chunk: string = '') { render_listeners(chunk = '') {
if (this.event_listeners.length > 0) { if (this.event_listeners.length > 0) {
const dispose: Identifier = { const dispose: Identifier = {
type: 'Identifier', type: 'Identifier',

@ -10,7 +10,7 @@ export function invalidate(
scope: Scope, scope: Scope,
node: Node, node: Node,
names: Set<string>, names: Set<string>,
main_execution_context: boolean = false main_execution_context = false
) { ) {
const { component } = renderer; const { component } = renderer;

@ -337,7 +337,7 @@ export default class InlineComponentWrapper extends Wrapper {
} }
const params = [x`#value`]; const params = [x`#value`];
let args = []; const args = [];
contextual_dependencies.forEach((name) => { contextual_dependencies.forEach((name) => {
params.push({ type: 'Identifier', name }); params.push({ type: 'Identifier', name });
renderer.add_to_context(name, true); renderer.add_to_context(name, true);

@ -0,0 +1,5 @@
{
"rules": {
"import/no-unresolved": "off"
}
}

@ -12,7 +12,7 @@ export const is_cors =
} }
})(); })();
export const has_Symbol = typeof Symbol === 'function'; export const has_Symbol = typeof Symbol === 'function';
/* eslint-disable no-var */
declare var global: any; declare var global: any;
export const globals = is_browser ? window : typeof globalThis !== 'undefined' ? globalThis : global; export const globals = is_browser ? window : typeof globalThis !== 'undefined' ? globalThis : global;
export const resolved_promise = Promise.resolve(); export const resolved_promise = Promise.resolve();

@ -44,8 +44,8 @@ export function bind({ $$: { props, bound, ctx } }, name: string, callback: (pro
export function mount_component({ $$ }, target, anchor) { export function mount_component({ $$ }, target, anchor) {
if ($$.fragment) $$.fragment.m(target, anchor); if ($$.fragment) $$.fragment.m(target, anchor);
add_render_callback(() => { add_render_callback(() => {
let { on_mount, on_destroy, after_update } = $$, const { on_mount, on_destroy, after_update } = $$;
i = 0, let i = 0,
res; res;
for (; i < on_mount.length; i++) for (; i < on_mount.length; i++)
if ('function' === typeof (res = on_mount[i]())) if ('function' === typeof (res = on_mount[i]()))

@ -184,7 +184,9 @@ export function set_input_value(input, value) {
export function set_input_type(input, type) { export function set_input_type(input, type) {
try { try {
input.type = type; input.type = type;
} catch (e) {} } catch (e) {
//
}
} }
export function set_style(node, property, value, is_important?) { export function set_style(node, property, value, is_important?) {

@ -155,13 +155,13 @@ const parseStructure = <T>(
): initCreateMotionTick<T> | initCreateTweenTick<T> => { ): initCreateMotionTick<T> | initCreateTweenTick<T> => {
const isArray = Array.isArray(obj); const isArray = Array.isArray(obj);
if (typeof obj === 'object' && obj !== null && (isArray || Object.prototype === Object.getPrototypeOf(obj))) { if (typeof obj === 'object' && obj !== null && (isArray || Object.prototype === Object.getPrototypeOf(obj))) {
const keys = Object.keys(obj);
let i = 0, let i = 0,
l = keys.length,
k = '', k = '',
createTickers = keys.map((key) => parseStructure(obj[key], schema)((next_value) => (obj[key] = next_value))),
tickers = new Array(l),
pending = 0; pending = 0;
const keys = Object.keys(obj),
l = keys.length,
createTickers = keys.map((key) => parseStructure(obj[key], schema)((next_value) => (obj[key] = next_value))),
tickers = new Array(l);
const target = { ...obj }; const target = { ...obj };
obj = isArray ? [...(obj as T[])] : { ...obj }; obj = isArray ? [...(obj as T[])] : { ...obj };
return (set) => (_, to_value) => { return (set) => (_, to_value) => {

@ -1,5 +1,7 @@
{ {
"rules": { "rules": {
"no-console": "off" "no-console": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-namespace": "off"
} }
} }

@ -51,13 +51,11 @@ describe('hydration', () => {
try { try {
global.window = window; global.window = window;
let SvelteComponent; // try {
const SvelteComponent = require(`${cwd}/main.svelte`).default;
try { // } catch (err) {
SvelteComponent = require(`${cwd}/main.svelte`).default; // throw err;
} catch (err) { // }
throw err;
}
const target = window.document.body; const target = window.document.body;
const head = window.document.head; const head = window.document.head;
@ -68,7 +66,9 @@ describe('hydration', () => {
try { try {
before_head = fs.readFileSync(`${cwd}/_before_head.html`, 'utf-8'); before_head = fs.readFileSync(`${cwd}/_before_head.html`, 'utf-8');
head.innerHTML = before_head; head.innerHTML = before_head;
} catch (err) {} } catch (_err) {
//
}
const snapshot = config.snapshot ? config.snapshot(target) : {}; const snapshot = config.snapshot ? config.snapshot(target) : {};

@ -1,8 +0,0 @@
type Test = {
test({ assert, component, mod, target, window, raf, compileOptions }): void | Promise<void>;
html: string;
skip: boolean;
};
declare module 'samples/*/_config.js' {
export default Test;
}

@ -4,7 +4,6 @@ import { rollup } from 'rollup';
import virtual from '@rollup/plugin-virtual'; import virtual from '@rollup/plugin-virtual';
import { clear_loops, flush, SvelteComponent } from '../../internal'; import { clear_loops, flush, SvelteComponent } from '../../internal';
import { set_now, set_raf, set_framerate } from '../../environment'; import { set_now, set_raf, set_framerate } from '../../environment';
import './ambient';
import { showOutput, loadConfig, loadSvelte, cleanRequireCache, env, setupHtmlEqual, mkdirp } from '../helpers'; import { showOutput, loadConfig, loadSvelte, cleanRequireCache, env, setupHtmlEqual, mkdirp } from '../helpers';
import { glob } from '../tiny-glob'; import { glob } from '../tiny-glob';
import { assert } from '../test'; import { assert } from '../test';

@ -1,8 +1,7 @@
import './ambient'; import './ambient';
import * as assert$1 from 'assert'; import * as assert$1 from 'assert';
import { readFileSync } from 'fs';
export const assert = (assert$1 as unknown) as typeof assert$1 & { htmlEqual: (actual, expected, message?) => void }; export const assert = (assert$1 as unknown) as typeof assert$1 & { htmlEqual: (actual, expected, message?) => void };
const { glob } = require('./tiny-glob.ts'); import { glob } from './tiny-glob';
// require('./setup.ts'); // require('./setup.ts');

@ -14,17 +14,17 @@ const GLOBSTAR = `((?:[^/]*(?:/|$))*)`;
const WILDCARD = `([^/]*)`; const WILDCARD = `([^/]*)`;
const GLOBSTAR_SEGMENT = `((?:[^${SEP_ESC}]*(?:${SEP_ESC}|$))*)`; const GLOBSTAR_SEGMENT = `((?:[^${SEP_ESC}]*(?:${SEP_ESC}|$))*)`;
const WILDCARD_SEGMENT = `([^${SEP_ESC}]*)`; const WILDCARD_SEGMENT = `([^${SEP_ESC}]*)`;
const isHidden = /(^|[\\\/])\.[^\\\/\.]/g; const isHidden = /(^|[\\/])\.[^\\/.]/g;
let CACHE = {}; let CACHE = {};
function isglob(str, { strict = true } = {}) { function isglob(str, { strict = true } = {}) {
if (str === '') return false; if (str === '') return false;
let match, let match;
rgx = strict ? STRICT : RELAXED; const rgx = strict ? STRICT : RELAXED;
while ((match = rgx.exec(str))) { while ((match = rgx.exec(str))) {
if (match[2]) return true; if (match[2]) return true;
let idx = match.index + match[0].length; let idx = match.index + match[0].length;
let open = match[1]; const open = match[1];
let close = open ? CHARS[open] : null; const close = open ? CHARS[open] : null;
let n; let n;
if (open && close) if ((n = str.indexOf(close, idx)) !== -1) idx = n + 1; if (open && close) if ((n = str.indexOf(close, idx)) !== -1) idx = n + 1;
str = str.slice(idx); str = str.slice(idx);
@ -33,15 +33,15 @@ function isglob(str, { strict = true } = {}) {
} }
function parent(str, { strict = false } = {}) { function parent(str, { strict = false } = {}) {
str = normalize(str).replace(/\/|\\/, '/'); str = normalize(str).replace(/\/|\\/, '/');
if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/'; if (/[{[].*[/]*.*[}]]$/.test(str)) str += '/';
str += 'a'; str += 'a';
do str = dirname(str); do str = dirname(str);
while (isglob(str, { strict }) || /(^|[^\\])([\{\[]|\([^\)]+$)/.test(str)); while (isglob(str, { strict }) || /(^|[^\\])([{[]|\([^)]+$)/.test(str));
return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1'); return str.replace(/\\([*?|[\](){}])/g, '$1');
} }
function globalyzer(pattern, opts = {}) { function globalyzer(pattern, opts = {}) {
let base = parent(pattern, opts); let base = parent(pattern, opts);
let isGlob = isglob(pattern, opts); const isGlob = isglob(pattern, opts);
let glob; let glob;
if (base != '.') { if (base != '.') {
if ((glob = pattern.substr(base.length)).startsWith('/')) glob = glob.substr(1); if ((glob = pattern.substr(base.length)).startsWith('/')) glob = glob.substr(1);
@ -54,7 +54,7 @@ function globalyzer(pattern, opts = {}) {
function globrex(glob, { extended = false, globstar = false, strict = false, filepath = false, flags = '' } = {}) { function globrex(glob, { extended = false, globstar = false, strict = false, filepath = false, flags = '' } = {}) {
let regex = ''; let regex = '';
let segment = ''; let segment = '';
let path = { const path = {
regex: '', regex: '',
segments: [], segments: [],
globstar: undefined, globstar: undefined,
@ -101,7 +101,7 @@ function globrex(glob, { extended = false, globstar = false, strict = false, fil
case ')': { case ')': {
if (ext.length) { if (ext.length) {
add(c); add(c);
let type = ext.pop(); const type = ext.pop();
if (type === '@') { if (type === '@') {
add('{1}'); add('{1}');
} else if (type === '!') { } else if (type === '!') {
@ -177,16 +177,16 @@ function globrex(glob, { extended = false, globstar = false, strict = false, fil
ext.push(c); ext.push(c);
break; break;
} }
let prevChar = glob[i - 1]; const prevChar = glob[i - 1];
let starCount = 1; let starCount = 1;
while (glob[i + 1] === '*') { while (glob[i + 1] === '*') {
starCount++; starCount++;
i++; i++;
} }
let nextChar = glob[i + 1]; const nextChar = glob[i + 1];
if (!globstar) add('.*'); if (!globstar) add('.*');
else { else {
let isGlobstar = const isGlobstar =
starCount > 1 && (prevChar === '/' || prevChar === void 0) && (nextChar === '/' || nextChar === void 0); starCount > 1 && (prevChar === '/' || prevChar === void 0) && (nextChar === '/' || nextChar === void 0);
if (isGlobstar) { if (isGlobstar) {
add(GLOBSTAR, { only: 'regex' }); add(GLOBSTAR, { only: 'regex' });
@ -225,8 +225,9 @@ function walk(output, prefix, lexer, filesOnly, dot, cwd, dirname = '', level =
const dir = join(cwd, prefix, dirname); const dir = join(cwd, prefix, dirname);
const files = readdirSync(dir); const files = readdirSync(dir);
let i = 0, let i = 0,
len = files.length,
file; file;
const len = files.length;
let fullpath, relpath, stats, isMatch; let fullpath, relpath, stats, isMatch;
for (; i < len; i++) { for (; i < len; i++) {
fullpath = join(dir, (file = files[i])); fullpath = join(dir, (file = files[i]));
@ -245,11 +246,11 @@ function walk(output, prefix, lexer, filesOnly, dot, cwd, dirname = '', level =
} }
export function glob(str: string, { cwd = '.', absolute = false, filesOnly = false, dot = false, flush = false }) { export function glob(str: string, { cwd = '.', absolute = false, filesOnly = false, dot = false, flush = false }) {
if (!str) return []; if (!str) return [];
let glob = globalyzer(str); const glob = globalyzer(str);
if (!glob.isGlob) { if (!glob.isGlob) {
try { try {
let resolved = resolve(cwd, str); const resolved = resolve(cwd, str);
let dirent = statSync(resolved); const dirent = statSync(resolved);
if (filesOnly && !dirent.isFile()) return []; if (filesOnly && !dirent.isFile()) return [];
return absolute ? [resolved] : [str]; return absolute ? [resolved] : [str];
@ -260,7 +261,7 @@ export function glob(str: string, { cwd = '.', absolute = false, filesOnly = fal
} }
} }
if (flush) CACHE = {}; if (flush) CACHE = {};
let matches = []; const matches = [];
const { path } = globrex(glob.glob, { filepath: true, globstar: true, extended: true }); const { path } = globrex(glob.glob, { filepath: true, globstar: true, extended: true });
//@ts-ignore //@ts-ignore
path.globstar = path.globstar.toString(); path.globstar = path.globstar.toString();

Loading…
Cancel
Save