Skip to content
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

BUG:Missing file extension for ts file #239

Open
pincman opened this issue Aug 25, 2021 · 3 comments
Open

BUG:Missing file extension for ts file #239

pincman opened this issue Aug 25, 2021 · 3 comments

Comments

@pincman
Copy link

pincman commented Aug 25, 2021

every dependencies installed by pnpm

eslint config

extends: [
        'airbnb-base',
        'airbnb-typescript/base',
        'plugin:@typescript-eslint/eslint-recommended',
        'plugin:@typescript-eslint/recommended-requiring-type-checking',
        'plugin:jest/recommended',
        'prettier',
        'plugin:prettier/recommended',
    ],

tsconfig

"compilerOptions": {
        ...
        "baseUrl": "./",
        "paths": {
            "@/*": ["src/*"]
        }
    },

package.json

"eslint": "^7.32.0",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-config-airbnb-typescript": "^14.0.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.24.2",
    "eslint-plugin-jest": "^24.4.0",
    "eslint-plugin-prettier": "^3.4.1",
    "eslint-plugin-unused-imports": "^1.1.4",

and error
截屏2021-08-26 上午4 11 04

@hym33
Copy link

hym33 commented Jun 22, 2022

How to solve it?

@r34son
Copy link

r34son commented Dec 26, 2022

Seems like problem with path aliases. I fixed by adding "import/extensions": [ "error", "ignorePackages", { "": "never" } ] in rules.

@tikiram
Copy link

tikiram commented Aug 2, 2023

This library adds some basic configuration to import/extensions to mimic support for typescript (no actual TS import resolution). Follow the Typescript instructions of the eslint-plugin-import package (https://www.npmjs.com/package/eslint-plugin-import) to get real TS support (including aliases).

The final result will be something like this:

{
  "env": {
    "es2021": true,
    "node": true
  },
  "extends": [
    "airbnb-base",
    "airbnb-typescript/base",
    "plugin:import/typescript",
    "plugin:@typescript-eslint/recommended-type-checked",
    "plugin:@typescript-eslint/stylistic-type-checked",
    "prettier"
  ],
  "ignorePatterns": [".eslintrc.js"],
  "parser": "@typescript-eslint/parser",
  "overrides": [],
  "parserOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module",
    "project": "./tsconfig.json"
  },
  "settings": {
    "import/resolver": {
      "typescript": true
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants