import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"import/internal-regex" monorepo package are ignored

karolis-96 opened this issue · comments

It;s a little bit unclear based on docs how to implement import/internal-regex

So far I have eslint structure like this & tried to add internal regex for @global:

{
  "root": true,
  "extends": [
    "react-app",
    "airbnb",
    "plugin:jsx-a11y/recommended",
    "plugin:import/recommended",
    "prettier",
  ],
  "plugins": ["jsx-a11y", "prettier", "import"],
  "parser": "@typescript-eslint/parser",
  "rules": {
    "react/prop-types": 0,
    "react/react-in-jsx-scope": 0,
    "import/no-unresolved": "off",
    "no-unused-vars": 0,
    "react/require-default-props": 0,
    "import/extensions": [2, { "ts": "never", "tsx": "never" }],
    "react/function-component-definition": [0, { "allowAsProps": true }],
    "react/jsx-filename-extension": [1, { "extensions": [".tsx"] }],
    "no-shadow": "off",
    "@typescript-eslint/no-shadow": ["error"],
    "import/prefer-default-export": 0,
    "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
    "react/jsx-props-no-spreading": 0,
    "sort-imports": [
      "error",
      { "ignoreCase": true, "ignoreDeclarationSort": true },
    ],
    "import/order": [
      "error",
      {
        "groups": ["internal", "external", ["parent", "sibling"]],
        "pathGroups": [
          {
            "pattern": "@global",
            "group": "internal",
          },
          {
            "pattern": "@global/**",
            "group": "internal",
          },
        ],
        "pathGroupsExcludedImportTypes": [],
        "newlines-between": "always",
        "alphabetize": {
          "order": "asc",
          "caseInsensitive": true,
        },
      },
    ],
  },
  "parserOptions": {
    "ecmaVersion": 2021,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
    },
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
  },
  "settings": {
    "react": {
      "version": "detect",
    },
    "import/internal-regex": "@global/",
    "import/extensions": "never",
  },
}

, but all imports with @global becomes completely ignored. Here is an example where I expect error, that @global import should be inserted between 7-8 lines
image

@karolis-96 did you figure this out?

yes, after meddling around managed to make it work