fi3ework / vite-plugin-checker

💬 Vite plugin that provide checks of TypeScript, ESLint, vue-tsc, Stylelint and more.
https://vite-plugin-checker.netlify.app
MIT License
976 stars 84 forks source link

Exclude folders option #182

Open olemarius opened 1 year ago

olemarius commented 1 year ago

Is your feature request related to a problem? Please describe.

I've been trying to exclude the code generated by swagger-codegen, which generates a typescript-axios api from a .net core webapi, but it seems vite-plugin-checker includes anything that's referenced, regardless of exclude rules in tsconfig.

A way to exclude a folder, or at least exclude node_modules folder.

In vite.config.ts:

checker({
  // terminal: true,
  vueTsc: {  
    root: './src',
     tsconfigPath: './tsconfig.json',
  },
  typescript: command === 'serve' && mode !== 'test',
  eslint: {
    lintCommand: 'eslint --format=pretty . --ext .js,.ts,.vue',
  },
  overlay:{
    initialIsOpen: false,
    position: 'bl'
  }
}),

My tsconfig looks like this:

{
    "display": "Recommended",
    "$schema": "https://json.schemastore.org/tsconfig",
    "compilerOptions": {
        "forceConsistentCasingInFileNames": true,
        "importHelpers": true,
        "target": "esnext",
        "allowJs": true,
        "module": "esnext",
        "moduleResolution": "node",
        "strict": true,
        "jsx": "preserve",
        "sourceMap": true,
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "noUnusedLocals": true,
        "skipLibCheck": true,
        "lib": [
            "esnext",
            "dom"
        ],
        "types": [
            "vitest/globals",
            "vite/client",
            "@types/youtube",
            "vitest/importMeta",
            "vue/ref-macros",
            "@intlify/vite-plugin-vue-i18n/client",
            "@types/google.maps",
            "./types/External/dom-to-image-more",
            "./types/External/vue3-tabs-component"
        ],
        "plugins": [
            {
                "name": "vuedx/typescript-plugin-vue"
            }
        ],
        "baseUrl": "./",
        "paths": {
            "@/*": ["src/*"]
        },
        "typeRoots": [
            "./types",
            "./node_modules/@types"
        ]
    },
    "vueCompilerOptions": {
        "experimentalAllowTypeNarrowingInInlineHandlers": true
    },
    "include": [
        "env.d.ts",
        "components.d.ts",
        "auto-imports.d.ts",
        "src/**/*.ts",
        "src/**/*.d.ts",
        "src/**/*.vue"
    ],
    "exclude": [
        "**/node_modules",
        "**/dist",
        "cypress",
        "src/services",
    ]
}

Normally we would generate this code to /src/services/webapi/, but I've also tried publishing the api to a private npm package and install it as a dependecy, but even when in node_modules it's still flooding the terminal with errors.

ERROR(vue-tsc) image

ERROR(Typescript) image

Describe the solution you'd like

Exclude option (with glob pattern support)

checker({
    vueTsc: {
        root: './src',
        tsconfigPath: './tsconfig.json',
        // EXCLUDE OPTION 
        exclude: [
          'node_modules',
          'src/services',
        ]
    },
    typescript: {
        root: './src',
        tsconfigPath: './tsconfig.json',
       // EXCLUDE OPTION 
        exclude: [
          'node_modules',
          'src/services',
        ]
    },
    eslint: {
        lintCommand: 'eslint --format=pretty . --ext .js,.ts,.vue',
    },
    overlay:{
        initialIsOpen: false,
        position: 'bl'
    }
}),

Describe alternatives you've considered

No response

Additional context

No response

Validations

fi3ework commented 1 year ago

As vite-plugin-checker is only a binding of vue-tsc to Vite. I tested in my demo project and find in vue-tsc: ^1.0.14, exclude files in src works and skipLibCheck should also work as mentioned in https://github.com/johnsoncodehk/volar/issues/2018#issuecomment-1281802717. Any minimal re-production is welcomed.