From 9994e1954f5237304d28933bd36b1e5abb62b77c Mon Sep 17 00:00:00 2001 From: redonkulus Date: Mon, 9 Dec 2024 11:45:42 -0800 Subject: [PATCH] chore: update prettier --- CHANGELOG.md | 68 +++++++++++++++++++-------------------- LICENSE.md | 16 ++++----- README.md | 10 +++--- docs/routr.md | 30 ++++++++--------- examples/server/README.md | 4 +-- package-lock.json | 9 +++--- package.json | 2 +- 7 files changed, 70 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c70592..304e453 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,13 @@ ## 3.0.1 -- [#114] fix handling of array like query params +- [#114] fix handling of array like query params ## 3.0.0 ### Breaking Changes -- [#110] `routr` uses native `URLSearchParams` instead of `query-string` to parse query strings. As a consequence, parsing `?foo` will result in `{ foo: '' }` as specified in the [WHATWG spec](https://url.spec.whatwg.org/#interface-urlsearchparams) instead of `{ foo: null }` as `query-string` would do. Also, `URLSearchParams` is not available in older browsers (noticeably IE11). If you need to support them, you can either add a `URLSearchParams` polyfill or inject `query-string` when instantiating `routr`: +- [#110] `routr` uses native `URLSearchParams` instead of `query-string` to parse query strings. As a consequence, parsing `?foo` will result in `{ foo: '' }` as specified in the [WHATWG spec](https://url.spec.whatwg.org/#interface-urlsearchparams) instead of `{ foo: null }` as `query-string` would do. Also, `URLSearchParams` is not available in older browsers (noticeably IE11). If you need to support them, you can either add a `URLSearchParams` polyfill or inject `query-string` when instantiating `routr`: ```js router = new Routr(routes, { @@ -16,105 +16,105 @@ router = new Routr(routes, { }); ``` -- [#113] Updated `path-to-regexp` to its latest version +- [#113] Updated `path-to-regexp` to its latest version ## 2.1.0 -- [#37] Enhance makePath for routes with path array +- [#37] Enhance makePath for routes with path array ## 2.0.2 -- [#36] Bug fix: Add support for question marks in hash fragments +- [#36] Bug fix: Add support for question marks in hash fragments ## 2.0.1 -- [#35] Fix decodeURIComponent of undefined bug +- [#35] Fix decodeURIComponent of undefined bug ## 2.0.0 ### Breaking Changes -- [#33] `getRoute` will now `decodeURIComponent` route values, you might need to remove `decodeURIComponent` from your route actions if you were supporting extended characters manually in your routes. +- [#33] `getRoute` will now `decodeURIComponent` route values, you might need to remove `decodeURIComponent` from your route actions if you were supporting extended characters manually in your routes. ## 1.0.0 ### Breaking Changes -- [#29] `navigate` is no longer used as part of `router.getRoute` options -- [#29] `route.navigate` has been removed from the matched route object +- [#29] `navigate` is no longer used as part of `router.getRoute` options +- [#29] `route.navigate` has been removed from the matched route object ### Features -- [#30] Route definitions should now be defined as an array of route objects - rather than a map of routes. The old method of defining routes - with a map is still supported, but ordering can not be guaranteed - (as per the JavaScript engine's implementation). -- [#31] Added support for parsing and constructing urls with query strings. - Matched route objects now contain a `query` property containing the map of - query parameters. `router.makePath` now accepts a third `query` parameter - which is a map of query parameters to add to the resulting URL string. e.g. - `router.makePath('home', {}, { foo: 'bar' });` will result in `/?foo=bar`. - Query strings are generated using the `query-string` npm module, but can - be customized by adding the `options.queryLib` to the `Router` constructor. - The replacement should have a `parse` and `stringify` method similar to - `query-string`. An example replacement would be `qs`. -- [#32] Allow routes to match multiple HTTP methods by using an array - for the `route.method` attribute. By default, routes with an undefined - `method` will match ANY method. +- [#30] Route definitions should now be defined as an array of route objects + rather than a map of routes. The old method of defining routes + with a map is still supported, but ordering can not be guaranteed + (as per the JavaScript engine's implementation). +- [#31] Added support for parsing and constructing urls with query strings. + Matched route objects now contain a `query` property containing the map of + query parameters. `router.makePath` now accepts a third `query` parameter + which is a map of query parameters to add to the resulting URL string. e.g. + `router.makePath('home', {}, { foo: 'bar' });` will result in `/?foo=bar`. + Query strings are generated using the `query-string` npm module, but can + be customized by adding the `options.queryLib` to the `Router` constructor. + The replacement should have a `parse` and `stringify` method similar to + `query-string`. An example replacement would be `qs`. +- [#32] Allow routes to match multiple HTTP methods by using an array + for the `route.method` attribute. By default, routes with an undefined + `method` will match ANY method. ## 0.1.3 ### Features -- [#27] Support for array paths with parameter name collision +- [#27] Support for array paths with parameter name collision ## 0.1.2 ### Internal -- Replace `reverand` with `path-to-regexp` for creation of paths +- Replace `reverand` with `path-to-regexp` for creation of paths ## 0.1.1 ### Features -- [#22] Make route methods case-insensitive +- [#22] Make route methods case-insensitive ## 0.1.0 ### Breaking Change -- Renamed "path" field to "url" in the return object of getRoute() +- Renamed "path" field to "url" in the return object of getRoute() ## 0.0.6 ### Internal -- Update devDependencies and Readme +- Update devDependencies and Readme ## 0.0.5 ### Features -- Freeze route objects in non-production environments +- Freeze route objects in non-production environments ## 0.0.4 ### Features -- Allow matching paths containing query strings +- Allow matching paths containing query strings ## 0.0.3 ### Features -- Updated dependencies +- Updated dependencies ## 0.0.2 ### Features -- [#2] Introduction of `navigate` property under route +- [#2] Introduction of `navigate` property under route ## 0.0.1 diff --git a/LICENSE.md b/LICENSE.md index b2d8394..976890a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -6,14 +6,14 @@ Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. -- Neither the name of Yahoo! Inc. nor the names of YUI's contributors may be - used to endorse or promote products derived from this software without - specific prior written permission of Yahoo! Inc. +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +- Neither the name of Yahoo! Inc. nor the names of YUI's contributors may be + used to endorse or promote products derived from this software without + specific prior written permission of Yahoo! Inc. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED diff --git a/README.md b/README.md index 8aa0ce8..01f639a 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ We use `if (process.env.NODE_ENV !== 'production')` to wrap around `Object.freez Two main utility plugins: -- use [DefinePlugin](http://webpack.github.io/docs/list-of-plugins.html#defineplugin) to define the value for `process.env` -- use [UglifyJsPlugin](http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin) to remove dead code. +- use [DefinePlugin](http://webpack.github.io/docs/list-of-plugins.html#defineplugin) to define the value for `process.env` +- use [UglifyJsPlugin](http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin) to remove dead code. Example of the webpack configuration: @@ -83,8 +83,8 @@ Example of the webpack configuration: Similar to webpack, you can also use the following two utils with your favorite build system: -- use [envify](https://github.com/hughsk/envify) to set `process.env.NODE_ENV` to the desired environment -- use [uglifyjs](https://github.com/mishoo/UglifyJS2) to remove dead code. +- use [envify](https://github.com/hughsk/envify) to set `process.env.NODE_ENV` to the desired environment +- use [uglifyjs](https://github.com/mishoo/UglifyJS2) to remove dead code. Command-line example: @@ -94,7 +94,7 @@ $ browserify index.js -t [ envify --NODE_ENV production ] | uglifyjs -c > bundl ## API -- [Routr](https://github.com/yahoo/routr/blob/master/docs/routr.md) +- [Routr](https://github.com/yahoo/routr/blob/master/docs/routr.md) ## License diff --git a/docs/routr.md b/docs/routr.md index a2f759f..e45744d 100644 --- a/docs/routr.md +++ b/docs/routr.md @@ -4,15 +4,15 @@ Creates a new routr plugin instance with the following parameters: -- `routes` (optional): Ordered list of routes used for matching. - ** `route.name`: Name of the route (used for path making) - ** `route.path`: The matching pattern of the route. Follows rules of [path-to-regexp](https://github - .com/pillarjs/path-to-regexp) - \*\* `route.method=undefined`: The method that the path should match to. Will match all methods if `undefined` and no - methods - if `null`. -- `options` (optional): Options for parsing and generating the urls - \*\* `options.queryLib=require('query-string')`: Library to use to `parse` and `stringify` query strings +- `routes` (optional): Ordered list of routes used for matching. + ** `route.name`: Name of the route (used for path making) + ** `route.path`: The matching pattern of the route. Follows rules of [path-to-regexp](https://github + .com/pillarjs/path-to-regexp) + \*\* `route.method=undefined`: The method that the path should match to. Will match all methods if `undefined` and no + methods + if `null`. +- `options` (optional): Options for parsing and generating the urls + \*\* `options.queryLib=require('query-string')`: Library to use to `parse` and `stringify` query strings ## Instance Methods @@ -20,14 +20,14 @@ Creates a new routr plugin instance with the following parameters: Returns the matched route info if path/method matches to a route; null otherwise. -- `url` (required) The url to be used for route matching. Query strings are **not** considered when performing the match. -- `options` options object -- `options.method` (optional) The case-insensitive HTTP method string. DEFAULT: 'get' +- `url` (required) The url to be used for route matching. Query strings are **not** considered when performing the match. +- `options` options object +- `options.method` (optional) The case-insensitive HTTP method string. DEFAULT: 'get' ### makePath(name, params, query) Generates a path string with the route with the given name, using the specified params. -- `name` (required) The route name -- `params` (required) The route parameters to be used to create the path string -- `query` (optional) The query parameters to be used to create the path string +- `name` (required) The route name +- `params` (required) The route parameters to be used to create the path string +- `query` (optional) The query parameters to be used to create the path string diff --git a/examples/server/README.md b/examples/server/README.md index b832235..0a5aac1 100644 --- a/examples/server/README.md +++ b/examples/server/README.md @@ -9,5 +9,5 @@ node app.js Then try: -- http://localhost:3000/user/superman -- http://localhost:3000/user/superman/post/how-i-saved-the-city +- http://localhost:3000/user/superman +- http://localhost:3000/user/superman/post/how-i-saved-the-city diff --git a/package-lock.json b/package-lock.json index 052b85c..b276878 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "eslint": "^9.0.0", "jest": "^29.0.0", "pre-commit": "^1.0.7", - "prettier": "^3.0.0" + "prettier": "^3.4.2" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -3937,10 +3937,11 @@ } }, "node_modules/prettier": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", - "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz", + "integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==", "dev": true, + "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" }, diff --git a/package.json b/package.json index 95d731f..b565bfc 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "eslint": "^9.0.0", "jest": "^29.0.0", "pre-commit": "^1.0.7", - "prettier": "^3.0.0" + "prettier": "^3.4.2" }, "pre-commit": [ "lint",