Skip to content
Myr

chore: set up prettier (#106)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by GitHub · parent fca3dde · Browse files · 10 files+71 added−78 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

10 files+71 added−78 removed

  • tests:+24 added−7 removed
  • other:+47 added−71 removed

10 files+71 added−78 removed

modified:src/middleware/cors/cors.test.ts+9 added-2 removed
modified:src/middleware/logger/logger.ts+6 added-25 removed
modified:src/middleware/serve-static/serve-static.ts+5 added-1 removed
modified:src/utils/buffer.test.ts+12 added-4 removed
15 unmodified lines
16 expect(await decodeBase64('abcdedf')).not.toBe('abcdef')17 })1819 it('sha256', async () => {20 expect(await sha256('hono')).toBe('8b3dc17add91b7e8f0b5109a389927d66001139cd9b03fa7b95f83126e1b2b23')21 expect(await sha256('炎')).toBe('1fddc5a562ee1fbeb4fc6def7d4be4911fcdae4273b02ae3a507b170ba0ea169')20 expect(await sha256('hono')).toBe(21 '8b3dc17add91b7e8f0b5109a389927d66001139cd9b03fa7b95f83126e1b2b23'22 )23 expect(await sha256('炎')).toBe(24 '1fddc5a562ee1fbeb4fc6def7d4be4911fcdae4273b02ae3a507b170ba0ea169'25 )2627 expect(await sha256('abcdedf')).not.toBe('abcdef')28 })29
12 unmodified lines
42 })4344 it('negative', async () => {45 expect(await timingSafeEqual('a', 'b')).toBe(false)42 expect(await timingSafeEqual('a', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toBe(false)43 expect(await timingSafeEqual('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'a')).toBe(false)46 expect(47 await timingSafeEqual('a', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')48 ).toBe(false)49 expect(50 await timingSafeEqual('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'a')51 ).toBe(false)52 expect(await timingSafeEqual('alpha', 'beta')).toBe(false)53 expect(await timingSafeEqual(false, true)).toBe(false)54 expect(await timingSafeEqual(false, undefined)).toBe(false)55 expect(
12 unmodified lines
modified:src/utils/buffer.ts+7 added-2 removed
46 unmodified lines
47 name: 'SHA-256',48 },49 new TextEncoder().encode(String(a))50 )51 const hash = Array.prototype.map.call(new Uint8Array(buffer), (x) => ('00' + x.toString(16)).slice(-2)).join('')51 const hash = Array.prototype.map52 .call(new Uint8Array(buffer), (x) => ('00' + x.toString(16)).slice(-2))53 .join('')54 return hash55 }5657 try {
5 unmodified lines
63 throw e64 }65}6665export const timingSafeEqual = async (a: string | object | boolean, b: string | object | boolean) => {67export const timingSafeEqual = async (68 a: string | object | boolean,69 b: string | object | boolean70) => {71 const sa = await sha256(a)72 const sb = await sha256(b)73 return sa === sb && a === b74}
modified:src/utils/cloudflare.test.ts+3 added-1 removed
37 unmodified lines
38 expect(getKVFilePath({ filename: 'foo', root: 'bar' })).toBe('bar/foo/index.html')39 expect(getKVFilePath({ filename: 'foo.txt', root: 'bar' })).toBe('bar/foo.txt')4041 expect(getKVFilePath({ filename: 'foo', defaultDocument: 'index.txt' })).toBe('foo/index.txt')42 expect(getKVFilePath({ filename: 'foo', root: 'bar', defaultDocument: 'index.txt' })).toBe('bar/foo/index.txt')42 expect(getKVFilePath({ filename: 'foo', root: 'bar', defaultDocument: 'index.txt' })).toBe(43 'bar/foo/index.txt'44 )4546 expect(getKVFilePath({ filename: './foo' })).toBe('foo/index.html')47 expect(getKVFilePath({ filename: 'foo', root: './bar' })).toBe('bar/foo/index.html')48 })
1 unmodified line
modified:.eslintrc.js+12 added-21 removed
4 unmodified lines
5 extends: [6 'eslint:recommended',7 'plugin:node/recommended',8 'plugin:@typescript-eslint/recommended',9 'prettier',10 ],11 parser: '@typescript-eslint/parser',12 parserOptions: {13 sourceType: 'module',
17 unmodified lines
31 {32 destructuring: 'all',33 },34 ],34 '@typescript-eslint/ban-types': ['error', {35 types: {36 'Function': false,37 }38 }],35 '@typescript-eslint/ban-types': [36 'error',37 {38 types: {39 Function: false,40 },41 },42 ],43 'node/no-missing-import': [44 'error',45 {42 allowModules: [43 'types',44 'estree',45 'testUtils',46 'less',47 'sass',48 'stylus',49 ],46 allowModules: ['types', 'estree', 'testUtils', 'less', 'sass', 'stylus'],47 tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'],48 },49 ],50 'node/no-missing-require': [
6 unmodified lines
57 'node/no-unpublished-import': 'off',58 'node/no-unpublished-require': 'off',59 'node/no-unsupported-features/es-syntax': 'off',6064 '@typescript-eslint/no-empty-function': [65 'error',66 { allow: ['arrowFunctions'] },67 ],61 '@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],62 '@typescript-eslint/no-empty-interface': 'off',63 '@typescript-eslint/no-inferrable-types': 'off',64 '@typescript-eslint/no-var-requires': 'off',71 '@typescript-eslint/consistent-type-imports': [72 'error',73 { prefer: 'type-imports' },74 ],65 '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],66 },67})
added:.prettierrc+9 added
1{2 "printWidth": 100,3 "trailingComma": "es5",4 "tabWidth": 2,5 "semi": false,6 "singleQuote": true,7 "jsxSingleQuote": true,8 "endOfLine": "lf"9}
modified:package.json+3 added-3 removed
48 unmodified lines
49 }50 },51 "scripts": {52 "test": "jest",53 "lint": "eslint --ext js,ts src .eslintrc.js test",53 "lint": "eslint --ext js,ts src .eslintrc.js test && prettier --check src",54 "build": "rimraf dist && tsc",55 "watch": "tsc -w",56 "prepublishOnly": "yarn build"57 },
23 unmodified lines
81 "@types/node": "^17.0.8",82 "@typescript-eslint/eslint-plugin": "^5.9.0",83 "@typescript-eslint/parser": "^5.9.0",84 "eslint": "^7.26.0",85 "eslint-config-prettier": "^8.1.0",85 "eslint-config-prettier": "^8.3.0",86 "eslint-define-config": "^1.2.1",87 "eslint-import-resolver-typescript": "^2.0.0",88 "eslint-plugin-eslint-comments": "^3.2.0",89 "eslint-plugin-flowtype": "^5.7.2",90 "eslint-plugin-import": "^2.20.2",91 "eslint-plugin-node": "^11.1.0",92 "eslint-plugin-prettier": "^4.0.0",92 "form-data": "^4.0.0",93 "jest": "^27.4.5",94 "jest-environment-miniflare": "^2.0.0",95 "mustache": "^4.2.0",96 "prettier": "^2.5.1",97 "rimraf": "^3.0.2",98 "ts-jest": "^27.1.2",99 "typescript": "^4.5.5"100 },
4 unmodified lines
modified:yarn.lock+5 added-19 removed
1515 unmodified lines
1516 optionator "^0.8.1"1517 optionalDependencies:1518 source-map "~0.6.1"15191520eslint-config-prettier@^8.1.0:1520eslint-config-prettier@^8.3.0:1521 version "8.3.0"1522 resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a"1523 integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==1524
83 unmodified lines
1608 minimatch "^3.0.4"1609 resolve "^1.10.1"1610 semver "^6.1.0"16111612eslint-plugin-prettier@^4.0.0:1613 version "4.0.0"1614 resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0"1615 integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==1616 dependencies:1617 prettier-linter-helpers "^1.0.0"16181612eslint-scope@^5.1.1:1613 version "5.1.1"1614 resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"1615 integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==
153 unmodified lines
1769 version "3.1.3"1770 resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"1771 integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==17721780fast-diff@^1.1.2:1781 version "1.2.0"1782 resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"1783 integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==17841773fast-glob@^3.2.9:1774 version "3.2.11"1775 resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"1776 integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
1399 unmodified lines
3176 version "1.1.2"3177 resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"3178 integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=31793192prettier-linter-helpers@^1.0.0:3193 version "1.0.0"3194 resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"3195 integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==3196 dependencies:3197 fast-diff "^1.1.2"3180prettier@^2.5.1:3181 version "2.5.1"3182 resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"3183 integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==31843185pretty-format@^27.0.0, pretty-format@^27.4.6:3186 version "27.4.6"3187 resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.4.6.tgz#1b784d2f53c68db31797b2348fa39b49e31846b7"
689 unmodified lines