[FIX] *: run prettier

This commit is contained in:
Géry Debongnie
2019-10-28 16:51:00 +01:00
parent e7967d0779
commit 6a434310ee
5 changed files with 85 additions and 93 deletions
+1 -3
View File
@@ -13,7 +13,6 @@ A rendering occurs in two phases:
- virtual rendering: this generates the virtual dom in memory, asynchronously
- patch: applies a virtual tree to the screen (synchronously)
There are several classes involved in a rendering:
- components
@@ -21,9 +20,9 @@ There are several classes involved in a rendering:
- fibers: small objects containing some metadata, associated with a rendering of
a specific component
Components are organized in a dynamic component tree, visible in the user
interface. Whenever a rendering is initiated in a component `C`:
- a fiber is created on `C` with the rendering props information
- the virtual rendering phase starts on C (will asynchronously render all the
child components)
@@ -31,4 +30,3 @@ interface. Whenever a rendering is initiated in a component `C`:
animation frame, if the fiber is done
- once it is done, the scheduler will call the task callback, which will apply
the patch (if it was not cancelled in the meantime).
+1 -1
View File
@@ -354,7 +354,7 @@ describe("props validation", () => {
async __updateProps() {
try {
await Component.prototype.__updateProps.apply(this, arguments);
} catch(e) {
} catch (e) {
error = e;
}
}
+11 -16
View File
@@ -23,7 +23,7 @@ interface MarkDownSection {
interface FileData {
name: string;
path: string[];
fullName: string
fullName: string;
links: MarkDownLink[];
sections: MarkDownSection[];
}
@@ -31,11 +31,9 @@ interface FileData {
const LINK_REGEXP = /\[([^\[]+)\]\(([^\)]+)\)/g;
const HEADING_REGEXP = /\n(#+\s*)(.*)/g;
export function addMardownData(fileData): void {
const sep = fileData.path.length > 0 ? '/' : '';
const fullName = fileData.path.join('/') + sep + fileData.name;
const sep = fileData.path.length > 0 ? "/" : "";
const fullName = fileData.path.join("/") + sep + fileData.name;
const content = fs.readFileSync(fullName, { encoding: "utf8" });
let m;
// get links info
@@ -54,7 +52,6 @@ export function addMardownData(fileData): void {
} while (m);
}
/**
* Returns a list of FileData corresponding to all files that need to be
* validated.
@@ -74,7 +71,7 @@ function getFiles(path: string[] = []): FileData[] {
if (f.isDirectory()) {
return getFiles(path.concat(f.name));
}
const fullName = path.join('/') + (path.length > 0 ? '/' : '') + f.name;
const fullName = path.join("/") + (path.length > 0 ? "/" : "") + f.name;
return [
{
name: f.name,
@@ -88,7 +85,7 @@ function getFiles(path: string[] = []): FileData[] {
return Array.prototype.concat(...files);
}
const LOCAL_FILES = ['LICENSE'];
const LOCAL_FILES = ["LICENSE"];
export function isLinkValid(link: MarkDownLink, current: FileData, files: FileData[]): boolean {
if (link.link.startsWith("http")) {
// no check on external links
@@ -99,19 +96,19 @@ export function isLinkValid(link: MarkDownLink, current: FileData, files: FileDa
// name = 'rendering.md'
// hash = 'blabla' (or '' if no hash)
const parts = link.link.split('#');
const hash = parts[1] || '';
const parts = link.link.split("#");
const hash = parts[1] || "";
let name;
let path;
if (parts[0]) {
let temp = parts[0].split('/');
let temp = parts[0].split("/");
name = temp[temp.length - 1];
temp.splice(-1);
path = current.path.slice();
for (let elem of temp) {
if (elem === '..') {
if (elem === "..") {
path.splice(-1);
} else if (elem !== '.') {
} else if (elem !== ".") {
path.push(elem);
}
}
@@ -122,7 +119,7 @@ export function isLinkValid(link: MarkDownLink, current: FileData, files: FileDa
}
// Step 2: build normalized link file name
const linkFullName = path.join('/') + (path.length > 0 ? '/' : '') + name;
const linkFullName = path.join("/") + (path.length > 0 ? "/" : "") + name;
// Step 3: check link name against white list of local files
if (LOCAL_FILES.includes(linkFullName)) {
@@ -164,8 +161,6 @@ function slugify(str) {
.replace(/-+$/, ""); // Trim - from end of text
}
//--------------------------------------------------------------------------
// Test
//--------------------------------------------------------------------------
+2 -3
View File
@@ -54,13 +54,12 @@ describe("router miscellaneous", () => {
});
test("navigate in hash mode preserve location", async () => {
router = new TestRouter(env, [{ name: "users", path: "/users/{{id}}" }], {mode: "hash"});
window.history.pushState({}, "title", window.location.origin + '/test.html');
router = new TestRouter(env, [{ name: "users", path: "/users/{{id}}" }], { mode: "hash" });
window.history.pushState({}, "title", window.location.origin + "/test.html");
expect(window.location.href).toBe("http://localhost/test.html");
await router.navigate({ to: "users", params: { id: 3 } });
expect(window.location.href).toBe("http://localhost/test.html#/users/3");
});
});
describe("routeToPath", () => {