Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 0fb04fc

Browse files
authored
feat: update eslint, prettier and typescript (#912)
1 parent de56cbe commit 0fb04fc

File tree

42 files changed

+1050
-632
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1050
-632
lines changed

packages/app/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ module.exports = {
9797
'@typescript-eslint/consistent-type-imports': 'error',
9898
'@typescript-eslint/explicit-function-return-type': [0],
9999
'@typescript-eslint/explicit-module-boundary-types': [0],
100-
'@typescript-eslint/no-duplicate-imports': 'error',
101100
'@typescript-eslint/no-use-before-define': [
102101
'error',
103102
{ functions: false, classes: true, variables: true },

packages/app/package.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"last 2 Safari versions"
3838
],
3939
"dependencies": {
40-
"@babel/eslint-parser": "7.21.3",
40+
"@babel/eslint-parser": "7.22.15",
4141
"@babel/runtime": "7.21.0",
4242
"@emotion/babel-preset-css-prop": "11.10.0",
4343
"@staticcms/core": "^3.3.4",
@@ -60,13 +60,13 @@
6060
"@babel/preset-env": "7.21.4",
6161
"@babel/preset-react": "7.18.6",
6262
"@babel/preset-typescript": "7.21.4",
63-
"@emotion/eslint-plugin": "11.10.0",
63+
"@emotion/eslint-plugin": "11.11.0",
6464
"@emotion/jest": "11.10.5",
6565
"@types/node": "18.16.14",
6666
"@types/react": "18.2.0",
6767
"@types/react-dom": "18.2.1",
68-
"@typescript-eslint/eslint-plugin": "5.59.1",
69-
"@typescript-eslint/parser": "5.59.1",
68+
"@typescript-eslint/eslint-plugin": "6.7.4",
69+
"@typescript-eslint/parser": "6.7.4",
7070
"autoprefixer": "10.4.14",
7171
"babel-core": "7.0.0-bridge.0",
7272
"babel-loader": "9.1.2",
@@ -81,24 +81,23 @@
8181
"cross-env": "7.0.3",
8282
"css-loader": "6.7.3",
8383
"dotenv": "16.0.3",
84-
"eslint": "8.39.0",
85-
"eslint-import-resolver-typescript": "3.5.5",
86-
"eslint-plugin-cypress": "2.13.3",
87-
"eslint-plugin-import": "2.27.5",
88-
"eslint-plugin-prettier": "4.2.1",
89-
"eslint-plugin-react": "7.32.2",
84+
"eslint": "8.50.0",
85+
"eslint-import-resolver-typescript": "3.6.1",
86+
"eslint-plugin-cypress": "2.15.1",
87+
"eslint-plugin-import": "2.28.1",
88+
"eslint-plugin-prettier": "5.0.0",
9089
"eslint-plugin-react-hooks": "4.6.0",
91-
"eslint-plugin-unicorn": "46.0.1",
90+
"eslint-plugin-unicorn": "48.0.1",
9291
"mini-css-extract-plugin": "2.7.5",
9392
"npm-run-all": "4.1.5",
9493
"postcss": "8.4.23",
9594
"postcss-scss": "4.0.6",
96-
"prettier": "2.8.8",
95+
"prettier": "3.0.3",
9796
"source-map-loader": "4.0.1",
9897
"style-loader": "3.3.2",
9998
"to-string-loader": "1.2.0",
10099
"tsconfig-paths-webpack-plugin": "4.0.1",
101-
"typescript": "5.0.4",
100+
"typescript": "5.2.2",
102101
"webpack": "5.80.0",
103102
"webpack-cli": "5.0.2"
104103
},

packages/core/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ module.exports = {
9999
'@typescript-eslint/consistent-type-imports': 'error',
100100
'@typescript-eslint/explicit-function-return-type': [0],
101101
'@typescript-eslint/explicit-module-boundary-types': [0],
102-
'@typescript-eslint/no-duplicate-imports': 'error',
103102
'@typescript-eslint/no-use-before-define': [
104103
'error',
105104
{ functions: false, classes: true, variables: true },

packages/core/package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"last 2 Safari versions"
4848
],
4949
"dependencies": {
50-
"@babel/eslint-parser": "7.21.3",
50+
"@babel/eslint-parser": "7.22.15",
5151
"@babel/runtime": "7.21.0",
5252
"@codemirror/autocomplete": "6.5.1",
5353
"@codemirror/commands": "6.2.3",
@@ -102,7 +102,7 @@
102102
"deepmerge": "4.3.1",
103103
"diacritics": "1.3.0",
104104
"escape-html": "1.0.3",
105-
"eslint-config-prettier": "8.8.0",
105+
"eslint-config-prettier": "9.0.0",
106106
"eslint-plugin-babel": "5.3.1",
107107
"fuzzy": "0.1.3",
108108
"globby": "13.1.4",
@@ -189,7 +189,7 @@
189189
"@babel/preset-env": "7.21.4",
190190
"@babel/preset-react": "7.18.6",
191191
"@babel/preset-typescript": "7.21.4",
192-
"@emotion/eslint-plugin": "11.10.0",
192+
"@emotion/eslint-plugin": "11.11.0",
193193
"@emotion/jest": "11.10.5",
194194
"@iarna/toml": "2.2.5",
195195
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
@@ -217,8 +217,8 @@
217217
"@types/styled-components": "5.1.26",
218218
"@types/url-join": "4.0.1",
219219
"@types/uuid": "9.0.1",
220-
"@typescript-eslint/eslint-plugin": "5.59.1",
221-
"@typescript-eslint/parser": "5.59.1",
220+
"@typescript-eslint/eslint-plugin": "6.7.4",
221+
"@typescript-eslint/parser": "6.7.4",
222222
"autoprefixer": "10.4.14",
223223
"axios": "1.3.6",
224224
"babel-core": "7.0.0-bridge.0",
@@ -237,14 +237,14 @@
237237
"cross-env": "7.0.3",
238238
"css-loader": "6.7.3",
239239
"dotenv": "16.0.3",
240-
"eslint": "8.39.0",
241-
"eslint-import-resolver-typescript": "3.5.5",
242-
"eslint-plugin-cypress": "2.13.3",
243-
"eslint-plugin-import": "2.27.5",
244-
"eslint-plugin-prettier": "4.2.1",
245-
"eslint-plugin-react": "7.32.2",
240+
"eslint": "8.50.0",
241+
"eslint-import-resolver-typescript": "3.6.1",
242+
"eslint-plugin-cypress": "2.15.1",
243+
"eslint-plugin-import": "2.28.1",
244+
"eslint-plugin-prettier": "5.0.0",
245+
"eslint-plugin-react": "7.33.2",
246246
"eslint-plugin-react-hooks": "4.6.0",
247-
"eslint-plugin-unicorn": "46.0.1",
247+
"eslint-plugin-unicorn": "48.0.1",
248248
"execa": "7.1.1",
249249
"fs-extra": "11.1.1",
250250
"gitlab": "14.2.2",
@@ -260,7 +260,7 @@
260260
"npm-run-all": "4.1.5",
261261
"postcss": "8.4.23",
262262
"postcss-loader": "7.2.4",
263-
"prettier": "2.8.8",
263+
"prettier": "3.0.3",
264264
"process": "0.11.10",
265265
"react-refresh": "0.14.0",
266266
"react-svg-loader": "3.0.3",
@@ -273,7 +273,7 @@
273273
"ts-jest": "29.1.0",
274274
"ts-node": "10.9.1",
275275
"tsconfig-paths-webpack-plugin": "4.0.1",
276-
"typescript": "5.0.4",
276+
"typescript": "5.2.2",
277277
"webpack": "5.80.0",
278278
"webpack-cli": "5.0.2",
279279
"webpack-dev-server": "4.13.3"

packages/core/src/backend.ts

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -190,19 +190,22 @@ export function expandSearchEntries(
190190
field: string;
191191
})[] {
192192
// expand the entries for the purpose of the search
193-
const expandedEntries = entries.reduce((acc, e) => {
194-
const expandedFields = searchFields.reduce((acc, f) => {
195-
const fields = expandPath({ data: e.data, path: f });
196-
acc.push(...fields);
197-
return acc;
198-
}, [] as string[]);
193+
const expandedEntries = entries.reduce(
194+
(acc, e) => {
195+
const expandedFields = searchFields.reduce((acc, f) => {
196+
const fields = expandPath({ data: e.data, path: f });
197+
acc.push(...fields);
198+
return acc;
199+
}, [] as string[]);
199200

200-
for (let i = 0; i < expandedFields.length; i++) {
201-
acc.push({ ...e, field: expandedFields[i] });
202-
}
201+
for (let i = 0; i < expandedFields.length; i++) {
202+
acc.push({ ...e, field: expandedFields[i] });
203+
}
203204

204-
return acc;
205-
}, [] as (Entry & { field: string })[]);
205+
return acc;
206+
},
207+
[] as (Entry & { field: string })[],
208+
);
206209

207210
return expandedEntries;
208211
}
@@ -212,27 +215,30 @@ export function mergeExpandedEntries(entries: (Entry & { field: string })[]): En
212215
const fields = entries.map(f => f.field);
213216
const arrayPaths: Record<string, Set<string>> = {};
214217

215-
const merged = entries.reduce((acc, e) => {
216-
if (!acc[e.slug]) {
217-
const { field: _field, ...rest } = e;
218-
acc[e.slug] = rest;
219-
arrayPaths[e.slug] = new Set();
220-
}
218+
const merged = entries.reduce(
219+
(acc, e) => {
220+
if (!acc[e.slug]) {
221+
const { field: _field, ...rest } = e;
222+
acc[e.slug] = rest;
223+
arrayPaths[e.slug] = new Set();
224+
}
221225

222-
const nestedFields = e.field.split('.');
223-
let value: ValueOrNestedValue = acc[e.slug].data;
224-
for (let i = 0; i < nestedFields.length; i++) {
225-
if (isNotNullish(value)) {
226-
value = value[nestedFields[i]];
227-
if (Array.isArray(value)) {
228-
const path = nestedFields.slice(0, i + 1).join('.');
229-
arrayPaths[e.slug] = arrayPaths[e.slug].add(path);
226+
const nestedFields = e.field.split('.');
227+
let value: ValueOrNestedValue = acc[e.slug].data;
228+
for (let i = 0; i < nestedFields.length; i++) {
229+
if (isNotNullish(value)) {
230+
value = value[nestedFields[i]];
231+
if (Array.isArray(value)) {
232+
const path = nestedFields.slice(0, i + 1).join('.');
233+
arrayPaths[e.slug] = arrayPaths[e.slug].add(path);
234+
}
230235
}
231236
}
232-
}
233237

234-
return acc;
235-
}, {} as Record<string, Entry>);
238+
return acc;
239+
},
240+
{} as Record<string, Entry>,
241+
);
236242

237243
// this keeps the search score sorting order designated by the order in entries
238244
// and filters non matching items

packages/core/src/backends/github/API.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,24 @@ function withCmsLabel(pr: GitHubPull, cmsLabelPrefix: string) {
129129
}
130130

131131
function getTreeFiles(files: GitHubCompareFiles) {
132-
const treeFiles = files.reduce((arr, file) => {
133-
if (file.status === 'removed') {
134-
// delete the file
135-
arr.push({ sha: null, path: file.filename });
136-
} else if (file.status === 'renamed') {
137-
// delete the previous file
138-
arr.push({ sha: null, path: file.previous_filename as string });
139-
// add the renamed file
140-
arr.push({ sha: file.sha, path: file.filename });
141-
} else {
142-
// add the file
143-
arr.push({ sha: file.sha, path: file.filename });
144-
}
145-
return arr;
146-
}, [] as { sha: string | null; path: string }[]);
132+
const treeFiles = files.reduce(
133+
(arr, file) => {
134+
if (file.status === 'removed') {
135+
// delete the file
136+
arr.push({ sha: null, path: file.filename });
137+
} else if (file.status === 'renamed') {
138+
// delete the previous file
139+
arr.push({ sha: null, path: file.previous_filename as string });
140+
// add the renamed file
141+
arr.push({ sha: file.sha, path: file.filename });
142+
} else {
143+
// add the file
144+
arr.push({ sha: file.sha, path: file.filename });
145+
}
146+
return arr;
147+
},
148+
[] as { sha: string | null; path: string }[],
149+
);
147150

148151
return treeFiles;
149152
}

packages/core/src/backends/gitlab/__tests__/gitlab.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,14 @@ describe('gitlab backend', () => {
250250
if (!query) {
251251
return {};
252252
}
253-
return query.split('&').reduce((acc, q) => {
254-
const [key, value] = q.split('=');
255-
acc[key] = value;
256-
return acc;
257-
}, {} as Record<string, string>);
253+
return query.split('&').reduce(
254+
(acc, q) => {
255+
const [key, value] = q.split('=');
256+
acc[key] = value;
257+
return acc;
258+
},
259+
{} as Record<string, string>,
260+
);
258261
}
259262

260263
interface CreateHeadersOptions {

packages/core/src/components/collections/CollectionHeader.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ const CollectionHeader: FC<CollectionHeaderProps> = ({ collection }) => {
3737

3838
const pluralLabel = useMemo(() => {
3939
if ('nested' in collection && collection.nested?.path && filterTerm) {
40-
const entriesByPath = entries.reduce((acc, entry) => {
41-
acc[entry.path] = entry;
42-
return acc;
43-
}, {} as Record<string, Entry>);
40+
const entriesByPath = entries.reduce(
41+
(acc, entry) => {
42+
acc[entry.path] = entry;
43+
return acc;
44+
},
45+
{} as Record<string, Entry>,
46+
);
4447

4548
if (isNotEmpty(filterTerm)) {
4649
const extension = selectFolderEntryExtension(collection);

packages/core/src/components/collections/entries/EntryListing.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ const EntryListing: FC<EntryListingProps> = ({
9090
}
9191

9292
const fieldNames = otherProps.collection.summary_fields;
93-
const collectionFields = selectFields(otherProps.collection).reduce((acc, f) => {
94-
acc[f.name] = f;
95-
return acc;
96-
}, {} as Record<string, Field>);
93+
const collectionFields = selectFields(otherProps.collection).reduce(
94+
(acc, f) => {
95+
acc[f.name] = f;
96+
return acc;
97+
},
98+
{} as Record<string, Field>,
99+
);
97100

98101
return fieldNames.map(summaryField => {
99102
const field = collectionFields[summaryField];

packages/core/src/components/common/autocomplete/Autocomplete.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ const Autocomplete: FC<AutocompleteProps> = ({
121121
const finalOptions = useMemo(() => options.map(getOptionLabelAndValue), [options]);
122122
const optionsByValue = useMemo(
123123
() =>
124-
finalOptions.reduce((acc, option) => {
125-
acc[option.value] = option;
124+
finalOptions.reduce(
125+
(acc, option) => {
126+
acc[option.value] = option;
126127

127-
return acc;
128-
}, {} as Record<string, Option>),
128+
return acc;
129+
},
130+
{} as Record<string, Option>,
131+
),
129132
[finalOptions],
130133
);
131134

0 commit comments

Comments
 (0)