Files
Crussell/frontend/eslint.a11y.config.js
T

51 lines
1.5 KiB
JavaScript

import { fileURLToPath } from 'node:url';
import { includeIgnoreFile } from '@eslint/compat';
import js from '@eslint/js';
import svelte from 'eslint-plugin-svelte';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
export default defineConfig(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
{
languageOptions: {
globals: { ...globals.browser, ...globals.node }
}
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
languageOptions: {
parserOptions: {
projectService: true,
extraFileExtensions: ['.svelte'],
parser: ts.parser,
svelteConfig
}
}
},
{
name: 'svelte:a11y:rules',
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
rules: {
// Compile all .svelte files and surface compiler warnings as ESLint errors.
// The Svelte 5 compiler has built-in a11y checks (a11y_missing_attribute,
// a11y_click_events_have_key_events, a11y_no_static_element_interactions, etc.)
// that are enabled by default via accessibilityWarnings: true.
'svelte/valid-compile': 'error',
// Require explicit type attribute on <button> elements
'svelte/button-has-type': 'error',
// Require rel="noopener noreferrer" with target="_blank"
'svelte/no-target-blank': 'error'
}
}
);