Skip to content

Commit 69758a8

Browse files
authored
guardian/eslint-config-typescript v12 (#14747)
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 7533b0c commit 69758a8

File tree

6 files changed

+436
-844
lines changed

6 files changed

+436
-844
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",
@@ -75,7 +75,7 @@
7575
"compression": "1.8.0",
7676
"constructs": "10.4.2",
7777
"core-js": "3.33.3",
78-
"eslint": "8.56.0",
78+
"eslint": "8.57.1",
7979
"eslint-plugin-jsx-a11y": "6.7.1",
8080
"eslint-plugin-react": "7.33.2",
8181
"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
@@ -212,7 +212,7 @@ module.exports = {
212212
files: ['**/**.js'],
213213
rules: {
214214
'global-require': 'off',
215-
'@typescript-eslint/no-var-requires': 'off',
215+
'@typescript-eslint/no-require-imports': 'off',
216216
'@typescript-eslint/no-unsafe-member-access': 'off',
217217
'@typescript-eslint/no-misused-promises': 'off',
218218
},
@@ -245,7 +245,7 @@ module.exports = {
245245
{
246246
files: ['**/**.tsx'],
247247
rules: {
248-
'@typescript-eslint/ban-types': [
248+
'@typescript-eslint/no-restricted-types': [
249249
'warn',
250250
{
251251
types: {
@@ -259,7 +259,7 @@ module.exports = {
259259
},
260260
},
261261
],
262-
'@typescript-eslint/ban-types': [
262+
'@typescript-eslint/no-restricted-types': [
263263
'error',
264264
{
265265
types: {
@@ -274,7 +274,6 @@ module.exports = {
274274
'React.FC':
275275
'Please use const MyThing = ({foo, bar}: Props) instead',
276276
},
277-
extendDefaults: true,
278277
},
279278
],
280279
},

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",
@@ -104,7 +104,7 @@
104104
"curlyquotes": "1.5.5",
105105
"dompurify": "3.2.4",
106106
"dynamic-import-polyfill": "0.1.1",
107-
"eslint": "8.56.0",
107+
"eslint": "8.57.1",
108108
"eslint-config-airbnb-base": "15.0.0",
109109
"eslint-config-airbnb-typescript": "17.0.0",
110110
"eslint-plugin-custom-elements": "0.0.8",

0 commit comments

Comments
 (0)