antfu / eslint-config

Anthony's ESLint config preset
https://eslint-config.antfu.me/
MIT License
3.72k stars 419 forks source link

Typescript rules don't work in astro components #546

Open soerenmartius opened 1 month ago

soerenmartius commented 1 month ago

Describe the bug

Seems like the typescript rules don't work on astro components. Activating astro with astro: true doesn't seem to parse typescript in astro --- blocks, even if typescript is explicitly enabled.

Here's my config

import antfu from '@antfu/eslint-config'
import vuea11y from 'eslint-plugin-vuejs-accessibility'
import eslintPluginReadableTailwind from 'eslint-plugin-readable-tailwind'

export default antfu(
  {
    jsx: true,
    vue: true,
    react: true,
    astro: true,
    typescript: true,
    javascript: true,
    stylistic: true,
    regexp: true,
    // TODO: REVISIT
    // typescript: {
    //   tsconfigPath: 'tsconfig.json',
    // },
    // unocss: true, # Disabled to avoid conflicts with `readable-tailwind`
    formatters: {
      css: 'prettier',
      html: 'prettier',
      markdown: 'prettier',
      astro: 'prettier',
    },
  },
  {
    plugins: {
      'readable-tailwind': eslintPluginReadableTailwind,
    },
    rules: {
      'no-console': 'warn',
      ...eslintPluginReadableTailwind.rules.error,
      'readable-tailwind/multiline': [
        'error',
        { classesPerLine: 1, group: 'newLine' },
      ],
    },
  },
  {
    files: ['**/*.tsx'],
    rules: {
      'react-hooks/exhaustive-deps': 'off', // TODO: revisit later when https://github.com/t3-oss/create-t3-turbo/issues/984 is resolved
    },
  },
  {
    files: ['**/*.vue'],
    plugins: {
      'vuejs-accessibility': vuea11y,
    },
    rules: {
      ...vuea11y.configs.recommended.rules,
      'vue/singleline-html-element-content-newline': [
        'error',
        {
          ignoreWhenNoAttributes: true,
          ignoreWhenEmpty: true,
          ignores: [
            'pre',
            'textarea',
            'a',
            'span',
          ],
        },
      ],
      'vue/max-attributes-per-line': [
        'error',
        {
          singleline: {
            max: 1,
          },
          multiline: {
            max: 1,
          },
        },
      ],
    },
  },
)

Reproduction

Activate in an astro project and try to write typescript in a astro component

System Info

System:
    OS: macOS 14.5
    CPU: (12) arm64 Apple M2 Max
    Memory: 9.34 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.2.0 - ~/.asdf/installs/nodejs/22.2.0/bin/node
    npm: 10.7.0 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 9.5.0 - ~/dev/terramate.io/terramate.io/node_modules/.bin/pnpm
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 17.5

Used Package Manager

pnpm

Validations

Contributions

pauliesnug commented 1 month ago

probably related to #525, astro <script> tags act weirdly for whatever reason, probably because of an upstream issue in astro-eslint-parser.