-
-
Notifications
You must be signed in to change notification settings - Fork 36
Unable to resolve path to module
on bun
or modules with bun:
prefix
#92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Configuration Solution / WorkaroundIf automating this based on the TS types in
const configArray = [
rules: {
'import-x/no-unresolved':
- 'error',
+ [
+ 'error',
+ {
+ ignore: ['^bun(:\\w+)?$'],
+ },
+ ],
},
},
]; Full configimport eslintTypescript from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import eslintImportX from 'eslint-plugin-import-x';
import globals from 'globals';
/** @type
* {import('@typescript-eslint/utils/ts-eslint').FlatConfig.ConfigArray}
* */
const configArray = [
{
// Lint common extensions by default with rules above
files: [
'**/*.js',
'**/*.jsx',
'**/*.cjs',
'**/*.mjs',
'**/*.ts',
'**/*.tsx',
'**/*.cts',
'**/*.mts',
],
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: './tsconfig.json',
// typescript-eslint specific options
warnOnUnsupportedTypeScriptVersion: true,
},
globals: {
...globals.browser,
...globals.node,
...globals.commonjs,
...globals.es2021,
// Allow using React as a global without importing it
React: true,
},
},
plugins: {
'@typescript-eslint': {
rules: eslintTypescript.rules,
},
'import-x': eslintImportX,
},
settings: {
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import-x/resolver': {
// Load <rootdir>/tsconfig.json
typescript: true,
node: true,
},
},
rules: {
// Error on imports that don't match the underlying file
// system
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
'import-x/no-unresolved': [
'error',
{
ignore: ['^bun:\\w+$'],
},
],
},
},
];
export default configArray; |
Unable to resolve path to module
on modules with 'bun:' prefixUnable to resolve path to module
on bun
or modules with bun:
prefix
import { isBuiltin } from 'node:module'
console.log(isBuiltin('bun:sqlite'))
// In Node.js: false
// In Bun: true Thus we can't use |
Ah just saw this other PR: I guess once this is published and |
@karlhorky You don't have to upgrade I just became the co-maintainer of |
The latest version of |
@SukkaW thanks for the heads up! Yeah indeed, I can confirm that Relevant PR from @SunsetTechuila : This uses the new |
Ah, just upgraded dependencies and received $ yarn eslint . --max-warnings 0
$ /home/runner/work/courses/courses/node_modules/.bin/eslint . --max-warnings 0
/home/runner/work/courses/courses/packages/curriculum-versions/curriculumVersions/2024-3-fall-pern-extensive-eu/drone/__tests__/smokeTest.test.ts
Error: 2:30 error Unable to resolve path to module 'bun:test' import-x/no-unresolved
/home/runner/work/courses/courses/packages/curriculum-versions/curriculumVersions/2025-1-winter-pern-extensive-eu/drone/__tests__/smokeTest.test.ts
Error: 2:30 error Unable to resolve path to module 'bun:test' import-x/no-unresolved
/home/runner/work/courses/courses/packages/fusion.upleveled.io/__tests__/smokeTestDevServer.test.ts
Error: 6:30 error Unable to resolve path to module 'bun:test' import-x/no-unresolved
/home/runner/work/courses/courses/packages/learn.upleveled.io/__tests__/smokeTestDevServer.test.ts
Error: 6:30 error Unable to resolve path to module 'bun:test' import-x/no-unresolved Looking into the last dependency changes, it appears that
@JounQin @SukkaW should this be added to the readme of |
@karlhorky Sorry for breaking, feel free to PR!
eslint-import-resolver-typescript |
@JounQin thanks for the release! I'll try to track down what changes are needed (maybe even code changes to Some things which I tried so far which didn't work:
|
@karlhorky No change needed in Did you enable |
Ah yeah, I forgot that I configured I'll take a look at:
|
@karlhorky I'd recommend using (This part is also missing in |
Nice, this looks great! I'll wait until it's not marked |
Importing modules with
bun:
prefix (eg.bun:test
) orbun
itself with@types/bun
installed results in a resolution error withimport-x/no-unresolved
index.test.ts
The text was updated successfully, but these errors were encountered: