Set up ESLint automatically to lint Astro files with TypeScript syntax.
npx astro-eslint-setupeslint@eslint/jsfor recommended JavaScript ruleseslint-plugin-astrofor Astro syntax lintingeslint-plugin-jsx-a11yfor accessibility checkstypescript-eslintfor strict TypeScript rules and to extend Astro plugin parser for TypeScript syntax detection
import js from '@eslint/js'
import astro from 'eslint-plugin-astro'
import { defineConfig } from 'eslint/config'
import tseslint from 'typescript-eslint'
export default defineConfig([
js.configs.recommended,
tseslint.configs.strict,
astro.configs.recommended,
astro.configs['jsx-a11y-strict'],
{
files: ['**/*.astro'],
languageOptions: {
parserOptions: {
parser: tseslint.parser,
},
},
},
{
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
},
},
{
ignores: ['.astro/', 'dist/'],
},
])For more info, refer to the ESLint Plugin Astro docs
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
Sometimes you want to ignore an argument in a callback. For example:
array.filter(([_, value]) => value !== '')