Skip to content

Commit

Permalink
fix: upgrade prettier to v2 (#131)
Browse files Browse the repository at this point in the history
* upgrade prettier to v2
* lint, fmt, docs; due to prettier v2

Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
  • Loading branch information
Charlike Mike Reagent committed Mar 27, 2020
1 parent eda3da1 commit 8b9f668
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 57 deletions.
2 changes: 1 addition & 1 deletion @configs/eslint-config/package.json
Expand Up @@ -51,7 +51,7 @@
},
"peerDependencies": {
"eslint": "^6.8.0",
"prettier": "^1.19.1"
"prettier": "^2.0.2"
},
"cov": {
"color": "grey"
Expand Down
2 changes: 1 addition & 1 deletion @configs/prettier-config/package.json
Expand Up @@ -32,7 +32,7 @@
},
"scripts": {},
"peerDependencies": {
"prettier": "^1.19.1",
"prettier": "^2.0.2",
"prettier-plugin-pkgjson": "^0.2.3"
},
"cov": {
Expand Down
5 changes: 1 addition & 4 deletions @packages/glob-cache/src/index.js
Expand Up @@ -183,10 +183,7 @@ globCache.stream = async function* globCacheStream(options) {

function hasha(value, opts) {
const { algorithm, digest } = { ...opts };
return crypto
.createHash(algorithm)
.update(value)
.digest(digest);
return crypto.createHash(algorithm).update(value).digest(digest);
}

function getIntegrityFor(contents, hash = 'sha512') {
Expand Down
6 changes: 3 additions & 3 deletions @packages/ip-filter/README.md
Expand Up @@ -180,8 +180,8 @@ are just related. So, thanks for your existance!
[homepage](https://github.com/micromatch/micromatch 'Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.')
- [to-file-path](https://www.npmjs.com/package/to-file-path): Create a filepath
from an object path (dot notation), list
[more](https://github.com/tunnckocore/to-file-path#readme) |
[homepage](https://github.com/tunnckocore/to-file-path#readme 'Create a filepath from an object path (dot notation), list of arguments, array, number or Arguments object.')
[more](https://tunnckocore.com/opensource) |
[homepage](https://tunnckocore.com/opensource 'Create a filepath from an object path (dot notation), list of arguments, array, number or Arguments object.')

**[back to top](#readme)**

Expand Down Expand Up @@ -335,7 +335,7 @@ Released under the [MPL-2.0 License][license-url].

<!-- prettier-ignore-end -->

[ip-filter]: https://github.com/tunnckocore/ip-filter
[ip-filter]: https://tunnckocore.com/opensource
[is-match]: https://github.com/jonschlinkert/is-match
[koa]: https://github.com/koajs/koa
[micromatch]: https://github.com/micromatch/micromatch
5 changes: 3 additions & 2 deletions @packages/jest-runner-docs/src/docks.js
Expand Up @@ -67,8 +67,9 @@ module.exports = function docks(filepath, options) {
}\n\n${signatureBlock}${params}\n${comment.examples
.map(
(example) =>
`\n${example.description.trim()}\n\n${examplesId}####${heading} Examples\n\n\`\`\`${example.language ||
'js'}${example.value}\`\`\``,
`\n${example.description.trim()}\n\n${examplesId}####${heading} Examples\n\n\`\`\`${
example.language || 'js'
}${example.value}\`\`\``,
)
.join('\n')}`;

Expand Down
6 changes: 1 addition & 5 deletions @packages/jest-runner-rollup/src/runner.js
Expand Up @@ -332,11 +332,7 @@ async function hooker(hookFn, options = {}) {
}

function revHash(input, len = 20) {
return crypto
.createHash('md5')
.update(input)
.digest('hex')
.slice(0, len);
return crypto.createHash('md5').update(input).digest('hex').slice(0, len);
}

function serializeJson(input) {
Expand Down
2 changes: 1 addition & 1 deletion @packages/koa-better-body/.verb.md
Expand Up @@ -18,7 +18,7 @@ var app = require('koa')();
var body = require('{%= name %}');
var router = require('koa-router')();

router.post('/upload', body(), function*(next) {
router.post('/upload', body(), function* (next) {
console.log(this.request.files);
console.log(this.request.fields);

Expand Down
10 changes: 5 additions & 5 deletions @packages/koa-better-body/README.md
Expand Up @@ -162,12 +162,12 @@ var app = koa();
app
.use(body())
.use(function*() {
.use(function* () {
console.log(this.request.body); // if buffer or text
console.log(this.request.files); // if multipart or urlencoded
console.log(this.request.fields); // if json
})
.listen(8080, function() {
.listen(8080, function () {
console.log('koa server start listening on port 8080');
});
```
Expand All @@ -185,7 +185,7 @@ var app = require('koa')();
var body = require('koa-better-body');
var router = require('koa-router')();
router.post('/upload', body(), function*(next) {
router.post('/upload', body(), function* (next) {
console.log(this.request.files);
console.log(this.request.fields);
Expand Down Expand Up @@ -358,8 +358,8 @@ are just related. So, thanks for your existance!
[homepage](https://github.com/node-formidable/formidable 'A node.js module for parsing form data, especially file uploads.')
- [ip-filter](https://www.npmjs.com/package/ip-filter): Validates valid IPs
(IPv4 and IPv6) using [micromatch][] - glob
[more](https://github.com/tunnckocore/ip-filter#readme) |
[homepage](https://github.com/tunnckocore/ip-filter#readme 'Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp, string or array of globs. If match returns the IP, otherwise null.')
[more](https://tunnckocore.com/opensource) |
[homepage](https://tunnckocore.com/opensource 'Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp, string or array of globs. If match returns the IP, otherwise null.')
- [koa-body-parsers](https://www.npmjs.com/package/koa-body-parsers): collection
of koa body parsers |
[homepage](https://github.com/koajs/body-parsers#readme 'collection of koa body parsers')
Expand Down
4 changes: 2 additions & 2 deletions @packages/koa-better-body/docs/src/index.md
Expand Up @@ -31,12 +31,12 @@ var app = koa();
app
.use(body())
.use(function*() {
.use(function* () {
console.log(this.request.body); // if buffer or text
console.log(this.request.files); // if multipart or urlencoded
console.log(this.request.fields); // if json
})
.listen(8080, function() {
.listen(8080, function () {
console.log('koa server start listening on port 8080');
});
```
10 changes: 5 additions & 5 deletions @packages/koa-better-body/recipes/formidable/README.md
Expand Up @@ -22,15 +22,15 @@ form.keepExtensions = true;
form.encoding = 'utf-8';
form.uploadDir = path.join(__dirname, 'uploads');

form.on('field', function(name, value) {
form.on('field', function (name, value) {
console.log(name, value); // name is user, value is test
});
form.on('file', function(name, file) {
form.on('file', function (name, file) {
console.log(name); // => foo
console.log(file); // => README.md
console.log(file.path); // => full filepath to where is uploaded
});
form.on('end', function(name, file) {
form.on('end', function (name, file) {
console.log('finish parse');
});

Expand All @@ -40,14 +40,14 @@ app
IncomingForm: form,
}),
)
.use(function*() {
.use(function* () {
console.log(this.body.user); // => test
console.log(this.request.files); // or `this.body.files`
console.log(this.body.files.foo.name); // => README.md
console.log(this.body.files.foo.path); // => full filepath to where is uploaded
});

app.listen(4290, function() {
app.listen(4290, function () {
console.log('Koa server start listening on port 4290');
console.log(
'curl -i http://localhost:4290/ -F "foo=@%s/README.md" -F user=test',
Expand Down
4 changes: 2 additions & 2 deletions @packages/koa-better-body/recipes/multipart/README.md
Expand Up @@ -17,13 +17,13 @@ app
keepExtensions: true,
}),
)
.use(function*() {
.use(function* () {
console.log(this.request.files); // or `this.body.files`
console.log(this.body.files.foo.name); // => README.md
console.log(this.body.files.foo.path); // => full filepath to where is uploaded
});

app.listen(4290, function() {
app.listen(4290, function () {
console.log('Koa server start listening on port 4290');
console.log(
'curl -i http://localhost:4290/ -F "foo=@%s/README.md"',
Expand Down
12 changes: 3 additions & 9 deletions @packages/koa-better-body/test/json.js
Expand Up @@ -22,9 +22,7 @@ function postBody() {
}

test('should parse a json body', async () => {
const server = koa()
.use(betterBody())
.use(postBody());
const server = koa().use(betterBody()).use(postBody());

await new Promise((resolve, reject) => {
request(server.callback())
Expand All @@ -37,9 +35,7 @@ test('should parse a json body', async () => {
});

test('should parse a string json body', async () => {
const server = koa()
.use(betterBody())
.use(postBody());
const server = koa().use(betterBody()).use(postBody());

await new Promise((resolve, reject) => {
request(server.callback())
Expand All @@ -53,9 +49,7 @@ test('should parse a string json body', async () => {
});

test('should throw on json non-object body in strict mode (default)', async () => {
const server = koa()
.use(betterBody())
.use(postBody());
const server = koa().use(betterBody()).use(postBody());

await new Promise((resolve, reject) => {
request(server.callback())
Expand Down
2 changes: 1 addition & 1 deletion @packages/parse-function/test/index.js
Expand Up @@ -305,7 +305,7 @@ test(`real anonymous fn has .name: null`, () => {
const app = parseFunction({ ecmaVersion: 2017 });

/* eslint-disable-next-line prefer-arrow-callback, func-names */
const actual = app.parse(function() {});
const actual = app.parse(function () {});
expect(actual.name).toBeNull();
expect(actual.isAnonymous).toStrictEqual(true);
});
4 changes: 2 additions & 2 deletions @packages/prettier-plugin-pkgjson/package.json
Expand Up @@ -30,10 +30,10 @@
},
"scripts": {},
"dependencies": {
"sort-package-json": "^1.39.0"
"sort-package-json": "^1.40.0"
},
"peerDependencies": {
"prettier": "^1.19.1"
"prettier": "^2.0.2"
},
"jest": {
"coverageThreshold": {
Expand Down
2 changes: 1 addition & 1 deletion @packages/prettier-plugin-pkgjson/src/index.js
Expand Up @@ -11,7 +11,7 @@

'use strict';

const { parsers } = require('prettier/parser-babylon');
const { parsers } = require('prettier/parser-babel');
const sortPackageJson = require('sort-package-json');

const parser = parsers['json-stringify'];
Expand Down
6 changes: 3 additions & 3 deletions @packages/to-file-path/README.md
Expand Up @@ -151,8 +151,8 @@ are just related. So, thanks for your existance!
[homepage](https://github.com/jonschlinkert/in-array "Return true if a value exists in an array. Faster than using indexOf and won't blow up on null values.")
- [ip-filter](https://www.npmjs.com/package/ip-filter): Validates valid IPs
(IPv4 and IPv6) using [micromatch][] - glob
[more](https://github.com/tunnckocore/ip-filter#readme) |
[homepage](https://github.com/tunnckocore/ip-filter#readme 'Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp, string or array of globs. If match returns the IP, otherwise null.')
[more](https://tunnckocore.com/opensource) |
[homepage](https://tunnckocore.com/opensource 'Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp, string or array of globs. If match returns the IP, otherwise null.')
- [to-object-path](https://www.npmjs.com/package/to-object-path): Create an
object path from a list or array of
[more](https://github.com/jonschlinkert/to-object-path) |
Expand Down Expand Up @@ -311,7 +311,7 @@ Released under the [MPL-2.0 License][license-url].
<!-- prettier-ignore-end -->

[fn-name]: https://github.com/sindresorhus/fn-name
[ip-filter]: https://github.com/tunnckocore/ip-filter
[ip-filter]: https://tunnckocore.com/opensource
[is-match]: https://github.com/jonschlinkert/is-match
[koa]: https://github.com/koajs/koa
[micromatch]: https://github.com/micromatch/micromatch
5 changes: 1 addition & 4 deletions @tunnckocore/utils/src/index.js
Expand Up @@ -270,10 +270,7 @@ function testCoverage(rootDir, testCovPath) {

/* istanbul ignore next */
const newKey = k.endsWith('src')
? k
.split('/')
.slice(0, -1)
.join('/')
? k.split('/').slice(0, -1).join('/')
: k;

acc[newKey] = jestCov[k];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -73,7 +73,7 @@
"lerna": "^3.20.2",
"lockfile-lint": "^4.0.0",
"mukla": "^0.4.9",
"prettier": "^1.19.1",
"prettier": "^2.0.2",
"react": "^16.12.0",
"rollup": "^1.31.0",
"rollup-plugin-babel": "^4.3.3",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Expand Up @@ -13426,10 +13426,10 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier@^1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
prettier@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.2.tgz#1ba8f3eb92231e769b7fcd7cb73ae1b6b74ade08"
integrity sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==

pretty-format@^23.6.0:
version "23.6.0"
Expand Down Expand Up @@ -15301,7 +15301,7 @@ sort-object-keys@^1.1.3:
resolved "https://registry.yarnpkg.com/sort-object-keys/-/sort-object-keys-1.1.3.tgz#bff833fe85cab147b34742e45863453c1e190b45"
integrity sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg==

sort-package-json@^1.39.0:
sort-package-json@^1.40.0:
version "1.40.0"
resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-1.40.0.tgz#81ad8c2bd7dd21b6a127ab4a26186a160f07a157"
integrity sha512-3Uc1kjmQ3SYuKziKghZvA23SihOqGxEjK2QPfFPmd7BMo9rWiJdC2FJWvAZbfhLWapuJrdmkUf6Kp0G4Wtuv5w==
Expand Down

0 comments on commit 8b9f668

Please sign in to comment.