Skip to content
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

chore: integrate eslint-plugin-jsx-a11y into the existing ESLint setup #4764

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
15 changes: 12 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
},
rules: {
"linebreak-style": ["error", "unix"],
Expand All @@ -26,7 +27,15 @@ module.exports = {
},
settings: {
react: {
version: "detect"
}
}
version: "detect",
},
},
overrides: [
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: ["plugin:@typescript-eslint/recommended"],
},
],
};
29 changes: 28 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,39 @@ jobs:
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
run: yarn lint-js

lint-a11y:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
js:
- '**/*.js'
ts:
- '**/*.ts'
jsx:
- '**/*.jsx'
tsx:
- '**/*.tsx'

- name: Install JS dependencies
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
run: yarn install --immutable

- name: Lint JS for Accessibility
if: ${{ steps.filter.outputs.js == 'true' || steps.filter.outputs.ts == 'true' || steps.filter.outputs.jsx == 'true' || steps.filter.outputs.tsx == 'true' }}
run: yarn lint-a11y

test-python:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
Expand Down
30 changes: 30 additions & 0 deletions eslint-a11y.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
parser: "@babel/eslint-parser",
plugins: ["jsx-a11y"],
env: {
browser: true,
es6: true,
node: true,
},
extends: [
"plugin:jsx-a11y/recommended",
],
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
},
overrides: [
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
plugins: ["jsx-a11y"],
extends: [
"plugin:jsx-a11y/recommended",
],
},
],
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"scripts": {
"lint-js": "eslint static/js",
"lint-js": "eslint static/js --ext .js,.jsx,.ts,.tsx",
"lint-a11y": "eslint -c eslint-a11y.config.js static/js --ext .js,.jsx,.ts,.tsx",
"lint-scss": "stylelint static/**/*.scss",
"lint-python": "flake8 webapp tests && black --diff --check --line-length 79 webapp tests",
"test": "yarn run test-python && yarn run test-js-all && yarn run lint-scss",
Expand Down Expand Up @@ -110,11 +111,14 @@
"@types/d3": "7.4.3",
"@types/markdown-it": "14.1.1",
"@types/uuid": "10.0.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"babel-jest": "29.7.0",
"concurrently": "8.2.2",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "27.6.1",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.33.2",
"identity-obj-proxy": "3.0.0",
Expand Down
Loading
Loading