Skip to content

Commit 2f084a3

Browse files
committed
guardian/eslint-config-typescript v12
This involved some dependency updates, including updating `typescript-eslint` from v7 to v8, which came with a number of breaking changes, detailed here: https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/ The first set of changes required to handle this were to our ESLint config. `no-var-requires` has been deprecated in favour of `no-require-imports`, and the former has been replaced by the latter in the `recommended` preset, which `guardian/eslint-config-typescript` extends. However, we had the former turned off, so this updates our config to turn the latter off instead. See: - https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/#rule-breaking-changes - https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/#updated-configuration-rules `ban-types` has been removed and replaced with `no-restricted-types`, `no-empty-object-type`, `no-unsafe-function-type` and `no-wrapper-object-types`. Previously we used `extendDefaults` to include the latter three rules. That option no longer exists, but they're included in the `recommended-type-checked` preset, which `guardian/eslint-config-typescript` extends, so they should still be present in our config. The remainder of our `ban-types` config involved banning a list of configurable types, which is now handled by `no-restricted-types`. See: - https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/#replacement-of-ban-types - https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/#updated-configuration-rules The second set of changes are to our source files, to fix issues surfaced by the rule changes. These have pre-emptively been handled in earlier commits, and amount to following these rules: - `no-unused-expressions` - `prefer-promise-reject-errors` - `no-empty-object-type` - `no-unsafe-function-type` There is one exception to this, where `prefer-promise-reject-errors` has been disabled for a particular issue in AR.
1 parent 7455158 commit 2f084a3

File tree

6 files changed

+421
-804
lines changed

6 files changed

+421
-804
lines changed

apps-rendering/config/.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ module.exports = {
118118
{
119119
files: ['**/*.tsx'],
120120
rules: {
121-
'@typescript-eslint/ban-types': [
121+
'@typescript-eslint/no-restricted-types': [
122122
'error',
123123
{
124124
types: {
@@ -132,7 +132,6 @@ module.exports = {
132132
'React.FC':
133133
'Please use const MyThing = ({foo, bar}: Props) instead',
134134
},
135-
extendDefaults: true,
136135
},
137136
],
138137
},

apps-rendering/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@guardian/cdk": "62.0.1",
4747
"@guardian/content-api-models": "31.0.0",
4848
"@guardian/content-atom-model": "6.1.0",
49-
"@guardian/eslint-config-typescript": "11.0.0",
49+
"@guardian/eslint-config-typescript": "12.0.0",
5050
"@guardian/libs": "22.0.0",
5151
"@guardian/renditions": "0.2.0",
5252
"@guardian/source": "9.0.0",
@@ -81,7 +81,7 @@
8181
"compression": "1.8.0",
8282
"constructs": "10.4.2",
8383
"core-js": "3.33.3",
84-
"eslint": "8.56.0",
84+
"eslint": "8.57.1",
8585
"eslint-plugin-jsx-a11y": "6.7.1",
8686
"eslint-plugin-react": "7.33.2",
8787
"express": "5.1.0",

apps-rendering/src/server/decoders.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const decodeContent =
3333

3434
return decoder.read(protocol);
3535
} else {
36+
/* eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors --
37+
* Part of an upgrade to get this rule enabled. */
3638
return Promise.reject('Invalid request');
3739
}
3840
};

dotcom-rendering/.eslintrc.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ module.exports = {
211211
files: ['**/**.js'],
212212
rules: {
213213
'global-require': 'off',
214-
'@typescript-eslint/no-var-requires': 'off',
214+
'@typescript-eslint/no-require-imports': 'off',
215215
'@typescript-eslint/no-unsafe-member-access': 'off',
216216
'@typescript-eslint/no-misused-promises': 'off',
217217
},
@@ -244,7 +244,7 @@ module.exports = {
244244
{
245245
files: ['**/**.tsx'],
246246
rules: {
247-
'@typescript-eslint/ban-types': [
247+
'@typescript-eslint/no-restricted-types': [
248248
'warn',
249249
{
250250
types: {
@@ -258,7 +258,7 @@ module.exports = {
258258
},
259259
},
260260
],
261-
'@typescript-eslint/ban-types': [
261+
'@typescript-eslint/no-restricted-types': [
262262
'error',
263263
{
264264
types: {
@@ -273,7 +273,6 @@ module.exports = {
273273
'React.FC':
274274
'Please use const MyThing = ({foo, bar}: Props) instead',
275275
},
276-
extendDefaults: true,
277276
},
278277
],
279278
},

dotcom-rendering/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@guardian/cdk": "62.0.1",
3535
"@guardian/commercial-core": "29.0.0",
3636
"@guardian/core-web-vitals": "7.0.0",
37-
"@guardian/eslint-config-typescript": "11.0.0",
37+
"@guardian/eslint-config-typescript": "12.0.0",
3838
"@guardian/identity-auth": "6.0.1",
3939
"@guardian/identity-auth-frontend": "8.1.0",
4040
"@guardian/libs": "26.0.1",
@@ -112,7 +112,7 @@
112112
"curlyquotes": "1.5.5",
113113
"dompurify": "3.2.4",
114114
"dynamic-import-polyfill": "0.1.1",
115-
"eslint": "8.56.0",
115+
"eslint": "8.57.1",
116116
"eslint-config-airbnb-base": "15.0.0",
117117
"eslint-config-airbnb-typescript": "17.0.0",
118118
"eslint-plugin-custom-elements": "0.0.8",

0 commit comments

Comments
 (0)