oxc-project / eslint-plugin-oxlint

Turn off all rules already supported by oxlint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom rules or `eslintrc.json` config is not working properly

cristianpoleyJS opened this issue · comments

Using lint-staged

  "lint-staged": {
    "*.{js,jsx,ts,tsx}": [
      "biome format --write --no-errors-on-unmatched",
      "oxlint -c .eslintrc.json --import-plugin --jest-plugin --max-warnings=0 --ignore-pattern '!.storybook' --ignore-pattern '!.storybook/main.ts' --ignore-pattern '!.storybook/preview.js'"
    ]
  },

And I want to reuse the configuration I have from my eslintrc.json:

{
  "extends": [
    "react-app",
    "plugin:no-lookahead-lookbehind-regexp/recommended",
    "plugin:playwright/playwright-test",
    "plugin:oxlint/recommended"
  ],
  "plugins": ["my-custom-plugin", "jest"],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "./tsconfig.json",
    "ecmaFeatures": {
      "jsx": true,
      "globalReturn": false
    },
    "ecmaVersion": 2020,
    "sourceType": "module"
  },
  "rules": {
    "no-debugger": 2,
    "no-console": 1,
    "my-custom-plugin/no-date-parse": 1,
    "my-custom-plugin/no-new-date": 1,
    "my-custom-plugin/no-make-styles": 0,
    "my-custom-plugin/no-spread-icon-import": 2,
    "my-custom-plugin/no-barrel-material-import": 2,
    "my-custom-plugin/no-unscoped-lodash-imports": 2,
    "my-custom-plugin/required-playwright-test-setup": 2,
    "my-custom-plugin/no-notistack-imports": 1,
    "my-custom-plugin/icon-name-match-filename": 2,
    "my-custom-plugin/no-playwright-test-import": 2,
    "playwright/no-conditional-in-test": 0,
    "playwright/no-force-option": 0,
    "playwright/no-skipped-test": 1,
    "@typescript-eslint/consistent-type-imports": 1,
    "@typescript-eslint/ban-ts-comment": [
      "error",
      {
        "ts-expect-error": "allow-with-description",
        "ts-ignore": "allow-with-description",
        "ts-nocheck": "allow-with-description",
        "minimumDescriptionLength": 10
      }
    ],
    "my-custom-plugin/prefer-my-component": [ <!--- THIS IS THE RULE
      "warn",
      {
        "paths": [
          "@mui/material/Tab",
          "@mui/material/Button",
          "@mui/material/Tooltip",
          "@mui/material/Chip",
          "@mui/material/Select",
          "@mui/material/Tab/Tab",
          "@mui/material/Button/Button",
          "@mui/material/Tooltip/Tooltip",
          "@mui/material/Chip/Chip",
          "@mui/material/Select/Select"
        ]
      }
    ],
    "jest/no-focused-tests": "error",
    "jest/no-identical-title": "error"
  },
  "overrides": [
    {
      "files": ["**/*.stories.*"],
      "rules": {
        "import/no-anonymous-default-export": "off"
      }
    },
    {
      "files": ["src/**/*.{ts,tsx}"],
      "rules": {
        "playwright/missing-playwright-await": 0
      }
    },
    {
      "env": {
        "commonjs": true,
        "node": true,
        "browser": false,
        "es6": true
      },
      "files": ["config/jest/*.{ts,js}"],
      "parser": "@babel/eslint-parser",
      "parserOptions": {
        "ecmaVersion": 11,
        "sourceType": "script"
      }
    },
    {
      "env": {
        "commonjs": true,
        "node": true,
        "browser": false,
        "es6": true,
        "jest": false
      },
      "files": ["jest.config.js", "scripts/*.js", "eslint-plugin-my-custom-plugin/**/*.js"],
      "parser": "@babel/eslint-parser",
      "parserOptions": {
        "ecmaVersion": 11,
        "sourceType": "script"
      }
    },
    {
      "files": "scripts/*.ts",
      "parser": "@typescript-eslint/parser",
      "parserOptions": {
        "project": "./scripts/tsconfig.json",
        "ecmaFeatures": {
          "jsx": false,
          "globalReturn": false
        },
        "ecmaVersion": 2020,
        "sourceType": "module"
      }
    },
    {
      "files": "scripts/esbuild-jest/src/*.ts",
      "parser": "@typescript-eslint/parser",
      "parserOptions": {
        "project": "./scripts/esbuild-jest/tsconfig.json",
        "ecmaFeatures": {
          "jsx": false,
          "globalReturn": false
        },
        "ecmaVersion": 2020,
        "sourceType": "module"
      }
    }
  ],
  "ignorePatterns": ["scripts/esbuild-jest/dist/index.js"]
}

But when I do commits using that rule (or even when I run npx oxlint) oxlint does not handler of this warning and I can commit without problem:

image

➜  app git:(oxlint) ✗ git commit -m "warning import"
✔ Preparing lint-staged...
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
[oxlint e76100d66] test
 1 file changed, 2 insertions(+)

Hello, my understanding is:

  • you tell oxlint to use your config
  • in your config, you silence oxlint rules (this is what this plugin is for)

So the behavior is good: oxlint does not report anything.
You should have a separate eslint config for eslint and oxlint in this case