mirror of https://github.com/sveltejs/svelte
parent
25488772e2
commit
c358c498ff
@ -1 +0,0 @@
|
|||||||
test/test.js
|
|
File diff suppressed because it is too large
Load Diff
@ -1,103 +1,112 @@
|
|||||||
{
|
{
|
||||||
"name": "svelte",
|
"name": "svelte",
|
||||||
"version": "3.22.3",
|
"version": "3.22.3",
|
||||||
"description": "Cybernetically enhanced web apps",
|
"description": "Cybernetically enhanced web apps",
|
||||||
"module": "index.mjs",
|
"module": "index.mjs",
|
||||||
"main": "index",
|
"main": "index",
|
||||||
"files": [
|
"files": [
|
||||||
"types",
|
"types",
|
||||||
"compiler.*",
|
"compiler.*",
|
||||||
"register.js",
|
"register.js",
|
||||||
"index.*",
|
"index.*",
|
||||||
"internal",
|
"internal",
|
||||||
"store",
|
"store",
|
||||||
"animate",
|
"animate",
|
||||||
"transition",
|
"transition",
|
||||||
"easing",
|
"easing",
|
||||||
"motion",
|
"motion",
|
||||||
"svelte",
|
"svelte",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
},
|
},
|
||||||
"types": "types/runtime/index.d.ts",
|
"types": "types/runtime/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --opts mocha.opts",
|
"test": "mocha",
|
||||||
"test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts",
|
"test:unit": "mocha -r sucrase/register --recursive src/**/__test__.ts",
|
||||||
"quicktest": "mocha --opts mocha.opts",
|
"quicktest": "mocha",
|
||||||
"precoverage": "c8 mocha --opts mocha.coverage.opts",
|
"update-expected": "node -r sucrase/register ./test/js/update.ts && node -r sucrase/register ./test/parser/update.ts",
|
||||||
"coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html",
|
"precoverage": "c8 mocha --opts mocha.coverage.opts",
|
||||||
"codecov": "codecov",
|
"coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html",
|
||||||
"precodecov": "npm run coverage",
|
"codecov": "codecov",
|
||||||
"build": "rollup -c && npm run tsd",
|
"precodecov": "npm run coverage",
|
||||||
"prepare": "npm run build",
|
"build": "rollup -c && npm run tsd",
|
||||||
"dev": "rollup -cw",
|
"prepare": "npm run build",
|
||||||
"pretest": "npm run build",
|
"dev": "rollup -cw",
|
||||||
"posttest": "agadoo internal/index.mjs",
|
"pretest": "npm run build",
|
||||||
"prepublishOnly": "npm run lint && PUBLISH=true npm test",
|
"posttest": "agadoo internal/index.mjs",
|
||||||
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
|
"prepublishOnly": "npm run lint && PUBLISH=true npm test",
|
||||||
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
|
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
|
||||||
},
|
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
|
||||||
"repository": {
|
},
|
||||||
"type": "git",
|
"mocha": {
|
||||||
"url": "https://github.com/sveltejs/svelte.git"
|
"file": "./test/test.ts",
|
||||||
},
|
"require": "sucrase/register",
|
||||||
"keywords": [
|
"bail": true,
|
||||||
"UI",
|
"timeout": "10000"
|
||||||
"framework",
|
},
|
||||||
"templates",
|
"repository": {
|
||||||
"templating"
|
"type": "git",
|
||||||
],
|
"url": "https://github.com/sveltejs/svelte.git"
|
||||||
"author": "Rich Harris",
|
},
|
||||||
"license": "MIT",
|
"keywords": [
|
||||||
"bugs": {
|
"UI",
|
||||||
"url": "https://github.com/sveltejs/svelte/issues"
|
"framework",
|
||||||
},
|
"templates",
|
||||||
"homepage": "https://github.com/sveltejs/svelte#README",
|
"templating"
|
||||||
"devDependencies": {
|
],
|
||||||
"@rollup/plugin-commonjs": "^11.0.0",
|
"author": "Rich Harris",
|
||||||
"@rollup/plugin-json": "^4.0.1",
|
"license": "MIT",
|
||||||
"@rollup/plugin-node-resolve": "^6.0.0",
|
"bugs": {
|
||||||
"@rollup/plugin-replace": "^2.3.0",
|
"url": "https://github.com/sveltejs/svelte/issues"
|
||||||
"@rollup/plugin-sucrase": "^3.0.0",
|
},
|
||||||
"@rollup/plugin-typescript": "^2.0.1",
|
"homepage": "https://github.com/sveltejs/svelte#README",
|
||||||
"@rollup/plugin-virtual": "^2.0.0",
|
"devDependencies": {
|
||||||
"@types/mocha": "^5.2.7",
|
"@rollup/plugin-commonjs": "^11.1.0",
|
||||||
"@types/node": "^8.10.53",
|
"@rollup/plugin-json": "^4.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^1.13.0",
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
||||||
"@typescript-eslint/parser": "^2.1.0",
|
"@rollup/plugin-replace": "^2.3.2",
|
||||||
"acorn": "^7.1.0",
|
"@rollup/plugin-sucrase": "^3.0.1",
|
||||||
"agadoo": "^1.1.0",
|
"@rollup/plugin-typescript": "^4.1.1",
|
||||||
"c8": "^5.0.1",
|
"@rollup/plugin-virtual": "^2.0.2",
|
||||||
"code-red": "0.1.1",
|
"@types/jsdom": "^16.2.2",
|
||||||
"codecov": "^3.5.0",
|
"@types/mocha": "^7.0.2",
|
||||||
"css-tree": "1.0.0-alpha22",
|
"@types/node": "^14.0.1",
|
||||||
"eslint": "^6.3.0",
|
"@types/puppeteer": "^2.1.0",
|
||||||
"eslint-plugin-import": "^2.18.2",
|
"@typescript-eslint/eslint-plugin": "^1.13.0",
|
||||||
"eslint-plugin-svelte3": "^2.7.3",
|
"@typescript-eslint/parser": "^2.1.0",
|
||||||
"estree-walker": "^1.0.0",
|
"acorn": "^7.2.0",
|
||||||
"is-reference": "^1.1.4",
|
"agadoo": "^2.0.0",
|
||||||
"jsdom": "^15.1.1",
|
"c8": "^7.1.2",
|
||||||
"kleur": "^3.0.3",
|
"code-red": "0.1.1",
|
||||||
"locate-character": "^2.0.5",
|
"codecov": "^3.6.5",
|
||||||
"magic-string": "^0.25.3",
|
"css-tree": "1.0.0-alpha22",
|
||||||
"mocha": "^6.2.0",
|
"eslint": "^6.3.0",
|
||||||
"periscopic": "^2.0.1",
|
"eslint-plugin-import": "^2.18.2",
|
||||||
"puppeteer": "^1.19.0",
|
"eslint-plugin-svelte3": "^2.7.3",
|
||||||
"rollup": "^1.27.14",
|
"estree-walker": "^2.0.1",
|
||||||
"source-map": "^0.7.3",
|
"is-reference": "^1.1.4",
|
||||||
"source-map-support": "^0.5.13",
|
"jsdom": "^16.2.2",
|
||||||
"tiny-glob": "^0.2.6",
|
"kleur": "^3.0.3",
|
||||||
"tslib": "^1.10.0",
|
"locate-character": "^2.0.5",
|
||||||
"typescript": "^3.5.3"
|
"magic-string": "^0.25.3",
|
||||||
},
|
"mocha": "^7.1.2",
|
||||||
"nyc": {
|
"periscopic": "^2.0.1",
|
||||||
"include": [
|
"puppeteer": "^3.1.0",
|
||||||
"compiler/svelte.js",
|
"rollup": "^2.10.5",
|
||||||
"shared.js"
|
"source-map-support": "^0.5.19",
|
||||||
],
|
"source-map": "^0.7.3",
|
||||||
"sourceMap": true,
|
"tslib": "^2.0.0",
|
||||||
"instrument": true
|
"typescript": "^3.9.2"
|
||||||
|
},
|
||||||
|
"nyc": {
|
||||||
|
"include": [
|
||||||
|
"compiler/svelte.js",
|
||||||
|
"shared.js"
|
||||||
|
],
|
||||||
|
"sourceMap": true,
|
||||||
|
"instrument": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-console": "off"
|
"no-console": "off",
|
||||||
}
|
"@typescript-eslint/no-var-requires": "off",
|
||||||
|
"@typescript-eslint/no-namespace": "off"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
import jsdom from 'jsdom';
|
||||||
|
export {};
|
||||||
|
declare global {
|
||||||
|
namespace NodeJS {
|
||||||
|
interface Global {
|
||||||
|
document: Document;
|
||||||
|
window: jsdom.DOMWindow;
|
||||||
|
navigator: Navigator;
|
||||||
|
getComputedStyle: jsdom.DOMWindow['getComputedStyle'];
|
||||||
|
requestAnimationFrame: any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<title>Some Title</title>
|
<title>Some Title</title>
|
||||||
<link rel="canonical" href="/" data-svelte="svelte-1s8aodm">
|
<link rel="canonical" href="/" data-svelte="svelte-1t0pfk9">
|
||||||
<meta name="description" content="some description" data-svelte="svelte-1s8aodm">
|
<meta name="description" content="some description" data-svelte="svelte-1t0pfk9">
|
||||||
<meta name="keywords" content="some keywords" data-svelte="svelte-1s8aodm">
|
<meta name="keywords" content="some keywords" data-svelte="svelte-1t0pfk9">
|
@ -1,72 +0,0 @@
|
|||||||
import * as assert from "assert";
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as path from "path";
|
|
||||||
import * as colors from "kleur";
|
|
||||||
import { loadConfig, svelte, shouldUpdateExpected } from "../helpers.js";
|
|
||||||
|
|
||||||
describe("js", () => {
|
|
||||||
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
|
|
||||||
if (dir[0] === ".") return;
|
|
||||||
|
|
||||||
// add .solo to a sample directory name to only run that test
|
|
||||||
const solo = /\.solo/.test(dir);
|
|
||||||
|
|
||||||
if (solo && process.env.CI) {
|
|
||||||
throw new Error("Forgot to remove `solo: true` from test");
|
|
||||||
}
|
|
||||||
|
|
||||||
const resolved = path.resolve(`${__dirname}/samples`, dir);
|
|
||||||
|
|
||||||
if (!fs.existsSync(`${resolved}/input.svelte`)) {
|
|
||||||
console.log(colors.red().bold(`Missing file ${dir}/input.svelte. If you recently switched branches you may need to delete this directory`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(solo ? it.only : it)(dir, () => {
|
|
||||||
const config = loadConfig(`${resolved}/_config.js`);
|
|
||||||
|
|
||||||
const input = fs.readFileSync(`${resolved}/input.svelte`, "utf-8").replace(/\s+$/, "");
|
|
||||||
|
|
||||||
let actual;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = Object.assign(config.options || {});
|
|
||||||
|
|
||||||
actual = svelte.compile(input, options).js.code.replace(/generated by Svelte v\d+\.\d+\.\d+(-\w+\.\d+)?/, 'generated by Svelte vX.Y.Z');
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err.frame);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
const output = `${resolved}/_actual.js`;
|
|
||||||
fs.writeFileSync(output, actual);
|
|
||||||
|
|
||||||
const expectedPath = `${resolved}/expected.js`;
|
|
||||||
|
|
||||||
let expected = '';
|
|
||||||
try {
|
|
||||||
expected = fs.readFileSync(expectedPath, "utf-8");
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
if (error.code === 'ENOENT') {
|
|
||||||
// missing expected.js
|
|
||||||
fs.writeFileSync(expectedPath, actual);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
assert.equal(
|
|
||||||
actual.trim().replace(/^[ \t]+$/gm, ""),
|
|
||||||
expected.trim().replace(/^[ \t]+$/gm, "")
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
if (shouldUpdateExpected()) {
|
|
||||||
fs.writeFileSync(expectedPath, actual);
|
|
||||||
console.log(`Updated ${expectedPath}.`);
|
|
||||||
} else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -0,0 +1,78 @@
|
|||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as colors from 'kleur';
|
||||||
|
import { loadConfig, svelte, shouldUpdateExpected } from '../helpers';
|
||||||
|
import { assert } from '../test';
|
||||||
|
|
||||||
|
describe('js', () => {
|
||||||
|
fs.readdirSync(`${__dirname}/samples`).forEach((dir) => {
|
||||||
|
if (dir[0] === '.') return;
|
||||||
|
|
||||||
|
// add .solo to a sample directory name to only run that test
|
||||||
|
const solo = /\.solo/.test(dir);
|
||||||
|
const skip = /\.skip$/.test(dir);
|
||||||
|
|
||||||
|
if (solo && process.env.CI) {
|
||||||
|
throw new Error('Forgot to remove `solo: true` from test');
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolved = path.resolve(`${__dirname}/samples`, dir);
|
||||||
|
|
||||||
|
if (!fs.existsSync(`${resolved}/input.svelte`)) {
|
||||||
|
console.log(
|
||||||
|
colors
|
||||||
|
.red()
|
||||||
|
.bold(
|
||||||
|
`Missing file ${dir}/input.svelte. If you recently switched branches you may need to delete this directory`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(skip ? it.skip : solo ? it.only : it)(dir, () => {
|
||||||
|
const config = loadConfig(`${resolved}/_config.js`);
|
||||||
|
|
||||||
|
const input = fs.readFileSync(`${resolved}/input.svelte`, 'utf-8').replace(/\s+$/, '');
|
||||||
|
|
||||||
|
let actual;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = Object.assign(config.options || {});
|
||||||
|
|
||||||
|
actual = svelte
|
||||||
|
.compile(input, options)
|
||||||
|
.js.code.replace(/generated by Svelte v\d+\.\d+\.\d+(-\w+\.\d+)?/, 'generated by Svelte vX.Y.Z');
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err.frame);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = `${resolved}/_actual.js`;
|
||||||
|
fs.writeFileSync(output, actual);
|
||||||
|
|
||||||
|
const expectedPath = `${resolved}/expected.js`;
|
||||||
|
|
||||||
|
let expected = '';
|
||||||
|
try {
|
||||||
|
expected = fs.readFileSync(expectedPath, 'utf-8');
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
if (error.code === 'ENOENT') {
|
||||||
|
// missing expected.js
|
||||||
|
fs.writeFileSync(expectedPath, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
assert.equal(actual.trim().replace(/^[ \t]+$/gm, '').replace(/\r/g, ''), expected.trim().replace(/^[ \t]+$/gm, '').replace(/\r/g, ''));
|
||||||
|
} catch (error) {
|
||||||
|
if (shouldUpdateExpected()) {
|
||||||
|
fs.writeFileSync(expectedPath, actual);
|
||||||
|
console.log(`Updated ${expectedPath}.`);
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,13 +0,0 @@
|
|||||||
// this file will replace all the expected.js files with their _actual
|
|
||||||
// equivalents. Only use it when you're sure that you haven't
|
|
||||||
// broken anything!
|
|
||||||
const fs = require("fs");
|
|
||||||
const glob = require("tiny-glob/sync.js");
|
|
||||||
|
|
||||||
glob("samples/*/_actual.js", { cwd: __dirname }).forEach(file => {
|
|
||||||
const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8");
|
|
||||||
fs.writeFileSync(
|
|
||||||
`${__dirname}/${file.replace("_actual.js", "expected.js")}`,
|
|
||||||
actual
|
|
||||||
);
|
|
||||||
});
|
|
@ -0,0 +1,39 @@
|
|||||||
|
import { readFileSync, writeFileSync } from 'fs';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
// this file will replace all the expected.js files with their _actual
|
||||||
|
// equivalents. Only use it when you're sure that you haven't
|
||||||
|
// broken anything!
|
||||||
|
const svelte = (function loadSvelte(test) {
|
||||||
|
process.env.TEST = test ? 'true' : '';
|
||||||
|
const resolved = require.resolve('../../compiler.js');
|
||||||
|
delete require.cache[resolved];
|
||||||
|
return require(resolved);
|
||||||
|
})(false);
|
||||||
|
function loadConfig(file) {
|
||||||
|
try {
|
||||||
|
const resolved = require.resolve(file);
|
||||||
|
delete require.cache[resolved];
|
||||||
|
|
||||||
|
const config = require(resolved);
|
||||||
|
return config.default || config;
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === 'MODULE_NOT_FOUND') {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require(resolve(__dirname, '../tiny-glob.ts'))
|
||||||
|
.glob('samples/*/input.svelte', { cwd: __dirname })
|
||||||
|
.forEach((file) => {
|
||||||
|
writeFileSync(
|
||||||
|
`${__dirname}/${file.replace('input.svelte', 'expected.js')}`,
|
||||||
|
svelte
|
||||||
|
.compile(
|
||||||
|
readFileSync(`${__dirname}/${file}`, 'utf-8').replace(/\s+$/, ''),
|
||||||
|
loadConfig(`${__dirname}/${file.replace('input.svelte', '_config.js')}`).options
|
||||||
|
)
|
||||||
|
.js.code.replace(/generated by Svelte v\d+\.\d+\.\d+(-\w+\.\d+)?/, 'generated by Svelte vX.Y.Z')
|
||||||
|
);
|
||||||
|
});
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "duplicate-attribute",
|
"code": "duplicate-attribute",
|
||||||
"message": "Attributes need to be unique",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 17,
|
"column": 17,
|
||||||
"character": 17
|
"character": 17
|
||||||
},
|
},
|
||||||
"pos": 17
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 17,
|
||||||
|
"character": 17
|
||||||
|
},
|
||||||
|
"pos": 17,
|
||||||
|
"frame": "1: <Widget foo={42} bind:foo/>\n ^",
|
||||||
|
"message": "Attributes need to be unique"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "duplicate-attribute",
|
"code": "duplicate-attribute",
|
||||||
"message": "Attributes need to be unique",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 17,
|
"column": 17,
|
||||||
"character": 17
|
"character": 17
|
||||||
},
|
},
|
||||||
"pos": 17
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 17,
|
||||||
|
"character": 17
|
||||||
|
},
|
||||||
|
"pos": 17,
|
||||||
|
"frame": "1: <div class='foo' class='bar'></div>\n ^",
|
||||||
|
"message": "Attributes need to be unique"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "duplicate-attribute",
|
"code": "duplicate-attribute",
|
||||||
"message": "Attributes need to be unique",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 17,
|
"column": 17,
|
||||||
"character": 17
|
"character": 17
|
||||||
},
|
},
|
||||||
"pos": 17
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 17,
|
||||||
|
"character": 17
|
||||||
|
},
|
||||||
|
"pos": 17,
|
||||||
|
"frame": "1: <div title='foo' {title}></div>\n ^",
|
||||||
|
"message": "Attributes need to be unique"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-catch-placement",
|
"code": "invalid-catch-placement",
|
||||||
"message": "Expected to close {#each} block before seeing {:catch} block",
|
"start": {
|
||||||
"start": { "line": 3, "column": 7, "character": 41 },
|
"line": 3,
|
||||||
"pos": 41
|
"column": 7,
|
||||||
}
|
"character": 43
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 7,
|
||||||
|
"character": 43
|
||||||
|
},
|
||||||
|
"pos": 43,
|
||||||
|
"frame": "1: {#await true}\r\n2: {#each foo as bar}\r\n3: {:catch f}\r\n ^\n4: {/await}",
|
||||||
|
"message": "Expected to close {#each} block before seeing {:catch} block"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-catch-placement",
|
"code": "invalid-catch-placement",
|
||||||
"message": "Cannot have an {:catch} block outside an {#await ...} block",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 7,
|
"column": 7,
|
||||||
"character": 7
|
"character": 7
|
||||||
},
|
},
|
||||||
"pos": 7
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 7,
|
||||||
|
"character": 7
|
||||||
|
},
|
||||||
|
"pos": 7,
|
||||||
|
"frame": "1: {:catch theValue}\n ^",
|
||||||
|
"message": "Cannot have an {:catch} block outside an {#await ...} block"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "unexpected-eof",
|
"code": "unexpected-eof",
|
||||||
"message": "comment was left open, expected -->",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 24,
|
"column": 24,
|
||||||
"character": 24
|
"character": 24
|
||||||
},
|
},
|
||||||
"pos": 24
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 24,
|
||||||
|
"character": 24
|
||||||
|
},
|
||||||
|
"pos": 24,
|
||||||
|
"frame": "1: <!-- an unclosed comment\n ^",
|
||||||
|
"message": "comment was left open, expected -->"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "css-syntax-error",
|
"code": "css-syntax-error",
|
||||||
"message": "LeftCurlyBracket is expected",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 16,
|
"column": 16,
|
||||||
"character": 24
|
"character": 25
|
||||||
},
|
},
|
||||||
"pos": 24
|
"end": {
|
||||||
}
|
"line": 2,
|
||||||
|
"column": 16,
|
||||||
|
"character": 25
|
||||||
|
},
|
||||||
|
"pos": 25,
|
||||||
|
"frame": "1: <style>\r\n2: this is not css\r\n ^\n3: </style>",
|
||||||
|
"message": "LeftCurlyBracket is expected"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-else-placement",
|
"code": "invalid-else-placement",
|
||||||
"message": "Expected to close {#await} block before seeing {:else} block",
|
"start": {
|
||||||
"start": { "line": 3, "column": 6, "character": 29 },
|
"line": 3,
|
||||||
"pos": 29
|
"column": 6,
|
||||||
}
|
"character": 31
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 6,
|
||||||
|
"character": 31
|
||||||
|
},
|
||||||
|
"pos": 31,
|
||||||
|
"frame": "1: {#if true}\r\n2: {#await p}\r\n3: {:else}\r\n ^\n4: {/if}",
|
||||||
|
"message": "Expected to close {#await} block before seeing {:else} block"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-else-placement",
|
"code": "invalid-else-placement",
|
||||||
"message": "Cannot have an {:else} block outside an {#if ...} or {#each ...} block",
|
"start": {
|
||||||
"start": { "line": 2, "column": 6, "character": 11 },
|
"line": 2,
|
||||||
"pos": 11
|
"column": 6,
|
||||||
}
|
"character": 12
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 6,
|
||||||
|
"character": 12
|
||||||
|
},
|
||||||
|
"pos": 12,
|
||||||
|
"frame": "1: <li>\r\n2: {:else}\n ^",
|
||||||
|
"message": "Cannot have an {:else} block outside an {#if ...} or {#each ...} block"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-else-placement",
|
"code": "invalid-else-placement",
|
||||||
"message": "Expected to close <li> tag before seeing {:else} block",
|
"start": {
|
||||||
"start": { "line": 3, "column": 6, "character": 23 },
|
"line": 3,
|
||||||
"pos": 23
|
"column": 6,
|
||||||
}
|
"character": 25
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 6,
|
||||||
|
"character": 25
|
||||||
|
},
|
||||||
|
"pos": 25,
|
||||||
|
"frame": "1: {#if true}\r\n2: <li>\r\n3: {:else}\r\n ^\n4: {/if}",
|
||||||
|
"message": "Expected to close <li> tag before seeing {:else} block"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-elseif-placement",
|
"code": "invalid-elseif-placement",
|
||||||
"message": "Expected to close <p> tag before seeing {:else if ...} block",
|
"start": {
|
||||||
"start": { "line": 3, "column": 9, "character": 25 },
|
"line": 3,
|
||||||
"pos": 25
|
"column": 9,
|
||||||
}
|
"character": 27
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 9,
|
||||||
|
"character": 27
|
||||||
|
},
|
||||||
|
"pos": 27,
|
||||||
|
"frame": "1: {#if true}\r\n2: <p>\r\n3: {:else if false}\r\n ^\n4: {/if}",
|
||||||
|
"message": "Expected to close <p> tag before seeing {:else if ...} block"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-elseif-placement",
|
"code": "invalid-elseif-placement",
|
||||||
"message": "Expected to close {#await} block before seeing {:else if ...} block",
|
"start": {
|
||||||
"start": { "line": 3, "column": 9, "character": 34 },
|
"line": 3,
|
||||||
"pos": 34
|
"column": 9,
|
||||||
}
|
"character": 36
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 9,
|
||||||
|
"character": 36
|
||||||
|
},
|
||||||
|
"pos": 36,
|
||||||
|
"frame": "1: {#if true}\r\n2: {#await foo}\r\n3: {:else if false}\r\n ^\n4: {/if}",
|
||||||
|
"message": "Expected to close {#await} block before seeing {:else if ...} block"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-elseif-placement",
|
"code": "invalid-elseif-placement",
|
||||||
"message": "Cannot have an {:else if ...} block outside an {#if ...} block",
|
"start": {
|
||||||
"start": { "line": 3, "column": 10, "character": 35 },
|
"line": 3,
|
||||||
"pos": 35
|
"column": 10,
|
||||||
}
|
"character": 37
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 10,
|
||||||
|
"character": 37
|
||||||
|
},
|
||||||
|
"pos": 37,
|
||||||
|
"frame": "1: {#await foo}\r\n2: {:then bar}\r\n3: {:else if}\r\n ^\n4: {/await}",
|
||||||
|
"message": "Cannot have an {:else if ...} block outside an {#if ...} block"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "parse-error",
|
"code": "parse-error",
|
||||||
"message": "Assigning to rvalue",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 1,
|
"column": 1,
|
||||||
"character": 1
|
"character": 1
|
||||||
},
|
},
|
||||||
"pos": 1
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 1,
|
||||||
|
"character": 1
|
||||||
|
},
|
||||||
|
"pos": 1,
|
||||||
|
"frame": "1: {42 = nope}\n ^",
|
||||||
|
"message": "Assigning to rvalue"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "duplicate-style",
|
"code": "duplicate-style",
|
||||||
"message": "You can only have one top-level <style> tag per component",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 9,
|
"line": 9,
|
||||||
"column": 0,
|
"column": 0,
|
||||||
"character": 58
|
"character": 66
|
||||||
},
|
},
|
||||||
"pos": 58
|
"end": {
|
||||||
}
|
"line": 9,
|
||||||
|
"column": 0,
|
||||||
|
"character": 66
|
||||||
|
},
|
||||||
|
"pos": 66,
|
||||||
|
"frame": " 7: </style>\r\n 8: \r\n 9: <style>\r\n ^\n10: div {\r\n11: color: blue;\r",
|
||||||
|
"message": "You can only have one top-level <style> tag per component"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "unclosed-script",
|
"code": "unclosed-script",
|
||||||
"message": "<script> must have a closing tag",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 3,
|
"line": 3,
|
||||||
"column": 8,
|
"column": 8,
|
||||||
"character": 32
|
"character": 34
|
||||||
},
|
},
|
||||||
"pos": 32
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 8,
|
||||||
|
"character": 34
|
||||||
|
},
|
||||||
|
"pos": 34,
|
||||||
|
"frame": "1: <h1>Hello {name}!</h1>\r\n2: \r\n3: <script>\n ^",
|
||||||
|
"message": "<script> must have a closing tag"
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-self-placement",
|
"code": "invalid-self-placement",
|
||||||
"message": "<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, or slots passed to components",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 1,
|
"column": 1,
|
||||||
"character": 1
|
"character": 1
|
||||||
},
|
},
|
||||||
"pos": 1
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 1,
|
||||||
|
"character": 1
|
||||||
|
},
|
||||||
|
"pos": 1,
|
||||||
|
"frame": "1: <svelte:self/>\n ^",
|
||||||
|
"message": "<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, or slots passed to components"
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-tag-name",
|
"code": "invalid-tag-name",
|
||||||
"message": "Valid <svelte:...> tag names are svelte:head, svelte:options, svelte:window, svelte:body, svelte:self or svelte:component",
|
|
||||||
"pos": 10,
|
|
||||||
"start": {
|
"start": {
|
||||||
"character": 10,
|
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 2
|
"column": 2,
|
||||||
}
|
"character": 11
|
||||||
}
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 2,
|
||||||
|
"character": 11
|
||||||
|
},
|
||||||
|
"pos": 11,
|
||||||
|
"frame": "1: {#if x}\r\n2: <svelte:selfdestructive x=\"{x - 1}\"/>\r\n ^\n3: {/if}",
|
||||||
|
"message": "Valid <svelte:...> tag names are svelte:head, svelte:options, svelte:window, svelte:body, svelte:self or svelte:component"
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-then-placement",
|
"code": "invalid-then-placement",
|
||||||
"message": "Expected to close <li> tag before seeing {:then} block",
|
"start": {
|
||||||
"start": { "line": 3, "column": 6, "character": 26 },
|
"line": 3,
|
||||||
"pos": 26
|
"column": 6,
|
||||||
}
|
"character": 28
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 6,
|
||||||
|
"character": 28
|
||||||
|
},
|
||||||
|
"pos": 28,
|
||||||
|
"frame": "1: {#await true}\r\n2: <li>\r\n3: {:then f}\r\n ^\n4: {/await}",
|
||||||
|
"message": "Expected to close <li> tag before seeing {:then} block"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-then-placement",
|
"code": "invalid-then-placement",
|
||||||
"message": "Cannot have an {:then} block outside an {#await ...} block",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 6,
|
"column": 6,
|
||||||
"character": 6
|
"character": 6
|
||||||
},
|
},
|
||||||
"pos": 6
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 6,
|
||||||
|
"character": 6
|
||||||
|
},
|
||||||
|
"pos": 6,
|
||||||
|
"frame": "1: {:then theValue}\n ^",
|
||||||
|
"message": "Cannot have an {:then} block outside an {#await ...} block"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "unexpected-eof",
|
"code": "unexpected-eof",
|
||||||
"message": "Unexpected end of input",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 2,
|
"column": 2,
|
||||||
"character": 2
|
"character": 2
|
||||||
},
|
},
|
||||||
"pos": 2
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 2,
|
||||||
|
"character": 2
|
||||||
|
},
|
||||||
|
"pos": 2,
|
||||||
|
"frame": "1: <d\n ^",
|
||||||
|
"message": "Unexpected end of input"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "unexpected-eof",
|
"code": "unexpected-eof",
|
||||||
"message": "Unexpected end of input",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 1,
|
"column": 1,
|
||||||
"character": 1
|
"character": 1
|
||||||
},
|
},
|
||||||
"pos": 1
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 1,
|
||||||
|
"character": 1
|
||||||
|
},
|
||||||
|
"pos": 1,
|
||||||
|
"frame": "1: <\n ^",
|
||||||
|
"message": "Unexpected end of input"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "unclosed-block",
|
"code": "unclosed-block",
|
||||||
"message": "Block was left open",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0,
|
"column": 0,
|
||||||
"character": 0
|
"character": 0
|
||||||
},
|
},
|
||||||
"pos": 0
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 0,
|
||||||
|
"character": 0
|
||||||
|
},
|
||||||
|
"pos": 0,
|
||||||
|
"frame": "1: {#if foo}\r\n ^\n2: <p>foo</p>",
|
||||||
|
"message": "Block was left open"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "unclosed-element",
|
"code": "unclosed-element",
|
||||||
"message": "<div> was left open",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0,
|
"column": 0,
|
||||||
"character": 0
|
"character": 0
|
||||||
},
|
},
|
||||||
"pos": 0
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 0,
|
||||||
|
"character": 0
|
||||||
|
},
|
||||||
|
"pos": 0,
|
||||||
|
"frame": "1: <div>\n ^",
|
||||||
|
"message": "<div> was left open"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-closing-tag",
|
"code": "invalid-closing-tag",
|
||||||
"message": "</div> attempted to close an element that was not open",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0,
|
"column": 0,
|
||||||
"character": 0
|
"character": 0
|
||||||
},
|
},
|
||||||
"pos": 0
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 0,
|
||||||
|
"character": 0
|
||||||
|
},
|
||||||
|
"pos": 0,
|
||||||
|
"frame": "1: </div>\n ^",
|
||||||
|
"message": "</div> attempted to close an element that was not open"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-void-content",
|
"code": "invalid-void-content",
|
||||||
"message": "<input> is a void element and cannot have children, or a closing tag",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 23,
|
"column": 23,
|
||||||
"character": 23
|
"character": 23
|
||||||
},
|
},
|
||||||
"pos": 23
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 23,
|
||||||
|
"character": 23
|
||||||
|
},
|
||||||
|
"pos": 23,
|
||||||
|
"frame": "1: <input>this is illegal!</input>\n ^",
|
||||||
|
"message": "<input> is a void element and cannot have children, or a closing tag"
|
||||||
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-window-content",
|
"code": "invalid-window-content",
|
||||||
"message": "<svelte:window> cannot have children",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 15,
|
"column": 15,
|
||||||
"character": 15
|
"character": 15
|
||||||
},
|
},
|
||||||
"pos": 15
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15,
|
||||||
|
"character": 15
|
||||||
|
},
|
||||||
|
"pos": 15,
|
||||||
|
"frame": "1: <svelte:window>contents</svelte:window>\n ^",
|
||||||
|
"message": "<svelte:window> cannot have children"
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "duplicate-window",
|
"code": "duplicate-window",
|
||||||
"message": "A component can only have one <svelte:window> tag",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 0,
|
"column": 0,
|
||||||
"character": 17
|
"character": 18
|
||||||
},
|
},
|
||||||
"pos": 17
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 0,
|
||||||
|
"character": 18
|
||||||
|
},
|
||||||
|
"pos": 18,
|
||||||
|
"frame": "1: <svelte:window/>\r\n2: <svelte:window/>\n ^",
|
||||||
|
"message": "A component can only have one <svelte:window> tag"
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-window-placement",
|
"code": "invalid-window-placement",
|
||||||
"message": "<svelte:window> tags cannot be inside elements or blocks",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 1,
|
"column": 1,
|
||||||
"character": 11
|
"character": 12
|
||||||
},
|
},
|
||||||
"pos": 11
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 1,
|
||||||
|
"character": 12
|
||||||
|
},
|
||||||
|
"pos": 12,
|
||||||
|
"frame": "1: {#if foo}\r\n2: <svelte:window/>\r\n ^\n3: {/if}",
|
||||||
|
"message": "<svelte:window> tags cannot be inside elements or blocks"
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "invalid-window-placement",
|
"code": "invalid-window-placement",
|
||||||
"message": "<svelte:window> tags cannot be inside elements or blocks",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 1,
|
"column": 1,
|
||||||
"character": 7
|
"character": 8
|
||||||
},
|
},
|
||||||
"pos": 7
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 1,
|
||||||
|
"character": 8
|
||||||
|
},
|
||||||
|
"pos": 8,
|
||||||
|
"frame": "1: <div>\r\n2: <svelte:window/>\r\n ^\n3: </div>",
|
||||||
|
"message": "<svelte:window> tags cannot be inside elements or blocks"
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"name": "ParseError",
|
||||||
"code": "missing-whitespace",
|
"code": "missing-whitespace",
|
||||||
"message": "Expected whitespace",
|
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 6,
|
"column": 6,
|
||||||
"character": 6
|
"character": 6
|
||||||
},
|
},
|
||||||
"pos": 6
|
"end": {
|
||||||
}
|
"line": 1,
|
||||||
|
"column": 6,
|
||||||
|
"character": 6
|
||||||
|
},
|
||||||
|
"pos": 6,
|
||||||
|
"frame": "1: {@htmlfoo}\n ^",
|
||||||
|
"message": "Expected whitespace"
|
||||||
|
}
|
@ -1,13 +0,0 @@
|
|||||||
// this file will replace all the output.json files with their _actual.json
|
|
||||||
// equivalents. Only use it when you're sure that you haven't
|
|
||||||
// broken anything!
|
|
||||||
const fs = require("fs");
|
|
||||||
const glob = require("tiny-glob/sync.js");
|
|
||||||
|
|
||||||
glob("samples/*/_actual.json", { cwd: __dirname }).forEach(file => {
|
|
||||||
const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8");
|
|
||||||
fs.writeFileSync(
|
|
||||||
`${__dirname}/${file.replace("_actual.json", "output.json")}`,
|
|
||||||
actual
|
|
||||||
);
|
|
||||||
});
|
|
@ -0,0 +1,31 @@
|
|||||||
|
import { readFileSync, writeFileSync } from 'fs';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
// this file will replace all the expected.js files with their _actual
|
||||||
|
// equivalents. Only use it when you're sure that you haven't
|
||||||
|
// broken anything!
|
||||||
|
const svelte = (function loadSvelte(test) {
|
||||||
|
process.env.TEST = test ? 'true' : '';
|
||||||
|
const resolved = require.resolve('../../compiler.js');
|
||||||
|
delete require.cache[resolved];
|
||||||
|
return require(resolved);
|
||||||
|
})(false);
|
||||||
|
require(resolve(__dirname, '../tiny-glob.ts'))
|
||||||
|
.glob('samples/*/input.svelte', { cwd: __dirname })
|
||||||
|
.forEach((file) => {
|
||||||
|
try {
|
||||||
|
writeFileSync(
|
||||||
|
`${__dirname}/${file.replace('input.svelte', 'output.json')}`,
|
||||||
|
JSON.stringify(
|
||||||
|
svelte.compile(readFileSync(`${__dirname}/${file}`, 'utf-8').replace(/\s+$/, ''), { generate: false }).ast,
|
||||||
|
null,
|
||||||
|
'\t'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.name !== 'ParseError') throw e;
|
||||||
|
writeFileSync(
|
||||||
|
`${__dirname}/${file.replace('input.svelte', 'error.json')}`,
|
||||||
|
JSON.stringify({ ...e, message: e.message }, null, '\t')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -1,9 +1,9 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as assert from 'assert';
|
import { loadConfig, svelte } from '../helpers';
|
||||||
import { loadConfig, svelte } from '../helpers.js';
|
import { assert } from '../test';
|
||||||
|
|
||||||
describe('preprocess', () => {
|
describe('preprocess', () => {
|
||||||
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
|
fs.readdirSync(`${__dirname}/samples`).forEach((dir) => {
|
||||||
if (dir[0] === '.') return;
|
if (dir[0] === '.') return;
|
||||||
|
|
||||||
const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
|
const config = loadConfig(`${__dirname}/samples/${dir}/_config.js`);
|
@ -1,40 +1,39 @@
|
|||||||
export default {
|
export default {
|
||||||
html: `<div class=" svelte-x1o6ra"></div>`,
|
|
||||||
|
|
||||||
test({ assert, component, target }) {
|
test({ assert, component, target }) {
|
||||||
const div = target.querySelector('div');
|
const div = target.querySelector('div');
|
||||||
|
|
||||||
component.testName = null;
|
component.testName = null;
|
||||||
assert.equal(div.className, ' svelte-x1o6ra');
|
const startsWith = (str) => assert.ok(div.className.startsWith(str));
|
||||||
|
startsWith(' svelte-');
|
||||||
|
|
||||||
component.testName = undefined;
|
component.testName = undefined;
|
||||||
assert.equal(div.className, ' svelte-x1o6ra');
|
startsWith(' svelte-');
|
||||||
|
|
||||||
component.testName = undefined + '';
|
component.testName = undefined + '';
|
||||||
assert.equal(div.className, 'undefined svelte-x1o6ra');
|
startsWith('undefined svelte-');
|
||||||
|
|
||||||
component.testName = null + '';
|
component.testName = null + '';
|
||||||
assert.equal(div.className, 'null svelte-x1o6ra');
|
startsWith('null svelte-');
|
||||||
|
|
||||||
component.testName = 1;
|
component.testName = 1;
|
||||||
assert.equal(div.className, '1 svelte-x1o6ra');
|
startsWith('1 svelte-');
|
||||||
|
|
||||||
component.testName = 0;
|
component.testName = 0;
|
||||||
assert.equal(div.className, '0 svelte-x1o6ra');
|
startsWith('0 svelte-');
|
||||||
|
|
||||||
component.testName = false;
|
component.testName = false;
|
||||||
assert.equal(div.className, 'false svelte-x1o6ra');
|
startsWith('false svelte-');
|
||||||
|
|
||||||
component.testName = true;
|
component.testName = true;
|
||||||
assert.equal(div.className, 'true svelte-x1o6ra');
|
startsWith('true svelte-');
|
||||||
|
|
||||||
component.testName = {};
|
component.testName = {};
|
||||||
assert.equal(div.className, '[object Object] svelte-x1o6ra');
|
startsWith('[object Object] svelte-');
|
||||||
|
|
||||||
component.testName = '';
|
component.testName = '';
|
||||||
assert.equal(div.className, ' svelte-x1o6ra');
|
startsWith(' svelte-');
|
||||||
|
|
||||||
component.testName = 'testClassName';
|
component.testName = 'testClassName';
|
||||||
assert.equal(div.className, 'testClassName svelte-x1o6ra');
|
startsWith('testClassName svelte-');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,45 +1,43 @@
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
testName1: "test1",
|
testName1: 'test1',
|
||||||
testName2: "test2",
|
testName2: 'test2',
|
||||||
},
|
},
|
||||||
|
|
||||||
html: `<div class="test1test2 svelte-x1o6ra"></div>`,
|
|
||||||
|
|
||||||
test({ assert, component, target }) {
|
test({ assert, component, target }) {
|
||||||
const div = target.querySelector('div');
|
const div = target.querySelector('div');
|
||||||
assert.equal(div.className, 'test1test2 svelte-x1o6ra');
|
const startsWith = (str) => assert.ok(div.className.startsWith(str + ' svelte-'));
|
||||||
|
startsWith('test1test2');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = null;
|
component.testName2 = null;
|
||||||
assert.equal(div.className, '0 svelte-x1o6ra');
|
startsWith('0');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = "test";
|
component.testName2 = 'test';
|
||||||
assert.equal(div.className, 'nulltest svelte-x1o6ra');
|
startsWith('nulltest');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = "test";
|
component.testName2 = 'test';
|
||||||
assert.equal(div.className, 'undefinedtest svelte-x1o6ra');
|
startsWith('undefinedtest');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = undefined;
|
component.testName2 = undefined;
|
||||||
assert.equal(div.className, 'NaN svelte-x1o6ra');
|
startsWith('NaN');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = 1;
|
component.testName2 = 1;
|
||||||
assert.equal(div.className, '1 svelte-x1o6ra');
|
startsWith('1');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = 1;
|
component.testName2 = 1;
|
||||||
assert.equal(div.className, 'NaN svelte-x1o6ra');
|
startsWith('NaN');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = 0;
|
component.testName2 = 0;
|
||||||
assert.equal(div.className, '0 svelte-x1o6ra');
|
startsWith('0');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = 0;
|
component.testName2 = 0;
|
||||||
assert.equal(div.className, 'NaN svelte-x1o6ra');
|
startsWith('NaN');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,42 +1,40 @@
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
testName: "testClassName"
|
testName: 'testClassName',
|
||||||
},
|
},
|
||||||
|
|
||||||
html: `<div class="testClassName svelte-x1o6ra"></div>`,
|
|
||||||
|
|
||||||
test({ assert, component, target }) {
|
test({ assert, component, target }) {
|
||||||
const div = target.querySelector('div');
|
const div = target.querySelector('div');
|
||||||
assert.equal(div.className, 'testClassName svelte-x1o6ra');
|
const startsWith = (str) => assert.ok(div.className.startsWith(str + ' svelte-'));
|
||||||
|
startsWith('testClassName');
|
||||||
|
|
||||||
component.testName = null;
|
component.testName = null;
|
||||||
assert.equal(div.className, ' svelte-x1o6ra');
|
startsWith('');
|
||||||
|
|
||||||
component.testName = undefined;
|
component.testName = undefined;
|
||||||
assert.equal(div.className, ' svelte-x1o6ra');
|
startsWith('');
|
||||||
|
|
||||||
component.testName = undefined + '';
|
component.testName = undefined + '';
|
||||||
assert.equal(div.className, 'undefined svelte-x1o6ra');
|
startsWith('undefined');
|
||||||
|
|
||||||
component.testName = null + '';
|
component.testName = null + '';
|
||||||
assert.equal(div.className, 'null svelte-x1o6ra');
|
startsWith('null');
|
||||||
|
|
||||||
component.testName = 1;
|
component.testName = 1;
|
||||||
assert.equal(div.className, '1 svelte-x1o6ra');
|
startsWith('1');
|
||||||
|
|
||||||
component.testName = 0;
|
component.testName = 0;
|
||||||
assert.equal(div.className, '0 svelte-x1o6ra');
|
startsWith('0');
|
||||||
|
|
||||||
component.testName = false;
|
component.testName = false;
|
||||||
assert.equal(div.className, 'false svelte-x1o6ra');
|
startsWith('false');
|
||||||
|
|
||||||
component.testName = true;
|
component.testName = true;
|
||||||
assert.equal(div.className, 'true svelte-x1o6ra');
|
startsWith('true');
|
||||||
|
|
||||||
component.testName = {};
|
component.testName = {};
|
||||||
assert.equal(div.className, '[object Object] svelte-x1o6ra');
|
startsWith('[object Object]');
|
||||||
|
|
||||||
component.testName = '';
|
component.testName = '';
|
||||||
assert.equal(div.className, ' svelte-x1o6ra');
|
startsWith('');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,45 +1,43 @@
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
testName1: "test1",
|
testName1: 'test1',
|
||||||
testName2: "test2",
|
testName2: 'test2',
|
||||||
},
|
},
|
||||||
|
|
||||||
html: `<div class="test1test2 svelte-x1o6ra"></div>`,
|
|
||||||
|
|
||||||
test({ assert, component, target }) {
|
test({ assert, component, target }) {
|
||||||
const div = target.querySelector('div');
|
const div = target.querySelector('div');
|
||||||
assert.equal(div.className, 'test1test2 svelte-x1o6ra');
|
const startsWith = (str) => assert.ok(div.className.startsWith(str + ' svelte-'));
|
||||||
|
startsWith('test1test2');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = null;
|
component.testName2 = null;
|
||||||
assert.equal(div.className, '0 svelte-x1o6ra');
|
startsWith('0');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = "test";
|
component.testName2 = 'test';
|
||||||
assert.equal(div.className, 'nulltest svelte-x1o6ra');
|
startsWith('nulltest');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = "test";
|
component.testName2 = 'test';
|
||||||
assert.equal(div.className, 'undefinedtest svelte-x1o6ra');
|
startsWith('undefinedtest');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = undefined;
|
component.testName2 = undefined;
|
||||||
assert.equal(div.className, 'NaN svelte-x1o6ra');
|
startsWith('NaN');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = 1;
|
component.testName2 = 1;
|
||||||
assert.equal(div.className, '1 svelte-x1o6ra');
|
startsWith('1');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = 1;
|
component.testName2 = 1;
|
||||||
assert.equal(div.className, 'NaN svelte-x1o6ra');
|
startsWith('NaN');
|
||||||
|
|
||||||
component.testName1 = null;
|
component.testName1 = null;
|
||||||
component.testName2 = 0;
|
component.testName2 = 0;
|
||||||
assert.equal(div.className, '0 svelte-x1o6ra');
|
startsWith('0');
|
||||||
|
|
||||||
component.testName1 = undefined;
|
component.testName1 = undefined;
|
||||||
component.testName2 = 0;
|
component.testName2 = 0;
|
||||||
assert.equal(div.className, 'NaN svelte-x1o6ra');
|
startsWith('NaN');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
html: `
|
html: `
|
||||||
<div class="foo svelte-xg5rbo">red</div>
|
<div class="foo svelte-1553ulx">red</div>
|
||||||
<div class="qux svelte-xg5rbo">red</div>
|
<div class="qux svelte-1553ulx">red</div>
|
||||||
<div class="bar svelte-xg5rbo">red and bold</div>
|
<div class="bar svelte-1553ulx">red and bold</div>
|
||||||
`
|
`
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<title>Some Title</title>
|
<title>Some Title</title>
|
||||||
<link rel="canonical" href="/" data-svelte="svelte-1s8aodm">
|
<link rel="canonical" href="/" data-svelte="svelte-1t0pfk9">
|
||||||
<meta name="description" content="some description" data-svelte="svelte-1s8aodm">
|
<meta name="description" content="some description" data-svelte="svelte-1t0pfk9">
|
||||||
<meta name="keywords" content="some keywords" data-svelte="svelte-1s8aodm">
|
<meta name="keywords" content="some keywords" data-svelte="svelte-1t0pfk9">
|
@ -1,2 +1,2 @@
|
|||||||
div.svelte-bzh57p{color:red}
|
div.svelte-awisl7{color:red}
|
||||||
div.svelte-4yw8vx{color:green}
|
div.svelte-1us38kz{color:green}
|
@ -1,8 +1,6 @@
|
|||||||
<div class="svelte-bzh57p">red</div>
|
<div class="svelte-awisl7">red</div>
|
||||||
<div class="svelte-4yw8vx">green: foo</div>
|
<div class="svelte-1us38kz">green: foo</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="svelte-4yw8vx">green: bar</div>
|
<div class="svelte-1us38kz">green: bar</div>
|
||||||
|
|
||||||
|
|
@ -1 +1 @@
|
|||||||
div.svelte-bzh57p{color:red}
|
div.svelte-awisl7{color:red}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue