From 8fb35ed969d150f50da2f575fc5d8e41665005c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 26 Nov 2019 22:35:11 +0100 Subject: [PATCH] [FIX] owl: add prettier to devDependencies also, run prettier on codebase closes #498 --- package.json | 1 + src/vdom/vdom.ts | 2 +- tests/component/component.test.ts | 34 ++++++++++++++++++++++++----- tests/qweb/qweb.test.ts | 5 ++++- tests/qweb/qweb_expressions.test.ts | 5 ++++- tests/router/link.test.ts | 10 +++++++-- tests/store_hooks.test.ts | 12 ++++++++-- 7 files changed, 57 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 5c9e1a74..d5303b1b 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "jest-environment-jsdom": "^24.7.1", "live-server": "^1.2.1", "npm-run-all": "^4.1.5", + "prettier": "^1.19.1", "rollup": "^1.6.0", "rollup-plugin-typescript2": "^0.20.1", "sass": "^1.16.1", diff --git a/src/vdom/vdom.ts b/src/vdom/vdom.ts index f7731e19..58845c3e 100644 --- a/src/vdom/vdom.ts +++ b/src/vdom/vdom.ts @@ -101,7 +101,7 @@ function isVnode(vnode: any): vnode is VNode { type KeyToIndexMap = { [key: string]: number }; -type ArraysOf = { [K in keyof T]: (T[K])[] }; +type ArraysOf = { [K in keyof T]: T[K][] }; type ModuleHooks = ArraysOf; diff --git a/tests/component/component.test.ts b/tests/component/component.test.ts index 87aa49c1..4a814f13 100644 --- a/tests/component/component.test.ts +++ b/tests/component/component.test.ts @@ -1362,7 +1362,13 @@ describe("composition", () => { class SubWidget extends Widget {} class Parent extends Widget { static components = { SubWidget }; - state = useState({ blips: [{ a: "a", id: 1 }, { b: "b", id: 2 }, { c: "c", id: 4 }] }); + state = useState({ + blips: [ + { a: "a", id: 1 }, + { b: "b", id: 2 }, + { c: "c", id: 4 } + ] + }); } const parent = new Parent(); await parent.mount(fixture); @@ -1465,7 +1471,11 @@ describe("composition", () => { `; state = useState({ - records: [{ id: 1, val: 1 }, { id: 2, val: 2 }, { id: 3, val: 3 }] + records: [ + { id: 1, val: 1 }, + { id: 2, val: 2 }, + { id: 3, val: 3 } + ] }); static components = { ChildWidget }; } @@ -3731,7 +3741,12 @@ describe("t-slot directive", () => { class Link extends Widget {} class App extends Widget { - state = useState({ users: [{ id: 1, name: "Aaron" }, { id: 2, name: "David" }] }); + state = useState({ + users: [ + { id: 1, name: "Aaron" }, + { id: 2, name: "David" } + ] + }); static components = { Link }; } @@ -3770,7 +3785,12 @@ describe("t-slot directive", () => { class Link extends Widget {} class App extends Widget { - state = useState({ users: [{ id: 1, name: "Aaron" }, { id: 2, name: "David" }] }); + state = useState({ + users: [ + { id: 1, name: "Aaron" }, + { id: 2, name: "David" } + ] + }); static components = { Link }; } @@ -4406,7 +4426,11 @@ describe("t-model directive", () => { `; - state = useState([{ f: false, id: 1 }, { f: false, id: 2 }, { f: false, id: 3 }]); + state = useState([ + { f: false, id: 1 }, + { f: false, id: 2 }, + { f: false, id: 3 } + ]); } const comp = new SomeComponent(); await comp.mount(fixture); diff --git a/tests/qweb/qweb.test.ts b/tests/qweb/qweb.test.ts index d384778c..d1d85c4b 100644 --- a/tests/qweb/qweb.test.ts +++ b/tests/qweb/qweb.test.ts @@ -1225,7 +1225,10 @@ describe("t-on", () => { ); const steps: string[] = []; const owner = { - projects: [{ id: 1, name: "Project 1" }, { id: 2, name: "Project 2" }], + projects: [ + { id: 1, name: "Project 1" }, + { id: 2, name: "Project 2" } + ], onEdit(projectId, ev) { expect(ev.defaultPrevented).toBe(true); diff --git a/tests/qweb/qweb_expressions.test.ts b/tests/qweb/qweb_expressions.test.ts index 7ea57d1a..99d9bbf1 100644 --- a/tests/qweb/qweb_expressions.test.ts +++ b/tests/qweb/qweb_expressions.test.ts @@ -27,7 +27,10 @@ describe("tokenizer", () => { { type: "VALUE", value: "2" }, { type: "RIGHT_BRACE", value: "}" } ]); - expect(tokenize("a,")).toEqual([{ type: "SYMBOL", value: "a" }, { type: "COMMA", value: "," }]); + expect(tokenize("a,")).toEqual([ + { type: "SYMBOL", value: "a" }, + { type: "COMMA", value: "," } + ]); expect(tokenize("][")).toEqual([ { type: "RIGHT_BRACKET", value: "]" }, { type: "LEFT_BRACKET", value: "[" } diff --git a/tests/router/link.test.ts b/tests/router/link.test.ts index 74bf7c73..f8df5c53 100644 --- a/tests/router/link.test.ts +++ b/tests/router/link.test.ts @@ -35,7 +35,10 @@ describe("Link component", () => { static components = { Link: Link }; } - const routes = [{ name: "about", path: "/about" }, { name: "users", path: "/users" }]; + const routes = [ + { name: "about", path: "/about" }, + { name: "users", path: "/users" } + ]; router = new TestRouter(env, routes, { mode: "history" }); router.navigate({ to: "users" }); @@ -66,7 +69,10 @@ describe("Link component", () => { static components = { Link: Link }; } - const routes = [{ name: "about", path: "/about" }, { name: "users", path: "/users" }]; + const routes = [ + { name: "about", path: "/about" }, + { name: "users", path: "/users" } + ]; router = new TestRouter(env, routes, { mode: "history" }); router.navigate({ to: "users" }); diff --git a/tests/store_hooks.test.ts b/tests/store_hooks.test.ts index 968cef53..d181d2f0 100644 --- a/tests/store_hooks.test.ts +++ b/tests/store_hooks.test.ts @@ -293,7 +293,12 @@ describe("connecting a component to store", () => { }); test("useStore can use props", async () => { - const state = { todos: [{ id: 1, text: "jupiler" }, { id: 2, text: "chimay" }] }; + const state = { + todos: [ + { id: 1, text: "jupiler" }, + { id: 2, text: "chimay" } + ] + }; const store = new Store({ state, actions: {} }); class TodoItem extends Component { @@ -360,7 +365,10 @@ describe("connecting a component to store", () => { test("can call useGetters to receive store getters", async () => { const state = { importantID: 1, - todos: [{ id: 1, text: "jupiler" }, { id: 2, text: "bertinchamps" }] + todos: [ + { id: 1, text: "jupiler" }, + { id: 2, text: "bertinchamps" } + ] }; const getters = { importantTodoText({ state }) {