Skip to content

Commit 258ea6d

Browse files
authored
Refactor/typescript migration deps (#909)
* refactor(tsconfig): Reorganize tsconfig.json to prep for typescript migration. Bump target version to ES6 as it meets 95% compatibility threshold. Include es2022 lib for Object.hasOwn and other useful checks for typescript compat. Enumerates tsconfig type checking options. Ideally, as the migration progresses, more of these feature flags can be enabled until strict mode can be turned on. Split into a build config and a type checking config to use parser services Signed-off-by: Drew Hoener <[email protected]> * refactor(types): Add expected error after setting the subscribe callback Signed-off-by: Drew Hoener <[email protected]> * refactor(eslint): Add type aware eslint config, disable rules that conflict for now Signed-off-by: Drew Hoener <[email protected]> --------- Signed-off-by: Drew Hoener <[email protected]>
1 parent 8d21f3d commit 258ea6d

File tree

8 files changed

+661
-28
lines changed

8 files changed

+661
-28
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ examples
88
jsdoc_conf.json
99
test
1010
tsconfig.json
11+
tsconfig.build.json

eslint.config.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
15
import globals from 'globals';
26

3-
export default [
7+
export default tseslint.config(
8+
eslint.configs.recommended,
9+
{
10+
// Linting rules for TS files, should be combined with the base config when migration is complete
11+
files: ['**/*.{ts,tsx}'],
12+
extends: [
13+
...tseslint.configs.strictTypeChecked,
14+
...tseslint.configs.stylisticTypeChecked,
15+
],
16+
languageOptions: {
17+
parser: tseslint.parser,
18+
parserOptions: {
19+
projectService: true,
20+
},
21+
}
22+
},
423
{
524
languageOptions: {
625
'globals': {
26+
...globals.es2020,
727
...globals.browser,
828
...globals.node,
929
'bson': true
@@ -18,6 +38,14 @@ export default [
1838
{
1939
ignores: ['dist']
2040
},
41+
{
42+
// FIXME: Recommended rules that have been turned off to maintain compatibility with the current codebase
43+
rules: {
44+
'no-useless-escape': 0,
45+
'no-unused-vars': 0,
46+
'no-prototype-builtins': 0,
47+
}
48+
},
2149
{
2250
rules: {
2351
curly: 2,
@@ -35,6 +63,6 @@ export default [
3563
'linebreak-style': 2,
3664
'key-spacing': [2, {afterColon: true}]
3765
},
38-
files: ['**/*.{js,jsx,cjs}']
66+
files: ['**/*.{js,jsx,ts,tsx,cjs}'],
3967
}
40-
];
68+
);

0 commit comments

Comments
 (0)