Skip to content

Commit 65bc458

Browse files
authored
Merge pull request #23 from sparingsoftware/feat/a11y-rules
feat: Add a11y rules to configs
2 parents b7060e8 + b8bf085 commit 65bc458

File tree

8 files changed

+724
-224
lines changed

8 files changed

+724
-224
lines changed

astro.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/** @type {import("eslint").Linter.Config} */
22
module.exports = {
3-
extends: ['plugin:astro/recommended', '@sparing-software/eslint-config'],
3+
extends: [
4+
'plugin:astro/recommended',
5+
'plugin:astro/jsx-a11y-recommended',
6+
'@sparing-software/eslint-config'
7+
],
48
overrides: [
59
{
610
files: ['*.astro'],
@@ -10,7 +14,20 @@ module.exports = {
1014
extraFileExtensions: ['.astro']
1115
},
1216
rules: {
13-
// All rules: https://ota-meshi.github.io/eslint-plugin-astro/rules/
17+
// All rules: https://ota-meshi.github.io/eslint-plugin-astro/rules/,
18+
'astro/jsx-a11y/alt-text': [
19+
'error',
20+
{
21+
elements: ['img', 'object', 'area'],
22+
img: ['Image']
23+
}
24+
],
25+
'astro/jsx-a11y/img-redundant-alt': [
26+
'error',
27+
{
28+
components: ['Image']
29+
}
30+
]
1431
}
1532
}
1633
],

next.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,12 @@
11
/** @type {import("eslint").Linter.Config} */
22
const next = {
3-
extends: ['next', 'next/core-web-vitals', '@sparing-software/eslint-config'],
3+
extends: [
4+
'next/core-web-vitals',
5+
'plugin:jsx-a11y/recommended',
6+
'@sparing-software/eslint-config'
7+
],
8+
plugins: ['jsx-a11y'],
49
rules: {
5-
'import/order': [
6-
'warn',
7-
{
8-
groups: [
9-
'builtin',
10-
'external',
11-
'internal',
12-
['parent', 'sibling', 'index']
13-
],
14-
alphabetize: {
15-
order: 'asc'
16-
},
17-
pathGroups: [
18-
{
19-
pattern: '@/styles/**',
20-
group: 'internal',
21-
position: 'after'
22-
},
23-
{
24-
pattern: '@/**',
25-
group: 'internal',
26-
position: 'before'
27-
}
28-
],
29-
'newlines-between': 'always'
30-
}
31-
],
3210
'react/self-closing-comp': [
3311
'warn',
3412
{
@@ -42,7 +20,31 @@ const next = {
4220
{ props: 'never', children: 'ignore' }
4321
],
4422
'react/jsx-boolean-value': ['warn', 'never'],
45-
'react/jsx-no-leaked-render': 'error'
23+
'react/jsx-no-leaked-render': 'error',
24+
'jsx-a11y/alt-text': [
25+
'error',
26+
{
27+
img: ['Image']
28+
}
29+
],
30+
'jsx-a11y/img-redundant-alt': [
31+
'error',
32+
{
33+
components: ['Image']
34+
}
35+
],
36+
'jsx-a11y/anchor-has-content': [
37+
'error',
38+
{
39+
components: ['Link']
40+
}
41+
],
42+
'jsx-a11y/anchor-is-valid': [
43+
'error',
44+
{
45+
components: ['Link']
46+
}
47+
]
4648
}
4749
}
4850

nuxt.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@ const nuxtEslintConfig = require('@nuxt/eslint-config')
33
/** @type {import("eslint").Linter.Config} */
44
const nuxt = {
55
extends: ['@nuxt/eslint-config', '@sparing-software/eslint-config/vue'],
6-
overrides: [...nuxtEslintConfig.overrides]
6+
overrides: [...nuxtEslintConfig.overrides],
7+
rules: {
8+
'vuejs-accessibility/alt-text': [
9+
'error',
10+
{
11+
img: ['NuxtImg', 'NuxtPicture']
12+
}
13+
],
14+
'vuejs-accessibility/anchor-has-content': [
15+
'error',
16+
{
17+
components: ['RouterLink', 'NuxtLink']
18+
}
19+
]
20+
}
721
}
822

923
module.exports = nuxt

0 commit comments

Comments
 (0)