diff --git a/superglue/.babelrc.js b/superglue/.babelrc.js index cdd162e7..745f03ba 100644 --- a/superglue/.babelrc.js +++ b/superglue/.babelrc.js @@ -2,18 +2,14 @@ module.exports = { plugins: [], presets: [ [ - "@babel/preset-env", + '@babel/preset-env', { - useBuiltIns: "entry", - corejs: "2", + useBuiltIns: 'entry', + corejs: '2', loose: true, - } - ], - [ - "@babel/preset-react" - ], - [ - "@babel/preset-typescript" + }, ], + ['@babel/preset-react'], + ['@babel/preset-typescript'], ], -}; +} diff --git a/superglue/.gitignore b/superglue/.gitignore index 9a853f25..3b7f80dd 100644 --- a/superglue/.gitignore +++ b/superglue/.gitignore @@ -61,3 +61,6 @@ typings/ dist/ package-lock.json + +coverage/ +todo.txt \ No newline at end of file diff --git a/superglue/.prettierignore b/superglue/.prettierignore new file mode 100644 index 00000000..4bbc1712 --- /dev/null +++ b/superglue/.prettierignore @@ -0,0 +1,6 @@ +# Ignore artifacts: +dist +coverage + +# Ignore all HTML files: +**/*.html \ No newline at end of file diff --git a/superglue/lib/index.tsx b/superglue/lib/index.tsx index 585b2e79..808035bf 100644 --- a/superglue/lib/index.tsx +++ b/superglue/lib/index.tsx @@ -56,11 +56,11 @@ function pageToInitialState(key: string, page: VisitResponse) { const nextPage: Page = { ...page, pageKey: key, //TODO remove this - savedAt: Date.now() + savedAt: Date.now(), } return { - pages: { [key]: nextPage}, + pages: { [key]: nextPage }, ...slices, } } @@ -70,7 +70,12 @@ function start({ baseUrl = config.baseUrl, maxPages = config.maxPages, path, -}: {initialPage: VisitResponse, baseUrl: string, maxPages?: number, path: string}) { +}: { + initialPage: VisitResponse + baseUrl: string + maxPages?: number + path: string +}) { const initialPageKey = urlToPageKey(parse(path).href) const { csrfToken } = initialPage const location = parse(path) @@ -97,24 +102,17 @@ function start({ } } -class NotImplementedError extends Error { - constructor(message: string) { - super(message) - this.name = this.constructor.name - } -} - interface Props { initialPage: VisitResponse baseUrl: string path: string appEl: HTMLElement } - + type ConnectedMapping = Record< - string, - ConnectedComponent - > + string, + ConnectedComponent +> export abstract class ApplicationBase extends React.Component { public hasWindow: boolean @@ -122,7 +120,7 @@ export abstract class ApplicationBase extends React.Component { public initialPageKey: string public store: SuperglueStore public history: History - public connectedMapping: ConnectedMapping + public connectedMapping: ConnectedMapping public ujsHandlers: Handlers public visit: Visit public remote: Remote @@ -176,12 +174,11 @@ export abstract class ApplicationBase extends React.Component { this.remote = remote } - visitAndRemote( + abstract visitAndRemote( // eslint-disable-next-line - navigatorRef: React.RefObject