gxmari007 / vite-plugin-eslint

🚨 ESLint plugin for vite
MIT License
268 stars 48 forks source link

Autofix source code option not work #13

Closed ishowman closed 2 years ago

ishowman commented 2 years ago

config and dependency

// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import eslintPlugin from "vite-plugin-eslint";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    eslintPlugin({
      fix: true,
    }),
  ],
});

package.json scripts

    "lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx --quiet --fix --ignore-path ./.gitignore",
    "lint:format": "prettier  --loglevel warn --write \"./**/*.{js,jsx,ts,tsx,css,md,json}\" ",
    "lint": "npm run lint:format && npm run lint:fix "

related npm dependencys

    "@typescript-eslint/eslint-plugin": "^4.28.2",
    "@typescript-eslint/parser": "^4.28.2",
    "eslint": "^7.30.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-simple-import-sort": "^7.0.0",
    "vite-plugin-eslint": "^1.3.0"

Eslint config:.eslintrc.js

module.exports = {
  root: true,
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: 2020,
    sourceType: "module",
    ecmaFeatures: {
      jsx: true,
    },
  },
  settings: {
    react: {
      version: "detect",
    },
  },
  env: {
    browser: true,
    amd: true,
    node: true,
  },
  extends: [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:jsx-a11y/recommended",
    "plugin:prettier/recommended", // Make sure this is always the last element in the array.
  ],
  plugins: ["simple-import-sort", "prettier"],
  rules: {
    "prettier/prettier": ["error", {}, { usePrettierrc: true }],
    "react/react-in-jsx-scope": "off",
    "jsx-a11y/accessible-emoji": "off",
    "react/prop-types": "off",
    "@typescript-eslint/explicit-function-return-type": "off",
    "simple-import-sort/imports": "error",
    "simple-import-sort/exports": "error",
    "jsx-a11y/anchor-is-valid": [
      "error",
      {
        components: ["Link"],
        specialLink: ["hrefLeft", "hrefRight"],
        aspects: ["invalidHref", "preferButton"],
      },
    ],
  },
};

Steps

Is there something wrong with my config?

gxmari007 commented 2 years ago

That's really can not fix

fh32000 commented 2 years ago

@gxmari007 @ishowman @IndexXuan @ricardogobbosouza any update

npm run dev --fix

> dev
> vite

  VITE v3.1.2  ready in 667 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://192.168.64.9:5173/

  LARAVEL v9.28.0  plugin v0.5.4

  ➜  APP_URL: http://localhost:8010
4:20:45 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue
4:20:45 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue?vue&type=style&index=0&lang.css
4:20:46 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue
4:20:46 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue?vue&type=style&index=0&lang.css
4:20:46 PM [vite] ✨ new dependencies optimized: vue
4:20:46 PM [vite] ✨ optimized dependencies changed. reloading
4:20:47 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue
4:20:47 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue?vue&type=style&index=0&lang.css
4:20:47 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue
4:20:47 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue?vue&type=style&index=0&lang.css
4:20:56 PM [vite] hmr update /resources/js/components/SectionContentComponent.vue
4:20:56 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue
4:20:56 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue?vue&type=style&index=0&lang.css
4:29:55 PM [vite] vite.config.js changed, restarting server...
4:29:56 PM [vite] server restarted.

  LARAVEL v9.28.0  plugin v0.5.4

  ➜  APP_URL: http://localhost:8010
4:29:58 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue
4:29:58 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue
4:29:59 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue?vue&type=style&index=0&lang.css
4:29:59 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue?vue&type=style&index=0&lang.css
4:30:04 PM [vite] vite.config.js changed, restarting server...
4:30:04 PM [vite] server restarted.

  LARAVEL v9.28.0  plugin v0.5.4

  ➜  APP_URL: http://localhost:8010
4:30:06 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue
4:30:06 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue
4:30:06 PM [vite] warning: 
/var/www/html/resources/js/components/MenuComponent.vue
  29:13  warning  Prop "sections" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/MenuComponent.vue?vue&type=style&index=0&lang.css
4:30:06 PM [vite] warning: 
/var/www/html/resources/js/components/SectionContentComponent.vue
  26:9  warning  Prop 'section' requires default value to be set  vue/require-default-prop

✖ 1 problem (0 errors, 1 warning)

  Plugin: vite-plugin-eslint
  File: /var/www/html/resources/js/components/SectionContentComponent.vue?vue&type=style&index=0&lang.css