import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.57k stars 1.57k forks source link

[import/no-unresolved] I get errors on all imports #2623

Open Jamu2800 opened 1 year ago

Jamu2800 commented 1 year ago

I worked on the problem with the help of this issue but could not solve the problem.

I would appreciate your help.

my problem

All imports are causing import/no-unresolved image

my project dir

image

settings

.eslintrc.json

{
  "env": {
    "browser": true,
    "commonjs": true,
    "es2021": true
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": "latest",
    "project": "./tsconfig.json"
  },
  "plugins": [
    "@typescript-eslint",
    "simple-import-sort",
    "import"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    "plugin:prettier/recommended",
    "prettier",
    "plugin:import/errors"
  ],
  "settings": {
    "import/resolver": {
      "import/parsers": {
        "@typescript-eslint/parser": [".ts", ".tsx"]
      },
      "import/resolver": {
        "typescript": {}
      }
    }
  },
  "rules": {
    "no-restricted-imports": [
      "error",
      { "patterns": [ "./", "../", "~/" ] }
    ],
    "@typescript-eslint/no-inferrable-types": "error",
    "prettier/prettier": [
      "error",
      { "semi": false }
    ],
    "simple-import-sort/imports": "error",
    "simple-import-sort/exports": "error",
    "import/first": "error",
    "import/newline-after-import": "error",
    "import/no-duplicates": "error",
    "import/order": [
      "error",
      {
        "groups": [
          "index",
          "sibling",
          "parent",
          "internal",
          "external",
          "builtin",
          "object",
          "type"
        ]
      }
    ]
  }
}

package.json

{
  .....more settings
  "dependencies": {
    "ag-psd": "^15.0.1",
    "canvas": "^2.11.0",
    "eslint-import-resolver-custom-alias": "^1.3.0",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.4"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.47.0",
    "@typescript-eslint/parser": "^5.47.0",
    "eslint": "^8.30.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-import-resolver-typescript": "^3.5.2",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-simple-import-sort": "^8.0.0",
    "prettier": "2.8.1",
    "tsconfig-paths": "^4.1.1"
  }
}

tsconfig.json

{
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig to read more about this file */

    /* Language and Environment */
    "target": "es2016",

    /* Modules */
    "module": "commonjs",
    /* Specify what module code is generated. */
    "rootDir": "./src",
    "baseUrl": "./src",
    /* Specify the base directory to resolve non-relative module names. */
    "paths": {
      "@typescript/*": [
        "typescript/*"
      ],
      "@resource/*": [
        "resource/*"
      ]
    },

    /* Emit */
    "outDir": "./out",

    /* Interop Constraints */
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,

    /* Type Checking */
    "strict": true
  }
}
ljharb commented 1 year ago

You're missing the import/extensions setting.

Jamu2800 commented 1 year ago

Thank you for your reply. Can't I use "plugin:import/errors" for typescript?

ljharb commented 1 year ago

No, that's what import/config/typescript is for.