Skip to content

Commit 6ab9526

Browse files
committed
Configure prettier for TypeScript code
We can migrate files one-by-one as we touch them.
1 parent 6014978 commit 6ab9526

File tree

6 files changed

+123
-40
lines changed

6 files changed

+123
-40
lines changed

ui/frontend/.eslintrc.js

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,54 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
3-
plugins: [
4-
'@typescript-eslint',
5-
'react',
6-
'react-hooks',
7-
],
3+
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
84
settings: {
95
react: {
106
version: 'detect',
117
},
128
},
13-
extends: [
14-
'plugin:@typescript-eslint/recommended',
15-
'plugin:react/recommended',
16-
],
17-
rules: {
9+
extends: ['plugin:@typescript-eslint/recommended', 'plugin:react/recommended'],
10+
rules: {
1811
'comma-dangle': ['error', 'always-multiline'],
19-
'max-len': ['error', {
20-
'code': 120,
21-
}],
12+
'max-len': [
13+
'error',
14+
{
15+
code: 120,
16+
},
17+
],
2218
'no-trailing-spaces': 'error',
23-
'quotes': ['error', 'single'],
19+
quotes: ['error', 'single'],
2420

25-
'@typescript-eslint/ban-ts-comment': ['error', {
26-
'ts-ignore': 'allow-with-description',
27-
}],
21+
'@typescript-eslint/ban-ts-comment': [
22+
'error',
23+
{
24+
'ts-ignore': 'allow-with-description',
25+
},
26+
],
2827
'@typescript-eslint/explicit-function-return-type': 'off',
2928
'@typescript-eslint/indent': ['error', 2],
3029
'@typescript-eslint/no-explicit-any': 'off',
31-
'@typescript-eslint/no-unused-vars': ['error', {
32-
varsIgnorePattern: "^_",
33-
argsIgnorePattern: "^_",
34-
}],
35-
'@typescript-eslint/no-use-before-define': ['error', {
36-
functions: false,
37-
variables: false,
38-
}],
30+
'@typescript-eslint/no-unused-vars': [
31+
'error',
32+
{
33+
varsIgnorePattern: '^_',
34+
argsIgnorePattern: '^_',
35+
},
36+
],
37+
'@typescript-eslint/no-use-before-define': [
38+
'error',
39+
{
40+
functions: false,
41+
variables: false,
42+
},
43+
],
3944

4045
'react/jsx-boolean-value': ['error', 'never'],
41-
'react/jsx-tag-spacing': ['error', {
42-
"beforeClosing": "never",
43-
}],
46+
'react/jsx-tag-spacing': [
47+
'error',
48+
{
49+
beforeClosing: 'never',
50+
},
51+
],
4452
'react/prop-types': 'off',
4553

4654
'react-hooks/rules-of-hooks': 'error',
@@ -50,4 +58,10 @@ module.exports = {
5058
'@typescript-eslint/ban-types': 'off',
5159
'@typescript-eslint/explicit-module-boundary-types': 'off',
5260
},
61+
overrides: [
62+
{
63+
files: ['.eslintrc.js'],
64+
extends: ['prettier'],
65+
},
66+
],
5367
};

ui/frontend/.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ node_modules
88
*.ts
99
*.tsx
1010
*.scss
11+
12+
# Slowly migrate files that we've touched
13+
!.eslintrc.js

ui/frontend/.prettierrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"singleQuote": true
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"importOrder": ["^[./].*(?<!\\.css)$", "\\.css$"],
6+
"importOrderSeparation": true,
7+
"importOrderSortSpecifiers": true
38
}

ui/frontend/Output/Gist.module.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ $copied-duration: 1s ease-in-out;
1313

1414
.text {
1515
opacity: 0;
16-
transition: visibility $copied-duration, opacity $copied-duration,
17-
color $copied-duration;
16+
transition: visibility $copied-duration, opacity $copied-duration, color $copied-duration;
1817
visibility: hidden;
1918
}
2019

ui/frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
3939
"@babel/preset-env": "^7.0.0",
4040
"@babel/preset-react": "^7.0.0",
41+
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
4142
"@types/common-tags": "^1.8.1",
4243
"@types/isomorphic-fetch": "^0.0.36",
4344
"@types/jest": "^29.2.5",
@@ -58,6 +59,7 @@
5859
"copy-webpack-plugin": "^11.0.0",
5960
"css-loader": "^6.0.0",
6061
"eslint": "^8.6.0",
62+
"eslint-config-prettier": "^8.7.0",
6163
"eslint-plugin-react": "^7.14.3",
6264
"eslint-plugin-react-hooks": "^4.0.0",
6365
"glob": "^8.0.3",

ui/frontend/yarn.lock

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@jridgewell/gen-mapping" "^0.1.0"
1616
"@jridgewell/trace-mapping" "^0.3.9"
1717

18-
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.18.6":
18+
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.18.6":
1919
version "7.18.6"
2020
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a"
2121
integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==
@@ -48,7 +48,16 @@
4848
json5 "^2.2.2"
4949
semver "^6.3.0"
5050

51-
"@babel/generator@^7.21.0", "@babel/generator@^7.21.1", "@babel/generator@^7.7.2":
51+
"@babel/generator@7.17.7":
52+
version "7.17.7"
53+
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad"
54+
integrity sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==
55+
dependencies:
56+
"@babel/types" "^7.17.0"
57+
jsesc "^2.5.1"
58+
source-map "^0.5.0"
59+
60+
"@babel/generator@^7.17.3", "@babel/generator@^7.21.0", "@babel/generator@^7.21.1", "@babel/generator@^7.7.2":
5261
version "7.21.1"
5362
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.21.1.tgz#951cc626057bc0af2c35cd23e9c64d384dea83dd"
5463
integrity sha512-1lT45bAYlQhFn/BHivJs43AiW2rg3/UbLyShGfF3C0KmHvO5fSghWd5kBJy30kpRRucGzXStvnnCFniCR2kXAA==
@@ -118,7 +127,7 @@
118127
resolve "^1.14.2"
119128
semver "^6.1.2"
120129

121-
"@babel/helper-environment-visitor@^7.18.9":
130+
"@babel/helper-environment-visitor@^7.16.7", "@babel/helper-environment-visitor@^7.18.9":
122131
version "7.18.9"
123132
resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be"
124133
integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==
@@ -130,15 +139,15 @@
130139
dependencies:
131140
"@babel/types" "^7.18.6"
132141

133-
"@babel/helper-function-name@^7.18.9", "@babel/helper-function-name@^7.19.0", "@babel/helper-function-name@^7.21.0":
142+
"@babel/helper-function-name@^7.16.7", "@babel/helper-function-name@^7.18.9", "@babel/helper-function-name@^7.19.0", "@babel/helper-function-name@^7.21.0":
134143
version "7.21.0"
135144
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz#d552829b10ea9f120969304023cd0645fa00b1b4"
136145
integrity sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==
137146
dependencies:
138147
"@babel/template" "^7.20.7"
139148
"@babel/types" "^7.21.0"
140149

141-
"@babel/helper-hoist-variables@^7.18.6":
150+
"@babel/helper-hoist-variables@^7.16.7", "@babel/helper-hoist-variables@^7.18.6":
142151
version "7.18.6"
143152
resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678"
144153
integrity sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==
@@ -221,7 +230,7 @@
221230
dependencies:
222231
"@babel/types" "^7.20.0"
223232

224-
"@babel/helper-split-export-declaration@^7.18.6":
233+
"@babel/helper-split-export-declaration@^7.16.7", "@babel/helper-split-export-declaration@^7.18.6":
225234
version "7.18.6"
226235
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075"
227236
integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==
@@ -233,7 +242,7 @@
233242
resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63"
234243
integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==
235244

236-
"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1":
245+
"@babel/helper-validator-identifier@^7.16.7", "@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1":
237246
version "7.19.1"
238247
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2"
239248
integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==
@@ -271,7 +280,7 @@
271280
chalk "^2.0.0"
272281
js-tokens "^4.0.0"
273282

274-
"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.21.0", "@babel/parser@^7.21.2":
283+
"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.17.3", "@babel/parser@^7.20.5", "@babel/parser@^7.20.7", "@babel/parser@^7.21.0", "@babel/parser@^7.21.2":
275284
version "7.21.2"
276285
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.2.tgz#dacafadfc6d7654c3051a66d6fe55b6cb2f2a0b3"
277286
integrity sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ==
@@ -963,6 +972,22 @@
963972
"@babel/parser" "^7.20.7"
964973
"@babel/types" "^7.20.7"
965974

975+
"@babel/traverse@7.17.3":
976+
version "7.17.3"
977+
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57"
978+
integrity sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==
979+
dependencies:
980+
"@babel/code-frame" "^7.16.7"
981+
"@babel/generator" "^7.17.3"
982+
"@babel/helper-environment-visitor" "^7.16.7"
983+
"@babel/helper-function-name" "^7.16.7"
984+
"@babel/helper-hoist-variables" "^7.16.7"
985+
"@babel/helper-split-export-declaration" "^7.16.7"
986+
"@babel/parser" "^7.17.3"
987+
"@babel/types" "^7.17.0"
988+
debug "^4.1.0"
989+
globals "^11.1.0"
990+
966991
"@babel/traverse@^7.20.5", "@babel/traverse@^7.20.7", "@babel/traverse@^7.21.0", "@babel/traverse@^7.21.2", "@babel/traverse@^7.7.2":
967992
version "7.21.2"
968993
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.21.2.tgz#ac7e1f27658750892e815e60ae90f382a46d8e75"
@@ -979,7 +1004,15 @@
9791004
debug "^4.1.0"
9801005
globals "^11.1.0"
9811006

982-
"@babel/types@^7.0.0", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5", "@babel/types@^7.20.7", "@babel/types@^7.21.0", "@babel/types@^7.21.2", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
1007+
"@babel/types@7.17.0":
1008+
version "7.17.0"
1009+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b"
1010+
integrity sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==
1011+
dependencies:
1012+
"@babel/helper-validator-identifier" "^7.16.7"
1013+
to-fast-properties "^2.0.0"
1014+
1015+
"@babel/types@^7.0.0", "@babel/types@^7.17.0", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5", "@babel/types@^7.20.7", "@babel/types@^7.21.0", "@babel/types@^7.21.2", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
9831016
version "7.21.2"
9841017
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.21.2.tgz#92246f6e00f91755893c2876ad653db70c8310d1"
9851018
integrity sha512-3wRZSs7jiFaB8AjxiiD+VqN5DTG2iRvJGQ+qYFrs/654lg6kGTQWIOFjlBo5RaXuAZjBmP3+OQH4dmhqiiyYxw==
@@ -1343,6 +1376,18 @@
13431376
dependencies:
13441377
"@sinonjs/commons" "^2.0.0"
13451378

1379+
"@trivago/prettier-plugin-sort-imports@^4.1.1":
1380+
version "4.1.1"
1381+
resolved "https://registry.yarnpkg.com/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-4.1.1.tgz#71c3c1ae770c3738b6fc85710714844477574ffd"
1382+
integrity sha512-dQ2r2uzNr1x6pJsuh/8x0IRA3CBUB+pWEW3J/7N98axqt7SQSm+2fy0FLNXvXGg77xEDC7KHxJlHfLYyi7PDcw==
1383+
dependencies:
1384+
"@babel/generator" "7.17.7"
1385+
"@babel/parser" "^7.20.5"
1386+
"@babel/traverse" "7.17.3"
1387+
"@babel/types" "7.17.0"
1388+
javascript-natural-sort "0.7.1"
1389+
lodash "^4.17.21"
1390+
13461391
"@types/babel__core@^7.1.14":
13471392
version "7.20.0"
13481393
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.0.tgz#61bc5a4cae505ce98e1e36c5445e4bee060d8891"
@@ -2795,6 +2840,11 @@ escape-string-regexp@^4.0.0:
27952840
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
27962841
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
27972842

2843+
eslint-config-prettier@^8.7.0:
2844+
version "8.7.0"
2845+
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.7.0.tgz#f1cc58a8afebc50980bd53475451df146c13182d"
2846+
integrity sha512-HHVXLSlVUhMSmyW4ZzEuvjpwqamgmlfkutD53cYXLikh4pt/modINRcCIApJ84czDxM4GZInwUrromsDdTImTA==
2847+
27982848
eslint-plugin-react-hooks@^4.0.0:
27992849
version "4.6.0"
28002850
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
@@ -3764,6 +3814,11 @@ istanbul-reports@^3.1.3:
37643814
html-escaper "^2.0.0"
37653815
istanbul-lib-report "^3.0.0"
37663816

3817+
javascript-natural-sort@0.7.1:
3818+
version "0.7.1"
3819+
resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59"
3820+
integrity sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==
3821+
37673822
jest-changed-files@^29.5.0:
37683823
version "29.5.0"
37693824
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.5.0.tgz#e88786dca8bf2aa899ec4af7644e16d9dcf9b23e"
@@ -5552,6 +5607,11 @@ source-map@0.5.6:
55525607
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
55535608
integrity sha512-MjZkVp0NHr5+TPihLcadqnlVoGIoWo4IBHptutGh9wI3ttUYvCG26HkSuDi+K6lsZ25syXJXcctwgyVCt//xqA==
55545609

5610+
source-map@^0.5.0:
5611+
version "0.5.7"
5612+
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
5613+
integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==
5614+
55555615
source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0:
55565616
version "0.6.1"
55575617
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"

0 commit comments

Comments
 (0)