Closed RashiqAzhan closed 3 months ago
Shouldn't import/no-unresolved be off by default according to the docs? It seems to not be working as expected for my case.
import/no-unresolved
package.json
{ "name": "typescript-eslint-airbnb-compat", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "tsc && vite build", "preview": "vite preview", "lint": "eslint .", "lint:fix": "npm run lint -- --fix", "format": "prettier . --check", "format:fix": "npm run format -- --write" }, "devDependencies": { "@eslint/eslintrc": "^3.0.2", "@eslint/js": "^8.57.0", "@typescript-eslint/eslint-plugin": "^7.5.0", "@typescript-eslint/parser": "^7.5.0", "eslint": "^8.57.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^18.0.0", "eslint-plugin-import": "^2.25.2", "eslint-config-prettier": "^9.1.0", "tslib": "^2.6.2", "typescript": "^5.4.3", "typescript-eslint": "^7.4.0", "vite": "^5.2.0" } }
eslint.config.mjs
import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; import eslintConfigPrettier from "eslint-config-prettier"; import { FlatCompat } from "@eslint/eslintrc"; import path from "path"; import { fileURLToPath } from "url"; const filename = fileURLToPath(import.meta.url); const dirname = path.dirname(filename); const compat = new FlatCompat({ baseDirectory: dirname }); export default tseslint.config( eslint.configs.recommended, ...compat.extends("airbnb-base"), ...compat.extends("airbnb-typescript/base"), ...tseslint.configs.recommendedTypeChecked, eslintConfigPrettier, { languageOptions: { parserOptions: { project: true, tsconfigRootDir: import.meta.dirname, }, }, }, { files: ['**/*.{js,jsx,cjs,mjs}'], extends: [tseslint.configs.disableTypeChecked], } );
tsconfig.json
{ "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, "module": "ESNext", "lib": ["ES2020", "DOM", "DOM.Iterable"], "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, "include": ["src"] }
Terminal Output:
.../typescript-eslint-airbnb-compat/eslint.config.mjs 2:22 error Unable to resolve path to module 'typescript-eslint' import/no-unresolved
You didn't config eslint-import-resolver-typescript at all.
eslint-import-resolver-typescript
Shouldn't
import/no-unresolved
be off by default according to the docs? It seems to not be working as expected for my case.package.json
eslint.config.mjs
tsconfig.json
Terminal Output: