feature-sliced / eslint-config

🍰 Lint feature-sliced concepts by existing eslint plugins
https://npmjs.com/@feature-sliced/eslint-config
MIT License
117 stars 4 forks source link

LINT: import/no-internal-modules not support aliases #89

Closed Krakazybik closed 2 years ago

Krakazybik commented 2 years ago

Problem:

Правило import/no-internal-modules игнорирует (ни как не реагирует) на альясы ~@# etc.

Version: 0.1.0-beta Severity: 🟥 CRITICAL

Krakazybik commented 2 years ago

Дано: CRA v5

eslintrc

{
    "extends": [
        "@feature-sliced/eslint-config"
    ],
    "parserOptions": {
        "project": "./tsconfig.json",
        "ecmaVersion": 2021,
        "sourceType": "module"
    },
    "settings": {
        "import/resolver": {
            "typescript": {
                "alwaysTryTypes": true
            }
        }
    },

    "rules": {

    }
}

package.json

{
  "name": "untitled",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.2",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.4.0",
    "@types/node": "^16.11.22",
    "@types/react": "^17.0.39",
    "@types/react-dom": "^17.0.11",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "5.0.0",
    "typescript": "^4.5.5",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@feature-sliced/eslint-config": "^0.1.0-beta.4",
    "@typescript-eslint/eslint-plugin": "^5.10.2",
    "@typescript-eslint/parser": "^5.10.2",
    "eslint": "^8.8.0",
    "eslint-import-resolver-typescript": "^2.5.0",
    "eslint-plugin-boundaries": "^2.8.0",
    "eslint-plugin-import": "^2.25.4"
  }
}

tsconfig

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@/*": ["./*"]
    },
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}

при таких настройках, любые импорты с альясами считаются правилом no-internal-modules как глобальные и игнорируются.

пример image

azinit commented 2 years ago

@Krakazybik в итоге же ведь удалось решить? Можем закрывать?

Krakazybik commented 2 years ago

вроде как да)