Skip to content

Create accessibility config #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 10, 2023
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
2 changes: 1 addition & 1 deletion example-app/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"extends": "plugin:@bam.tech/recommended",
"extends": ["plugin:@bam.tech/recommended", "plugin:@bam.tech/a11y"],
"overrides": [
{
"files": ["*.test.tsx"],
Expand Down
1 change: 1 addition & 0 deletions example-app/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
15 changes: 15 additions & 0 deletions example-app/eslint-breaking-examples/break-react-native-a11y.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Save without formatting: [⌘ + K] > [S]

// This should trigger one error breaking eslint-plugin-react-native:
// react-native-a11y/has-valid-accessibility-descriptors

import { Pressable, Text } from "react-native";

export const MyCustomButton = () => {
return (
<Pressable>
<Text>Click here!</Text>
<Text>Here is a short summary</Text>
</Pressable>
);
};
16 changes: 9 additions & 7 deletions example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@
"scripts": {
"start": "node .",
"lint": "eslint .",
"types":"tsc --noEmit"
"types": "tsc --noEmit"
},
"devDependencies": {
"@bam.tech/eslint-plugin": "*",
"@bam.tech/typescript-config": "*",
"@types/jest": "^29.5.2",
"@types/react": "^18.2.14",
"@bam.tech/typescript-config": "*",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"eslint": "^8.32.0",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"eslint": "^8.44.0",
"eslint-plugin-jest": "^27.2.2",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.1",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.0.0",
"eslint-plugin-react-native-a11y": "^3.3.0",
"eslint-plugin-testing-library": "^5.11.0",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"typescript": "^4.9.4"
},
"private": "true",
"dependencies": {
"expo": "^47.0.13",
"react": "^18.2.0",
"react-native": "^0.72.0",
"expo": "^47.0.13"
"react-native": "^0.72.0"
}
}
13 changes: 7 additions & 6 deletions packages/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This project is an ESLint plugin that gathers all the rules, plugins and parsers
Install the plugin and its peer dependencies:

```bash
yarn add --dev @bam.tech/eslint-plugin
npx install-peerdeps --dev @bam.tech/eslint-plugin
yarn add @bam.tech/eslint-plugin --dev
npx install-peerdeps @bam.tech/eslint-plugin --dev --yarn
```

Then update your `.eslintrc` config file:
Expand All @@ -30,10 +30,11 @@ Then update your `.eslintrc` config file:

This plugin exports multiple configurations that can be used in your `.eslintrc` config file:

| Name | Description |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `@bam.tech/recommended` | The recommended config for all projects |
| `@bam.tech/tests` | The recommended config for test files. By default this applies to every file: put it in an `overrides` to filter on your test files. |
| Name | Description |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `@bam.tech/recommended` | The recommended config for all projects |
| `@bam.tech/tests` | The recommended config for test files. By default this applies to every file: put it in an `overrides` to filter on your test files. |
| `@bam.tech/a11y` | [beta] Eslint config to check for accessibility. Still in beta to not break existing projects, but will be merged into the recommended config in the future. |

These configs need some peer dependencies. You can list them with:

Expand Down
11 changes: 11 additions & 0 deletions packages/eslint-plugin/lib/configs/a11y.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check
"use strict";

const { defineConfig } = require("eslint-define-config");

module.exports = defineConfig({
extends: ["plugin:react-native-a11y/all"],
rules: {
"react-native-a11y/has-accessibility-hint": "off",
},
});
1 change: 0 additions & 1 deletion packages/eslint-plugin/lib/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module.exports = defineConfig({
"@typescript-eslint/no-unused-vars": "error",
"no-console": ["error", { allow: ["warn", "error"] }],
"no-return-await": "error",
"prettier/prettier": ["error", { printWidth: 80 }],
"react-hooks/exhaustive-deps": "error",
"react-native/no-color-literals": "off",
"react-native/no-raw-text": ["error", { skip: ["Trans"] }],
Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-plugin/lib/configs/tests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// @ts-check
"use strict";

const { defineConfig } = require("eslint-define-config");

module.exports = defineConfig({
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.0.0",
"eslint-plugin-react-native-a11y": "^3.3.0",
"eslint-plugin-testing-library": "^5.11.0",
"prettier": "^2.8.8"
},
Expand Down
Loading