eslint-config
eslint-config copied to clipboard
Typescript rules don't work in astro components
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
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guide.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- [X] 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!)