Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript rules don't work in astro components #546

Open
5 of 7 tasks
soerenmartius opened this issue Jul 17, 2024 · 1 comment
Open
5 of 7 tasks

Typescript rules don't work in astro components #546

soerenmartius opened this issue Jul 17, 2024 · 1 comment
Labels

Comments

@soerenmartius
Copy link

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

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
@antfu antfu added the astro label Jul 17, 2024
@pauliesnug
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants