Skip to content

Commit eb76568

Browse files
lorensrJounQin
andauthored
chore: Add eslint-import-resolver-typescript (#771)
* chore: Add eslint-import-resolver-typescript * Update .eslintrc Co-authored-by: JounQin <admin@1stg.me> * Fail on ts-prune nonempty * build before lint * order * confirmed exit code 1 * Add import rules * Fix lint * wrap * npm i * Address review comments * Move @types/uuid to devDep * fix build * fix lint errors * fix lint * fix circular imports; prettier * rm deleted files * mv PayloadConverterWithEncoding * fix * Fix test-npm-init * update lint-and-prune * Remove unused MakeOptional * address comments * dedup * use randomUUID instead of uuid * update deps * Update `tsconfig.prune.json` * fix lint? * use a duplicate import rule that works in ci * Fix CI lint * update core to same as main * fix lint errors Co-authored-by: JounQin <admin@1stg.me>
1 parent e6c4c42 commit eb76568

Some content is hidden

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

54 files changed

+2014
-724
lines changed

.eslintrc

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
"parserOptions": {
55
"project": "./packages/*/tsconfig.json"
66
},
7-
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc", "deprecation"],
7+
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc", "deprecation", "import"],
88
"extends": [
99
"eslint:recommended",
1010
"plugin:@typescript-eslint/eslint-recommended",
1111
"plugin:@typescript-eslint/recommended",
1212
"prettier"
1313
],
1414
"rules": {
15+
"no-duplicate-imports": "error",
1516
"object-shorthand": ["error", "always"],
1617
"deprecation/deprecation": "warn",
1718
"@typescript-eslint/no-explicit-any": 0,
@@ -23,6 +24,42 @@
2324
"argsIgnorePattern": "^_",
2425
"varsIgnorePattern": "^_"
2526
}
26-
]
27+
],
28+
"import/no-unresolved": ["error", { "ignore": ["^__temporal_"] }],
29+
// TypeScript compilation already ensures that named imports exist in the referenced module
30+
"import/named": "off",
31+
"import/default": "error",
32+
"import/namespace": "error",
33+
"import/no-absolute-path": "error",
34+
"import/no-self-import": "error",
35+
"import/no-cycle": "error",
36+
"import/no-useless-path-segments": "error",
37+
"import/no-relative-packages": "error",
38+
"import/export": "error",
39+
"import/no-named-as-default": "error",
40+
// TODO enable and fix
41+
// "import/no-deprecated": "error",
42+
"import/no-extraneous-dependencies": "error",
43+
"import/no-mutable-exports": "error",
44+
"import/unambiguous": "error",
45+
"import/first": "error",
46+
// TODO next PR
47+
// "import/order": "error",
48+
"import/newline-after-import": "error",
49+
"import/no-unassigned-import": "error",
50+
"import/no-named-default": "error"
51+
},
52+
"settings": {
53+
"import/parsers": {
54+
"@typescript-eslint/parser": [".ts"]
55+
},
56+
"import/resolver": {
57+
"typescript": {
58+
// always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like
59+
// `@types/unist`
60+
"alwaysTryTypes": true,
61+
"project": ["packages/*/tsconfig.json"]
62+
}
63+
}
2764
}
2865
}

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ jobs:
116116
- uses: actions/setup-node@v1
117117
with:
118118
node-version: 16
119-
# Don't build during install phase since we don't need builds for linting
120119
- run: npm ci --ignore-scripts
120+
# eslint-import-resolver-typescript requires packages to be built
121+
- name: Compile all non-rust code
122+
run: npm run build -- --ignore @temporalio/core-bridge
121123
- run: npm run lint
122124
- run: npm run lint.prune
123125

0 commit comments

Comments
 (0)