Skip to content

Commit de8e54a

Browse files
authored
Upgrade eslint to v9 with newer recommended configs (#1760)
1 parent 7e16383 commit de8e54a

16 files changed

+1292
-840
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 18 deletions
This file was deleted.

.eslintrc.dist.cjs

Lines changed: 0 additions & 21 deletions
This file was deleted.

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"semi": true,
55
"tabWidth": 2,
66
"printWidth": 100,
7-
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
7+
"importOrder": ["<THIRD_PARTY_TS_TYPES>", "^[./]"],
88
"importOrderSeparation": false,
99
"importOrderSortSpecifiers": true,
1010
"importOrderParserPlugins": ["typescript"],

eslint.config.dist.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @ts-check
2+
import compat from 'eslint-plugin-compat';
3+
4+
const compatPlugin = compat.configs['flat/recommended'];
5+
6+
compatPlugin.settings = { ...compatPlugin.settings, lintAllEsApis: true };
7+
8+
if (compatPlugin.rules) {
9+
compatPlugin.rules['compat/compat'] = 'warn'; // TODO once we've updated browser support and use feature detection that this plugin can understand we can change this to 'error'
10+
}
11+
12+
export default [compatPlugin];

eslint.config.mjs

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
// @ts-check
2+
import js from '@eslint/js';
3+
import { configs, plugins, rules } from 'eslint-config-airbnb-extended';
4+
import { rules as prettierConfigRules } from 'eslint-config-prettier';
5+
import prettierPlugin from 'eslint-plugin-prettier';
6+
7+
const strictness = 'off';
8+
9+
const jsConfig = [
10+
// ESLint Recommended Rules
11+
{
12+
name: 'js/config',
13+
...js.configs.recommended,
14+
},
15+
// Stylistic Plugin
16+
plugins.stylistic,
17+
// Import X Plugin
18+
plugins.importX,
19+
// Airbnb Base Recommended Config
20+
...configs.base.recommended,
21+
// Strict Import Config
22+
rules.base.importsStrict,
23+
];
24+
25+
const typescriptConfig = [
26+
// TypeScript ESLint Plugin
27+
plugins.typescriptEslint,
28+
// Airbnb Base TypeScript Config
29+
...configs.base.typescript,
30+
// Strict TypeScript Config
31+
rules.typescript.typescriptEslintStrict,
32+
];
33+
34+
const prettierConfig = [
35+
// Prettier Plugin
36+
{
37+
name: 'prettier/plugin/config',
38+
plugins: {
39+
prettier: prettierPlugin,
40+
},
41+
},
42+
// Prettier Config
43+
{
44+
name: 'prettier/config',
45+
rules: {
46+
...prettierConfigRules,
47+
'prettier/prettier': 'error',
48+
},
49+
},
50+
];
51+
52+
export default [
53+
// Javascript Config
54+
...jsConfig,
55+
// TypeScript Config
56+
...typescriptConfig,
57+
// Prettier Config
58+
...prettierConfig,
59+
{
60+
languageOptions: {
61+
parserOptions: {
62+
projectService: false,
63+
project: './tsconfig.eslint.json',
64+
},
65+
},
66+
rules: {
67+
'import/export': 'off',
68+
'max-classes-per-file': 'off',
69+
'no-param-reassign': 'off',
70+
'no-await-in-loop': 'off',
71+
'no-restricted-syntax': 'off',
72+
'consistent-return': 'off',
73+
'class-methods-use-this': 'off',
74+
'no-underscore-dangle': 'off',
75+
76+
// compat rules to make lint temporarily pass after upgrading to eslint v9 and airbnb-config-extended
77+
// these can then get removed one by one to allow for small and focused PRs
78+
'import-x/prefer-default-export': strictness,
79+
'import-x/order': strictness,
80+
'import-x/consistent-type-specifier-style': strictness,
81+
'import-x/no-cycle': strictness,
82+
'import-x/no-extraneous-dependencies': strictness,
83+
'import-x/export': strictness,
84+
'import-x/no-namespace': strictness,
85+
86+
'@typescript-eslint/no-use-before-define': strictness,
87+
'@typescript-eslint/consistent-type-definitions': strictness,
88+
'@typescript-eslint/explicit-module-boundary-types': strictness,
89+
'@typescript-eslint/no-explicit-any': strictness,
90+
'@typescript-eslint/ban-ts-comment': strictness,
91+
'@typescript-eslint/no-wrapper-object-types': strictness,
92+
'@typescript-eslint/consistent-type-imports': strictness,
93+
'@typescript-eslint/method-signature-style': strictness,
94+
'@typescript-eslint/unified-signatures': strictness,
95+
'@typescript-eslint/no-unsafe-return': strictness,
96+
'@typescript-eslint/await-thenable': strictness,
97+
'@typescript-eslint/prefer-regexp-exec': strictness,
98+
'@typescript-eslint/no-confusing-void-expression': strictness,
99+
'@typescript-eslint/no-empty-object-type': strictness,
100+
'@typescript-eslint/no-import-type-side-effects': strictness,
101+
'@typescript-eslint/no-invalid-void-type': strictness,
102+
'@typescript-eslint/no-namespace': strictness,
103+
'@typescript-eslint/prefer-destructuring': strictness,
104+
'@typescript-eslint/consistent-type-assertions': strictness,
105+
'@typescript-eslint/no-unnecessary-type-assertion': strictness,
106+
'@typescript-eslint/no-non-null-assertion': strictness,
107+
'@typescript-eslint/prefer-optional-chain': strictness,
108+
'@typescript-eslint/prefer-for-of': strictness,
109+
'@typescript-eslint/no-duplicate-type-constituents': strictness,
110+
'@typescript-eslint/consistent-indexed-object-style': strictness,
111+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': strictness,
112+
'@typescript-eslint/class-literal-property-style': strictness,
113+
'@typescript-eslint/consistent-generic-constructors': strictness,
114+
'@typescript-eslint/promise-function-async': strictness,
115+
'@typescript-eslint/no-unsafe-enum-comparison': strictness,
116+
'@typescript-eslint/no-redundant-type-constituents': strictness,
117+
'@typescript-eslint/prefer-reduce-type-parameter': strictness,
118+
'@typescript-eslint/no-unused-vars': strictness,
119+
'@typescript-eslint/prefer-includes': strictness,
120+
'@typescript-eslint/no-misused-spread': strictness,
121+
'@typescript-eslint/consistent-type-exports': strictness,
122+
'@typescript-eslint/prefer-function-type': strictness,
123+
'@typescript-eslint/prefer-find': strictness,
124+
125+
'@stylistic/spaced-comment': strictness,
126+
127+
'no-self-assign': strictness,
128+
'no-plusplus': strictness,
129+
'no-bitwise': strictness,
130+
'no-else-return': strictness,
131+
'no-nested-ternary': strictness,
132+
'no-promise-executor-return': strictness,
133+
'prefer-const': strictness,
134+
'prefer-exponentiation-operator': strictness,
135+
'no-async-promise-executor': strictness,
136+
'no-console': strictness,
137+
'no-restricted-properties': strictness,
138+
'no-undef-init': strictness,
139+
'no-irregular-whitespace': strictness,
140+
'object-shorthand': strictness,
141+
'no-case-declarations': strictness,
142+
'no-useless-escape': strictness,
143+
'no-useless-catch': strictness,
144+
'no-useless-return': strictness,
145+
'no-return-assign': strictness,
146+
'no-fallthrough': strictness,
147+
'default-case': strictness,
148+
'operator-assignment': strictness,
149+
'prefer-promise-reject-errors': strictness,
150+
'no-continue': strictness,
151+
'arrow-body-style': strictness,
152+
'no-new': strictness,
153+
'vars-on-top': strictness,
154+
'no-var': strictness,
155+
'no-restricted-globals': strictness,
156+
'no-lonely-if': strictness,
157+
'no-empty': strictness,
158+
'one-var': strictness,
159+
'no-multi-assign': strictness,
160+
'new-cap': strictness,
161+
162+
radix: strictness,
163+
eqeqeq: strictness,
164+
165+
// debatable
166+
'@typescript-eslint/array-type': 'off',
167+
'@typescript-eslint/no-inferrable-types': 'off',
168+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
169+
},
170+
},
171+
];

examples/rpc/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import dotenv from 'dotenv';
22
import express from 'express';
3-
import type { Express } from 'express';
43
import { AccessToken } from 'livekit-server-sdk';
4+
import type { Express } from 'express';
55

66
dotenv.config({ path: '.env.local' });
77

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"format:check": "prettier --check src examples/**/*.ts",
5252
"ci:publish": "pnpm build:clean && pnpm compat && changeset publish",
5353
"downlevel-dts": "downlevel-dts ./dist/src ./dist/ts4.2 --to=4.2",
54-
"compat": "eslint --no-eslintrc --config ./.eslintrc.dist.cjs ./dist/livekit-client.umd.js",
54+
"compat": "eslint --config ./eslint.config.dist.mjs --no-inline-config ./dist/livekit-client.esm.mjs",
5555
"size-limit": "size-limit"
5656
},
5757
"dependencies": {
@@ -74,6 +74,7 @@
7474
"@babel/preset-env": "7.28.5",
7575
"@bufbuild/protoc-gen-es": "^1.10.0",
7676
"@changesets/cli": "2.29.7",
77+
"@eslint/js": "9.39.1",
7778
"@livekit/changesets-changelog-github": "^0.0.4",
7879
"@rollup/plugin-babel": "6.1.0",
7980
"@rollup/plugin-commonjs": "28.0.9",
@@ -82,18 +83,20 @@
8283
"@rollup/plugin-terser": "^0.4.4",
8384
"@size-limit/file": "^11.2.0",
8485
"@size-limit/webpack": "^11.2.0",
86+
"@stylistic/eslint-plugin": "^3.1.0",
8587
"@trivago/prettier-plugin-sort-imports": "^5.0.0",
8688
"@types/events": "^3.0.3",
8789
"@types/sdp-transform": "2.15.0",
8890
"@types/ua-parser-js": "0.7.39",
8991
"@typescript-eslint/eslint-plugin": "7.18.0",
9092
"@typescript-eslint/parser": "7.18.0",
9193
"downlevel-dts": "^0.11.0",
92-
"eslint": "8.57.1",
93-
"eslint-config-airbnb-typescript": "18.0.0",
94+
"eslint": "9.39.1",
95+
"eslint-config-airbnb-extended": "^2.3.2",
9496
"eslint-config-prettier": "10.1.8",
95-
"eslint-plugin-ecmascript-compat": "^3.2.1",
96-
"eslint-plugin-import": "2.32.0",
97+
"eslint-plugin-compat": "^6.0.2",
98+
"eslint-plugin-import-x": "^4.16.1",
99+
"eslint-plugin-prettier": "^5.5.4",
97100
"gh-pages": "6.3.0",
98101
"happy-dom": "^17.2.0",
99102
"jsdom": "^26.1.0",
@@ -105,6 +108,7 @@
105108
"typedoc": "0.28.14",
106109
"typedoc-plugin-no-inherit": "1.6.1",
107110
"typescript": "5.8.3",
111+
"typescript-eslint": "^8.47.0",
108112
"vite": "7.2.2",
109113
"vitest": "^3.0.0"
110114
},

0 commit comments

Comments
 (0)