sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
304 stars 38 forks source link

False Positive for 'customElement: true'. #602

Closed irvingoujAtDevolution closed 1 year ago

irvingoujAtDevolution commented 1 year ago

Before You File a Bug Report Please Confirm You Have Done The Following...

What version of ESLint are you using?

8.52.0

What version of eslint-plugin-svelte are you using?

2.34.0

What did you do?

Configuration ``` module.exports = { root: true, parser: '@typescript-eslint/parser', extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'plugin:svelte/recommended'], plugins: ['@typescript-eslint'], ignorePatterns: ['*.cjs'], overrides: [ { files: ['*.svelte'], parser: 'svelte-eslint-parser', parserOptions: { parser: '@typescript-eslint/parser' } } ], parserOptions: { sourceType: 'module', ecmaVersion: 2020, project: './tsconfig.json', extraFileExtensions: ['.svelte'] }, env: { browser: true, es2017: true, node: true }, rules: { '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], '@typescript-eslint/no-explicit-any': 'off', 'no-prototype-builtins': 'off', // 'svelte/valid-compile':'off' }, settings: { svelte: { compileOptions: { customElement: true } } } }; ```
<svelte:options tag="iron-remote-gui"/>

<script lang="ts">
    import {onMount} from 'svelte';
...
</script>
...

What did you expect to happen?

I expect eslint throw no error with run npx eslint src/**

What actually happened?

> npx eslint src/**

C:\Users\jou\code\IronRDP\web-client\iron-remote-gui\src\iron-remote-gui.svelte
  1:17  error  The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?(missing-custom-element-compile-options)  svelte/valid-compile

✖ 1 problem (1 error, 0 warnings)

Link to GitHub Repo with Minimal Reproducible Example

IronRDP

inside the ./web-client/iron-remote-gui, one can try remove the

svelte/valid-compile': 'off'

to reproduce this problem

Additional comments

No response

baseballyama commented 1 year ago

This error is came from Svelte compiler, so I think this is not ESLint issue. Can you try to compile your code with Svelte compilar and share the result?

irvingoujAtDevolution commented 1 year ago

I use vite build and it works well. Everything compiles.

irvingoujAtDevolution commented 1 year ago

here is my vite config

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";
import dtsPlugin from "vite-plugin-dts";

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    lib: {
      entry: './src/main.ts',
      name: 'IronRemoteGui',
      formats: ["umd", "es"],
    }
  },
  server: {
    fs: {
      strict: false
    }
  },
  plugins: [svelte({
    compilerOptions:{
      customElement:true
    }
  }), wasm(), topLevelAwait(), dtsPlugin()],
})
baseballyama commented 1 year ago

It should be fix in 2.34.1!