Apply standard/enforced code format with prettier.
This commit marks applying prettier to the whole of git history up to this point and prettier is used to enforce format via pre-commit hook. The command used was: `git filter-branch -f --tree-filter 'prettier --no-config --single-quote --tab-width=1 --print-width=100 --use-tabs --trailing-comma=none --prose-wrap=always --write "{.,{packages,bin}/**}/*.{js,json,md}" || echo "Error formatting, possibly invalid JS"' -- --all`
This commit is contained in:
parent
dde7bb3e70
commit
3328248274
@ -35,7 +35,7 @@ silly.
|
|||||||
|
|
||||||
These are `npm --global` dependencies:
|
These are `npm --global` dependencies:
|
||||||
|
|
||||||
* [Lerna 2.0.0](https://lernajs.io/)
|
- [Lerna 2.0.0](https://lernajs.io/)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
|||||||
4
bin/pre-commit.sh
Normal file
4
bin/pre-commit.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
nodejs node_modules/lerna/bin/lerna.js run pre-commit\
|
||||||
|
&& npm run check_code_format
|
||||||
@ -12,7 +12,8 @@ const CDP = require('chrome-remote-interface');
|
|||||||
const SPEC_DIR = 'spec';
|
const SPEC_DIR = 'spec';
|
||||||
const TEST_FILENAME = '.spec_runner.html';
|
const TEST_FILENAME = '.spec_runner.html';
|
||||||
const HOST = '127.0.0.1';
|
const HOST = '127.0.0.1';
|
||||||
const PORT = 10080;
|
// Randomize the port so we can just run again if there's a stuck process.
|
||||||
|
const PORT = Math.floor(Math.random() * 40000) + 1025;
|
||||||
|
|
||||||
const DEBUG =
|
const DEBUG =
|
||||||
typeof process.env['DEBUG'] === 'string'
|
typeof process.env['DEBUG'] === 'string'
|
||||||
@ -150,7 +151,9 @@ async function runTestsInChrome() {
|
|||||||
|
|
||||||
Network.requestWillBeSent(result => reqMap.set(result.requestId, result.request.url));
|
Network.requestWillBeSent(result => reqMap.set(result.requestId, result.request.url));
|
||||||
Network.loadingFailed(result =>
|
Network.loadingFailed(result =>
|
||||||
consolePrint(`\x1b[31mNetwork Error: ${result.errorText} for ${reqMap.get(result.requestId)}`)
|
consolePrint(
|
||||||
|
`\x1b[31mNetwork Error: ${result.errorText} for ${reqMap.get(result.requestId)}`
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Runtime.exceptionThrown(result =>
|
Runtime.exceptionThrown(result =>
|
||||||
|
|||||||
@ -5,9 +5,13 @@
|
|||||||
"husky": "1.0.0-rc.13",
|
"husky": "1.0.0-rc.13",
|
||||||
"lerna": "2.0.0-beta.32"
|
"lerna": "2.0.0-beta.32"
|
||||||
},
|
},
|
||||||
|
"scripts": {
|
||||||
|
"check_code_format": "nodejs node_modules/prettier/bin-prettier.js --config ./prettier.config.js --list-different \"{.,{packages,bin}/**/!(dist)}/*.{js,json,md}\"",
|
||||||
|
"format_code": "nodejs node_modules/prettier/bin-prettier.js --config ./prettier.config.js --write \"{.,{packages,bin}/**/!(dist)}/*.{js,json,md}\""
|
||||||
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "lerna run pre-commit"
|
"pre-commit": "sh ./bin/pre-commit.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -284,7 +284,7 @@ container.
|
|||||||
|
|
||||||
FRPTools is the result of years of learning from the following projects:
|
FRPTools is the result of years of learning from the following projects:
|
||||||
|
|
||||||
* [KnockoutJS](http://knockoutjs.com/)
|
- [KnockoutJS](http://knockoutjs.com/)
|
||||||
* [Overture](https://github.com/fastmail/overture)
|
- [Overture](https://github.com/fastmail/overture)
|
||||||
* [Redux](https://redux.js.org/)
|
- [Redux](https://redux.js.org/)
|
||||||
* [Mithril](https://mithril.js.org/)
|
- [Mithril](https://mithril.js.org/)
|
||||||
|
|||||||
@ -3,12 +3,16 @@
|
|||||||
"version": "3.2.1",
|
"version": "3.2.1",
|
||||||
"description": "Observable Property and Computed data streams",
|
"description": "Observable Property and Computed data streams",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"files": ["src"],
|
"files": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node ../../bin/runTests.js ./",
|
"test": "node ../../bin/runTests.js ./",
|
||||||
"pre-commit": "npm run test"
|
"pre-commit": "npm run test"
|
||||||
},
|
},
|
||||||
"keywords": ["reactive"],
|
"keywords": [
|
||||||
|
"reactive"
|
||||||
|
],
|
||||||
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,8 +5,8 @@ myself and to share with friends and family. Along the way it became a learning
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* Upload and view images
|
- Upload and view images
|
||||||
* Save files to Backblaze B2 storage.
|
- Save files to Backblaze B2 storage.
|
||||||
|
|
||||||
## Development Philosophy
|
## Development Philosophy
|
||||||
|
|
||||||
@ -19,9 +19,9 @@ photo gallery for anyone who wishes to escape the social media silos. However, i
|
|||||||
|
|
||||||
This would not be possible without the giants who have laid the foundation:
|
This would not be possible without the giants who have laid the foundation:
|
||||||
|
|
||||||
* [Webpack](http://webpack.js.org/)
|
- [Webpack](http://webpack.js.org/)
|
||||||
* [DOMVM](http://leeoniya.github.io/domvm/)
|
- [DOMVM](http://leeoniya.github.io/domvm/)
|
||||||
* [PouchDB](https://pouchdb.com/)
|
- [PouchDB](https://pouchdb.com/)
|
||||||
|
|
||||||
There are many more dependencies. You can find them in the [package.json](./package.json) file.
|
There are many more dependencies. You can find them in the [package.json](./package.json) file.
|
||||||
|
|
||||||
@ -36,12 +36,12 @@ localhost certificate exception in order to operate properly.
|
|||||||
|
|
||||||
In the future, I plan to add:
|
In the future, I plan to add:
|
||||||
|
|
||||||
* sharable links
|
- sharable links
|
||||||
* local file storage
|
- local file storage
|
||||||
* CSRF for interacting with server component
|
- CSRF for interacting with server component
|
||||||
* albums
|
- albums
|
||||||
* client-side encryption
|
- client-side encryption
|
||||||
* video support
|
- video support
|
||||||
* Sandstorm support
|
- Sandstorm support
|
||||||
* CORS-based storage: - s3 - remotestorage - Google Cloud? - Dropbox?
|
- CORS-based storage: - s3 - remotestorage - Google Cloud? - Dropbox?
|
||||||
* tags
|
- tags
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
"name": "Gallery",
|
"name": "Gallery",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "Personal photo gallery",
|
"description": "Personal photo gallery",
|
||||||
"keywords": ["javascript"],
|
"keywords": [
|
||||||
|
"javascript"
|
||||||
|
],
|
||||||
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -50,11 +50,11 @@ export function FocusView(vm, params) {
|
|||||||
if (windowRatio > imageRatio) {
|
if (windowRatio > imageRatio) {
|
||||||
return {
|
return {
|
||||||
height: vw / windowRatio,
|
height: vw / windowRatio,
|
||||||
width: vw / windowRatio * imageRatio
|
width: (vw / windowRatio) * imageRatio
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
height: vh * windowRatio / imageRatio,
|
height: (vh * windowRatio) / imageRatio,
|
||||||
width: vh * windowRatio
|
width: vh * windowRatio
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -32,7 +32,7 @@ export function SectionView(vm, params, key) {
|
|||||||
const availableWidth = vw - CONTENT_MARGIN_WIDTH;
|
const availableWidth = vw - CONTENT_MARGIN_WIDTH;
|
||||||
const aspectRatios = pArr.map(aspectRatio);
|
const aspectRatios = pArr.map(aspectRatio);
|
||||||
const totalImageRatio = sum(aspectRatios);
|
const totalImageRatio = sum(aspectRatios);
|
||||||
const rowCount = Math.ceil(totalImageRatio * OPTIMAL_IMAGE_HEIGHT / availableWidth);
|
const rowCount = Math.ceil((totalImageRatio * OPTIMAL_IMAGE_HEIGHT) / availableWidth);
|
||||||
const rowRatios = partition(aspectRatios, rowCount);
|
const rowRatios = partition(aspectRatios, rowCount);
|
||||||
|
|
||||||
let index = 0;
|
let index = 0;
|
||||||
@ -41,7 +41,7 @@ export function SectionView(vm, params, key) {
|
|||||||
const rowTotal = sum(row);
|
const rowTotal = sum(row);
|
||||||
const imageRatio = row[0];
|
const imageRatio = row[0];
|
||||||
const portion = imageRatio / rowTotal;
|
const portion = imageRatio / rowTotal;
|
||||||
let rowHeight = availableWidth * portion / aspectRatio(pArr[index]);
|
let rowHeight = (availableWidth * portion) / aspectRatio(pArr[index]);
|
||||||
if (rowHeight > OPTIMAL_IMAGE_HEIGHT * ROW_HEIGHT_CUTOFF_MODIFIER) {
|
if (rowHeight > OPTIMAL_IMAGE_HEIGHT * ROW_HEIGHT_CUTOFF_MODIFIER) {
|
||||||
rowHeight = OPTIMAL_IMAGE_HEIGHT * ROW_HEIGHT_CUTOFF_MODIFIER;
|
rowHeight = OPTIMAL_IMAGE_HEIGHT * ROW_HEIGHT_CUTOFF_MODIFIER;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,17 @@
|
|||||||
"version": "0.9.0",
|
"version": "0.9.0",
|
||||||
"description": "Expose an API to a web worker and its parent",
|
"description": "Expose an API to a web worker and its parent",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"files": ["src"],
|
"files": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node ../../bin/runTests.js ./",
|
"test": "node ../../bin/runTests.js ./",
|
||||||
"pre-commit": "npm run test"
|
"pre-commit": "npm run test"
|
||||||
},
|
},
|
||||||
"keywords": ["worker", "webworker"],
|
"keywords": [
|
||||||
|
"worker",
|
||||||
|
"webworker"
|
||||||
|
],
|
||||||
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,11 @@
|
|||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"description": "Document Management Layer for PouchDB",
|
"description": "Document Management Layer for PouchDB",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"files": ["dist", "lib", "src"],
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"lib",
|
||||||
|
"src"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node ../../bin/runTests.js ./",
|
"test": "node ../../bin/runTests.js ./",
|
||||||
"pre-commit": "npm run test"
|
"pre-commit": "npm run test"
|
||||||
|
|||||||
@ -3,9 +3,13 @@
|
|||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"description": "A DOM-abstraction communicator",
|
"description": "A DOM-abstraction communicator",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"files": ["src"],
|
"files": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
"keywords": ["router"],
|
"keywords": [
|
||||||
|
"router"
|
||||||
|
],
|
||||||
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -16,43 +16,43 @@ const router = Router(routeSpecArray, rootURL='#'):
|
|||||||
|
|
||||||
An array of objects with the following properties:
|
An array of objects with the following properties:
|
||||||
|
|
||||||
* `name` _string_ - an optional string that can be referred to in the `href` and `goto` instance
|
- `name` _string_ - an optional string that can be referred to in the `href` and `goto` instance
|
||||||
methods. Duplicate names are not allowed.
|
methods. Duplicate names are not allowed.
|
||||||
|
|
||||||
* `path` _string_ - the path template for this route. Path templates are matched in the order of the
|
- `path` _string_ - the path template for this route. Path templates are matched in the order of the
|
||||||
array. Example:
|
array. Example:
|
||||||
|
|
||||||
`"/"` - for the root path `"/articles"` - another static path `"/article/:id"` - a path with a
|
`"/"` - for the root path `"/articles"` - another static path `"/article/:id"` - a path with a
|
||||||
variable `"/:unknownRoute"` - the last route could catch erroneous routes. Unmatched urls will
|
variable `"/:unknownRoute"` - the last route could catch erroneous routes. Unmatched urls will
|
||||||
automatically route here.
|
automatically route here.
|
||||||
|
|
||||||
* `vars` _object_ - an optional object mapping variable names in the path template to a regular
|
- `vars` _object_ - an optional object mapping variable names in the path template to a regular
|
||||||
expression for validation
|
expression for validation
|
||||||
|
|
||||||
* `enter` _function_ - a function for when this route is entered. The `enter` function receives two
|
- `enter` _function_ - a function for when this route is entered. The `enter` function receives two
|
||||||
parameters:
|
parameters:
|
||||||
|
|
||||||
* _route instance object_ - this is a object that contains properties:
|
- _route instance object_ - this is a object that contains properties:
|
||||||
|
|
||||||
* `name` _string_ - the route name
|
- `name` _string_ - the route name
|
||||||
* `vars` _object_ - an object holding any variables parsed from the path
|
- `vars` _object_ - an object holding any variables parsed from the path
|
||||||
* `path` _string_ - the path as received
|
- `path` _string_ - the path as received
|
||||||
|
|
||||||
* _router instance object_ - (see below)
|
- _router instance object_ - (see below)
|
||||||
|
|
||||||
The `enter` function may return a callback that will be called instead of the `enter` function for
|
The `enter` function may return a callback that will be called instead of the `enter` function for
|
||||||
further navigate events that will be handled by this route (with different variables). This allows
|
further navigate events that will be handled by this route (with different variables). This allows
|
||||||
`enter` to establish a context for the route it handles.
|
`enter` to establish a context for the route it handles.
|
||||||
|
|
||||||
* `exit` _function_ - an optional function that will be called before calling `enter` of the next
|
- `exit` _function_ - an optional function that will be called before calling `enter` of the next
|
||||||
path. `exit` has the option to delay the call to `enter` by returning a promise. This is intended
|
path. `exit` has the option to delay the call to `enter` by returning a promise. This is intended
|
||||||
for handling transition animations. If the route's `enter` function returns a callback, `exit`
|
for handling transition animations. If the route's `enter` function returns a callback, `exit`
|
||||||
will not be called if the same route receives navigation but with different variables. `exit`
|
will not be called if the same route receives navigation but with different variables. `exit`
|
||||||
receives the parameters similarly to `enter`:
|
receives the parameters similarly to `enter`:
|
||||||
|
|
||||||
* _route instance object_ - for the route being exited
|
- _route instance object_ - for the route being exited
|
||||||
* _route instance object_ - for the route yet-to-be entered
|
- _route instance object_ - for the route yet-to-be entered
|
||||||
* _router instance object_ - (see below)
|
- _router instance object_ - (see below)
|
||||||
|
|
||||||
### rootURL (optional string)
|
### rootURL (optional string)
|
||||||
|
|
||||||
@ -62,24 +62,24 @@ The url prefix of all paths. This should always be `#` unless you're nesting rou
|
|||||||
|
|
||||||
The returned instance provides these methods:
|
The returned instance provides these methods:
|
||||||
|
|
||||||
* `goto(url: string)` or `goto(pathName: string, vars: object)`
|
- `goto(url: string)` or `goto(pathName: string, vars: object)`
|
||||||
|
|
||||||
Match to a route by relative url or pathName and a vars object. Navigate there.
|
Match to a route by relative url or pathName and a vars object. Navigate there.
|
||||||
|
|
||||||
* `href(pathName: string, vars: object)`
|
- `href(pathName: string, vars: object)`
|
||||||
|
|
||||||
Build a relative url based on the name and supplied vars.
|
Build a relative url based on the name and supplied vars.
|
||||||
|
|
||||||
* `start(initialRoute: string)`
|
- `start(initialRoute: string)`
|
||||||
|
|
||||||
Listen to `window.onhashchange` for route changes. The `initialRoute` will be passed to `goto()`
|
Listen to `window.onhashchange` for route changes. The `initialRoute` will be passed to `goto()`
|
||||||
if there is no current route in `window.location`.
|
if there is no current route in `window.location`.
|
||||||
|
|
||||||
* `stop()`
|
- `stop()`
|
||||||
|
|
||||||
Cancel subscription to `window.onhashchange`
|
Cancel subscription to `window.onhashchange`
|
||||||
|
|
||||||
* `current()`
|
- `current()`
|
||||||
|
|
||||||
Get the current _route instance object_ as was provided to the current routes `enter` function.
|
Get the current _route instance object_ as was provided to the current routes `enter` function.
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,16 @@
|
|||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"description": "A slim and unopinionated router",
|
"description": "A slim and unopinionated router",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"files": ["src"],
|
"files": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node ../../bin/runTests.js ./",
|
"test": "node ../../bin/runTests.js ./",
|
||||||
"pre-commit": "npm run test"
|
"pre-commit": "npm run test"
|
||||||
},
|
},
|
||||||
"keywords": ["router"],
|
"keywords": [
|
||||||
|
"router"
|
||||||
|
],
|
||||||
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -37,16 +37,16 @@ pre-compression gains can result in post-compression losses. YMMV.
|
|||||||
|
|
||||||
# Abstractions
|
# Abstractions
|
||||||
|
|
||||||
* `undefined`
|
- `undefined`
|
||||||
* `requestAnimationFrame`
|
- `requestAnimationFrame`
|
||||||
* `Array.isArray`
|
- `Array.isArray`
|
||||||
* `Array.from`
|
- `Array.from`
|
||||||
* `Object.keys`
|
- `Object.keys`
|
||||||
* `document`
|
- `document`
|
||||||
* `typeof obj === 'function'`
|
- `typeof obj === 'function'`
|
||||||
* `typeof obj === 'string'`
|
- `typeof obj === 'string'`
|
||||||
* `typeof obj === 'number'`
|
- `typeof obj === 'number'`
|
||||||
* `null`
|
- `null`
|
||||||
* `obj === undefined`
|
- `obj === undefined`
|
||||||
* `obj === null`
|
- `obj === null`
|
||||||
* `fn.apply(context, params)`
|
- `fn.apply(context, params)`
|
||||||
|
|||||||
@ -3,8 +3,12 @@
|
|||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"description": "Javascript and DOM abstractions for smaller minifiable code",
|
"description": "Javascript and DOM abstractions for smaller minifiable code",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"files": ["src"],
|
"files": [
|
||||||
"keywords": ["javascript"],
|
"src"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"javascript"
|
||||||
|
],
|
||||||
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
"author": "Timothy Farrell <tim@thecookiejar.me> (https://github.com/explorigin)",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
}
|
}
|
||||||
|
|||||||
12
prettier.config.js
Normal file
12
prettier.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module.exports = {
|
||||||
|
printWidth: 100,
|
||||||
|
tabWidth: 1,
|
||||||
|
useTabs: true,
|
||||||
|
singleQuote: true,
|
||||||
|
trailingComma: 'none',
|
||||||
|
bracketSpacing: true,
|
||||||
|
semi: true,
|
||||||
|
requirePragma: false,
|
||||||
|
proseWrap: 'always',
|
||||||
|
arrowParens: 'avoid'
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user