Skip to content

Commit

Permalink
chore: Format dev with Prettier defaults (#942)
Browse files Browse the repository at this point in the history
* chore: use default prettier config
* chore: add format script and update prettier
* chore: format with prettier
  • Loading branch information
chaance authored Feb 22, 2022
1 parent c9bc27d commit 3e9dab4
Show file tree
Hide file tree
Showing 44 changed files with 714 additions and 716 deletions.
1 change: 0 additions & 1 deletion .github/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ lockLabel: false

# Comment to post before locking. Set to `false` to disable
lockComment: false

# Limit to only `issues` or `pulls`
# only: issues

Expand Down
5 changes: 1 addition & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
{
"singleQuote": true,
"trailingComma": "none"
}
{}
12 changes: 6 additions & 6 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ A browser history object keeps track of the browsing history of an application u
`createBrowserHistory` returns a `BrowserHistory` instance. `window` defaults to [the `defaultView` of the current `document`](https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView).

```ts
import { createBrowserHistory } from 'history';
import { createBrowserHistory } from "history";
let history = createBrowserHistory();
```

Expand Down Expand Up @@ -150,8 +150,8 @@ interface Path {
The `createPath` and `parsePath` functions are useful for creating and parsing URL paths.

```ts
createPath({ pathname: '/login', search: '?next=home' }); // "/login?next=home"
parsePath('/login?next=home'); // { pathname: '/login', search: '?next=home' }
createPath({ pathname: "/login", search: "?next=home" }); // "/login?next=home"
parsePath("/login?next=home"); // { pathname: '/login', search: '?next=home' }
```

<a name="createhashhistory"></a>
Expand All @@ -177,7 +177,7 @@ A hash history object keeps track of the browsing history of an application usin
The main difference between this and [browser history](#createbrowserhistory) is that a hash history stores the current location in the [`hash` portion of the URL](https://developer.mozilla.org/en-US/docs/Web/API/Location/hash#:~:text=The%20hash%20property%20of%20the,an%20empty%20string%2C%20%22%22%20.), which means that it is not ever sent to the server. This can be useful if you are hosting your site on a domain where you do not have full control over the server routes, or e.g. in an Electron app where you don't want to configure the "server" to serve the same page at different URLs.

```ts
import { createHashHistory } from 'history';
import { createHashHistory } from "history";
let history = createHashHistory();
```

Expand Down Expand Up @@ -211,11 +211,11 @@ A memory history object keeps track of the browsing history of an application us
`createMemoryHistory` returns a `MemoryHistory` instance. You can provide initial entries to this history instance through the `initialEntries` property, which defaults to `['/']` (a single location at the root `/` URL). The `initialIndex` defaults to the index of the last item in `initialEntries`.

```ts
import { createMemoryHistory } from 'history';
import { createMemoryHistory } from "history";
let history = createMemoryHistory();
// Or, to pre-seed the history instance with some URLs:
let history = createMemoryHistory({
initialEntries: ['/home', '/profile', '/about']
initialEntries: ["/home", "/profile", "/about"],
});
```

Expand Down
2 changes: 1 addition & 1 deletion docs/blocking-transitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ they will lose some unsaved changes they've made.
```js
// Block navigation and register a callback that
// fires when a navigation attempt is blocked.
let unblock = history.block(tx => {
let unblock = history.block((tx) => {
// Navigation was blocked! Let's show a confirmation dialog
// so the user can decide if they actually want to navigate
// away and discard changes they've made in the current page.
Expand Down
16 changes: 8 additions & 8 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Basic usage looks like this:

```js
// Create your own history instance.
import { createBrowserHistory } from 'history';
import { createBrowserHistory } from "history";
let history = createBrowserHistory();

// ... or just import the browser history singleton instance.
import history from 'history/browser';
import history from "history/browser";

// Alternatively, if you're using hash history import
// the hash history singleton instance.
Expand All @@ -42,10 +42,10 @@ let unlisten = history.listen(({ location, action }) => {
});

// Use push to push a new entry onto the history stack.
history.push('/home', { some: 'state' });
history.push("/home", { some: "state" });

// Use replace to replace the current entry in the stack.
history.replace('/logged-in');
history.replace("/logged-in");

// Use back/forward to navigate one entry back or forward.
history.back();
Expand All @@ -58,7 +58,7 @@ If you're using memory history you'll need to create your own `history` object
before you can use it.

```js
import { createMemoryHistory } from 'history';
import { createMemoryHistory } from "history";
let history = createMemoryHistory();
```

Expand All @@ -67,9 +67,9 @@ current `document` (like an iframe), you'll need to create your own browser/hash
history:

```js
import { createBrowserHistory } from 'history';
import { createBrowserHistory } from "history";
let history = createBrowserHistory({
window: iframe.contentWindow
window: iframe.contentWindow,
});
```

Expand Down Expand Up @@ -134,7 +134,7 @@ unlisten();
The main history bundle also contains both `createPath` and `parsePath` methods that may be useful when working with URL paths.

```js
let pathPieces = parsePath('/the/path?the=query#the-hash');
let pathPieces = parsePath("/the/path?the=query#the-hash");
// pathPieces = {
// pathname: '/the/path',
// search: '?the=query',
Expand Down
10 changes: 5 additions & 5 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ versions of Webpack and Parcel are also good choices.
Then you can write your code using JavaScript `import` statements, like this:

```js
import { createBrowserHistory } from 'history';
import { createBrowserHistory } from "history";
// ...
```

If you're using a bundler that doesn't understand JavaScript modules and only
understands CommonJS, you can use `require` as you would with anything else:

```js
var createBrowserHistory = require('history').createBrowserHistory;
var createBrowserHistory = require("history").createBrowserHistory;
```

## Using `<script>` Tags
Expand All @@ -35,9 +35,9 @@ just use the `history.production.min.js` build:

```html
<script type="module">
// Can also use history.development.js in development
import { createBrowserHistory } from 'https://unpkg.com/history/history.production.min.js';
// ...
// Can also use history.development.js in development
import { createBrowserHistory } from "https://unpkg.com/history/history.production.min.js";
// ...
</script>
```

Expand Down
19 changes: 11 additions & 8 deletions docs/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ An example:

```js
// Push a new entry onto the history stack.
history.push('/home');
history.push("/home");

// Push a new entry onto the history stack with a query string
// and some state. Location state does not appear in the URL.
history.push('/home?the=query', { some: 'state' });
history.push("/home?the=query", { some: "state" });

// If you prefer, use a location-like object to specify the URL.
// This is equivalent to the example above.
history.push({
pathname: '/home',
search: '?the=query'
}, {
some: state
});
history.push(
{
pathname: "/home",
search: "?the=query",
},
{
some: state,
}
);

// Go back to the previous history entry. The following
// two lines are synonymous.
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"build": "node ./scripts/build.js",
"clean": "git clean -fdX .",
"lint": "eslint .",
"format": "prettier --ignore-path .eslintignore --write .",
"publish": "node ./scripts/publish.js",
"size": "filesize",
"test": "node ./scripts/test.js",
Expand Down Expand Up @@ -47,7 +48,7 @@
"karma-sourcemap-loader": "0.3.8",
"karma-webpack": "^3.0.5",
"mocha": "^5.2.0",
"prettier": "^2.3.2",
"prettier": "^2.5.1",
"prompt-confirm": "^2.0.4",
"rollup": "^2.56.2",
"rollup-plugin-copy": "^3.4.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import expect from 'expect';
import expect from "expect";

import { execSteps } from './utils.js';
import { execSteps } from "./utils.js";

export default (history, done) => {
let hookWasCalled = false;
Expand All @@ -9,15 +9,15 @@ export default (history, done) => {
let steps = [
({ location }) => {
expect(location).toMatchObject({
pathname: '/'
pathname: "/",
});

history.push('/home');
history.push("/home");
},
({ action, location }) => {
expect(action).toBe('PUSH');
expect(action).toBe("PUSH");
expect(location).toMatchObject({
pathname: '/home'
pathname: "/home",
});

unblock = history.block(() => {
Expand All @@ -27,15 +27,15 @@ export default (history, done) => {
window.history.go(-1);
},
({ action, location }) => {
expect(action).toBe('POP');
expect(action).toBe("POP");
expect(location).toMatchObject({
pathname: '/'
pathname: "/",
});

expect(hookWasCalled).toBe(true);

unblock();
}
},
];

execSteps(steps, history, done);
Expand Down
12 changes: 6 additions & 6 deletions packages/history/__tests__/TestSequences/BlockEverything.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import expect from 'expect';
import expect from "expect";

import { execSteps } from './utils.js';
import { execSteps } from "./utils.js";

export default (history, done) => {
let steps = [
({ location }) => {
expect(location).toMatchObject({
pathname: '/'
pathname: "/",
});

let unblock = history.block();

history.push('/home');
history.push("/home");

expect(history.location).toMatchObject({
pathname: '/'
pathname: "/",
});

unblock();
}
},
];

execSteps(steps, history, done);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import expect from 'expect';
import expect from "expect";

export default (history, done) => {
expect(history.location).toMatchObject({
pathname: '/'
pathname: "/",
});

history.push('/home');
history.push("/home");

let transitionHookWasCalled = false;
let unblock = history.block(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import expect from 'expect';
import expect from "expect";

import { execSteps } from './utils.js';
import { execSteps } from "./utils.js";

export default (history, done) => {
let steps = [
() => {
// encoded string
let pathname = '/view/%23abc';
let pathname = "/view/%23abc";
history.replace(pathname);
},
({ location }) => {
expect(location).toMatchObject({
pathname: '/view/%23abc'
pathname: "/view/%23abc",
});
// encoded object
let pathname = '/view/%23abc';
let pathname = "/view/%23abc";
history.replace({ pathname });
},
({ location }) => {
expect(location).toMatchObject({
pathname: '/view/%23abc'
pathname: "/view/%23abc",
});
// unencoded string
let pathname = '/view/#abc';
let pathname = "/view/#abc";
history.replace(pathname);
},
({ location }) => {
expect(location).toMatchObject({
pathname: '/view/',
hash: '#abc'
pathname: "/view/",
hash: "#abc",
});
}
},
];

execSteps(steps, history, done);
Expand Down
Loading

0 comments on commit 3e9dab4

Please sign in to comment.