Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .c8rc.json

This file was deleted.

7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

include:
- executeLint: true
node: 20
node: lts/*
os: ubuntu-latest
fail-fast: false

Expand All @@ -44,11 +44,6 @@ jobs:
node-version: ${{ matrix.node }}
cache: yarn

# - name: Install ESLint ${{ matrix.eslint }}
# if: ${{ matrix.eslint != 9 }}
# run: |
# yarn add -D eslint@${{ matrix.eslint }} eslint-plugin-unicorn@56

- name: Install Dependencies
run: yarn --immutable

Expand Down
37 changes: 14 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
<p align="center">
<a href="https://github.com/es-tooling/eslint-plugin-jsx-a11y-x/actions">
<img src="https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-tooling/eslint-plugin-jsx-a11y-x"
alt="CI status" />
</a>
<a href="https://npmjs.org/package/eslint-plugin-jsx-a11y">
<img src="https://img.shields.io/npm/v/eslint-plugin-jsx-a11y.svg"
alt="npm version">
</a>
<a href="https://github.com/es-tooling/eslint-plugin-jsx-a11y-x/blob/HEAD/LICENSE.md">
<img src="https://img.shields.io/npm/l/eslint-plugin-jsx-a11y.svg"
alt="license">
</a>
<a href='https://coveralls.io/github/es-tooling/eslint-plugin-jsx-a11y-x?branch=master'>
<img src='https://coveralls.io/repos/github/es-tooling/eslint-plugin-jsx-a11y-x/badge.svg?branch=master' alt='Coverage Status' />
</a>
<a href='https://npmjs.org/package/eslint-plugin-jsx-a11y'>
<img src='https://img.shields.io/npm/dt/eslint-plugin-jsx-a11y.svg'
alt='Total npm downloads' />
</a>
</p>
# eslint-plugin-jsx-a11y-x

<a href='https://tidelift.com/lifter/search/npm/eslint-plugin-jsx-a11y-x'>Get professional support for eslint-plugin-jsx-a11y-x on Tidelift</a>
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/es-tooling/eslint-plugin-jsx-a11y-x/ci.yml?branch=main)](https://github.com/es-tooling/eslint-plugin-jsx-a11y-x/actions/workflows/ci.yml?query=branch%3Amain)
[![Codecov](https://img.shields.io/codecov/c/github/es-tooling/eslint-plugin-jsx-a11y-x.svg)](https://codecov.io/gh/es-tooling/eslint-plugin-jsx-a11y-x)
[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Fes-tooling%2Feslint-plugin-jsx-a11y-x%2Fmain%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
[![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/es-tooling/eslint-plugin-jsx-a11y-x)](https://coderabbit.ai)
[![npm](https://img.shields.io/npm/v/eslint-plugin-jsx-a11y-x.svg)](https://www.npmjs.com/package/eslint-plugin-jsx-a11y-x)
[![GitHub Release](https://img.shields.io/github/release/es-tooling/eslint-plugin-jsx-a11y-x)](https://github.com/es-tooling/eslint-plugin-jsx-a11y-x/releases)

# eslint-plugin-jsx-a11y-x
[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)

Static AST checker for accessibility rules on JSX elements.

<a href='https://tidelift.com/lifter/search/npm/eslint-plugin-jsx-a11y-x'>Get professional support for eslint-plugin-jsx-a11y-x on Tidelift</a>

## Why?

This plugin does a static evaluation of the JSX to spot accessibility issues in React apps. Because it only catches errors in static code, use it in combination with [@axe-core/react](https://github.com/dequelabs/axe-core-npm/tree/develop/packages/react) to test the accessibility of the rendered DOM. Consider these tools just as one step of a larger a11y testing process and always test your apps with assistive technology.
Expand Down
34 changes: 8 additions & 26 deletions __tests__/index-test.js → __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,39 @@

import fs from 'fs';
import path from 'path';
import test from 'tape';

import plugin from '../src';

const rules = fs
.readdirSync(path.resolve(__dirname, '../src/rules/'))
.map(f => path.basename(f, '.js'));

test('all rule files should be exported by the plugin', t => {
test('all rule files should be exported by the plugin', () => {
rules.forEach(ruleName => {
t.equal(
plugin.rules[ruleName],
expect(plugin.rules[ruleName]).toBe(
require(path.join('../src/rules', ruleName)),
`exports ${ruleName}`,
);
});

t.end();
});

test('configurations', t => {
t.notEqual(
plugin.configs.recommended,
undefined,
"exports a 'recommended' configuration",
);

t.end();
test('configurations', () => {
expect(plugin.configs.recommended).not.toBe(undefined);
});

test('schemas', t => {
test('schemas', () => {
rules.forEach(ruleName => {
const rule = require(path.join('../src/rules', ruleName));
const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
const { type } = schema;

t.equal(type, 'object', `${ruleName} exports a schema with type object`);
expect(type).toBe('object');
});

t.end();
});

test('plugin referentially equal to prevent flat config issues', t => {
test('plugin referentially equal to prevent flat config issues', () => {
const keys = Object.keys(plugin.flatConfigs);
for (let i = 0; i < keys.length; i += 1) {
const config = plugin.flatConfigs[keys[i]];
t.equal(
plugin,
config.plugins['jsx-a11y-x'],
`${config.name}'s plugin reference is referentially equal to the top-level export`,
);
expect(plugin).toBe(config.plugins['jsx-a11y-x']);
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import { aria } from 'aria-query';
import { RuleTester } from 'eslint';
import test from 'tape';

import parserOptionsMapper from '../../__util__/parserOptionsMapper';
import parsers from '../../__util__/helpers/parsers';
Expand Down Expand Up @@ -57,14 +56,8 @@ tokens from the following: ${permittedValues}.`,
}
};

test('validityCheck', t => {
t.equal(
validityCheck(null, null),
false,
'is false for an unknown expected type',
);

t.end();
test('validityCheck', () => {
expect(validityCheck(null, null)).toBe(false);
});

ruleTester.run('aria-proptypes', rule, {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
import test from 'tape';

import attributesComparator from '../../../src/util/attributesComparator';
import JSXAttributeMock from '../../../__mocks__/JSXAttributeMock';
import JSXElementMock from '../../../__mocks__/JSXElementMock';

test('attributesComparator', t => {
t.equal(
attributesComparator(),
true,
'baseAttributes are undefined and attributes are undefined -> true',
);
test('attributesComparator', () => {
expect(attributesComparator()).toBe(true);

t.equal(
attributesComparator([], []),
true,
'baseAttributes are empty and attributes are empty -> true',
);
expect(attributesComparator([], [])).toBe(true);

t.equal(
expect(
attributesComparator(
[],
[JSXAttributeMock('foo', 0), JSXAttributeMock('bar', 'baz')],
),
true,
'baseAttributes are empty and attributes have values -> true',
);
).toBe(true);

const baseAttributes = [
{
Expand All @@ -41,53 +29,39 @@ test('attributesComparator', t => {
},
];

t.equal(
attributesComparator(baseAttributes, []),
false,
'baseAttributes have values and attributes are empty -> false',
);
expect(attributesComparator(baseAttributes, [])).toBe(false);

t.equal(
expect(
attributesComparator(baseAttributes, [
JSXElementMock(),
JSXAttributeMock('biz', 2),
JSXAttributeMock('ziff', 'opo'),
JSXAttributeMock('far', 'lolz'),
]),
false,
'baseAttributes have values and attributes have values, and the values are different -> false',
);
).toBe(false);

t.equal(
expect(
attributesComparator(baseAttributes, [
JSXAttributeMock('biz', 1),
JSXAttributeMock('fizz', 'pop'),
JSXAttributeMock('goo', 'gazz'),
]),
false,
'baseAttributes have values and attributes have values, and the values are a subset -> false',
);
).toBe(false);

t.equal(
expect(
attributesComparator(baseAttributes, [
JSXAttributeMock('biz', 1),
JSXAttributeMock('fizz', 'pop'),
JSXAttributeMock('fuzz', 'lolz'),
]),
true,
'baseAttributes have values and attributes have values, and the values are the same -> true',
);
).toBe(true);

t.equal(
expect(
attributesComparator(baseAttributes, [
JSXAttributeMock('biz', 1),
JSXAttributeMock('fizz', 'pop'),
JSXAttributeMock('fuzz', 'lolz'),
JSXAttributeMock('dar', 'tee'),
]),
true,
'baseAttributes have values and attributes have values, and the values are a superset -> true',
);

t.end();
).toBe(true);
});
Loading