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

Add a11y configuration for eslint and storybook #1849

Merged
merged 15 commits into from
Mar 23, 2021
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"build:clean": "rimraf ./packages/**/dist",
"build:watch": "lerna run build:watch --parallel; ttsc --build",
"test": "lerna run test --stream -- --colors --maxWorkers=4",
"lint": "eslint -c .eslintrc.js packages",
"lint:fix": "eslint -c .eslintrc.js --fix packages"
"lint": "cross-env __REDWOOD__CONFIG_PATH=packages/create-redwood-app/template eslint -c .eslintrc.js packages",
"lint:fix": "cross-env __REDWOOD__CONFIG_PATH=packages/create-redwood-app/template eslint -c .eslintrc.js --fix packages"
},
"private": true,
"license": "MIT",
Expand Down
7 changes: 6 additions & 1 deletion packages/core/config/storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const fs = require('fs')
const path = require('path')
const { merge } = require('webpack-merge')
const { getPaths } = require('@redwoodjs/internal')
const { getConfig, getPaths } = require('@redwoodjs/internal')
const { getSharedPlugins } = require('../webpack.common')

const config = getConfig()

const baseConfig = {
stories: ['../../../../web/src/**/*.stories.{tsx,jsx,js}'],
addons: [
config.web.a11y && '@storybook/addon-a11y'
].filter(Boolean),
webpackFinal: (sbConfig, { configType }) => {
// configType is 'PRODUCTION' or 'DEVELOPMENT', why shout?
const isEnvProduction = configType && configType.toLowerCase() === 'production'
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@redwoodjs/eslint-config": "^0.27.1",
"@redwoodjs/internal": "^0.27.1",
"@redwoodjs/testing": "^0.27.1",
"@storybook/addon-a11y": "^6.1.19",
"@storybook/react": "^6.1.21",
"@testing-library/jest-dom": "5.11.6",
"@types/jest": "^26.0.10",
Expand Down
9 changes: 7 additions & 2 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// This is the ESLint configuation used by Redwood projects.
const { getConfig } = require('@redwoodjs/internal')

module.exports = {
extends: './shared.js',
const config = getConfig()

module.exports = {
extends: [
'./shared.js',
config.web.a11y && 'plugin:jsx-a11y/recommended',
].filter(Boolean),
plugins: ['@redwoodjs/eslint-plugin-redwood'],
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/internal/src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('getConfig', () => {
"open": false,
},
"web": Object {
"a11y": true,
"apiProxyPath": "/.netlify/functions",
"apiProxyPort": 8911,
"experimentalFastRefresh": false,
Expand Down
2 changes: 2 additions & 0 deletions packages/internal/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface BrowserTargetConfig {
apiProxyPath: string
experimentalFastRefresh?: boolean
experiemntalPrerender?: boolean
a11y: boolean
}

export interface Config {
Expand All @@ -53,6 +54,7 @@ const DEFAULT_CONFIG: Config = {
apiProxyPath: '/.netlify/functions',
apiProxyPort: 8911,
experimentalFastRefresh: false,
a11y: true,
},
api: {
host: 'localhost',
Expand Down
36 changes: 34 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,28 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@storybook/addon-a11y@^6.1.19":
version "6.1.21"
resolved "https://registry.yarnpkg.com/@storybook/addon-a11y/-/addon-a11y-6.1.21.tgz#28e44c9f3b7b9e8a319f59b112092fb9aa15fb96"
integrity sha512-FTHQ0QdPhL+0D/E/og/xkT6tIEEOSCgCV+eX9UcDn3shnxVAHEHbqJ7Yf1fF5B/nRx+ptY57c9O64vIFd7UMHg==
dependencies:
"@storybook/addons" "6.1.21"
"@storybook/api" "6.1.21"
"@storybook/channels" "6.1.21"
"@storybook/client-api" "6.1.21"
"@storybook/client-logger" "6.1.21"
"@storybook/components" "6.1.21"
"@storybook/core-events" "6.1.21"
"@storybook/theming" "6.1.21"
axe-core "^4.0.1"
core-js "^3.0.1"
global "^4.3.2"
lodash "^4.17.15"
react-sizeme "^2.5.2"
regenerator-runtime "^0.13.7"
ts-dedent "^2.0.0"
util-deprecate "^1.0.2"

"@storybook/[email protected]":
version "6.1.21"
resolved "https://registry.yarnpkg.com/@storybook/addons/-/addons-6.1.21.tgz#94bb66fc51d1dfee80d0fe84f5b83c10045651b5"
Expand Down Expand Up @@ -5257,6 +5279,11 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59"
integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==

axe-core@^4.0.1:
version "4.1.2"
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.1.2.tgz#7cf783331320098bfbef620df3b3c770147bc224"
integrity sha512-V+Nq70NxKhYt89ArVcaNL9FDryB3vQOd+BFXZIfO3RP6rwtj+2yqqqdHEkacutglPaZLkJeuXKCjCJDMGPtPqg==

axe-core@^4.0.2:
version "4.1.3"
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.1.3.tgz#64a4c85509e0991f5168340edc4bedd1ceea6966"
Expand Down Expand Up @@ -7109,11 +7136,16 @@ [email protected]:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.6.5.tgz#7395dc273af37fb2e50e9bd3d9fe841285231d1a"
integrity sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==

core-js@^3.0.1, core-js@^3.0.4, core-js@^3.2.1, core-js@^3.6.5, core-js@^3.8.0:
core-js@^3.0.1, core-js@^3.0.4, core-js@^3.2.1, core-js@^3.8.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.9.1.tgz#cec8de593db8eb2a85ffb0dbdeb312cb6e5460ae"
integrity sha512-gSjRvzkxQc1zjM/5paAmL4idJBFzuJoo+jDjF1tStYFMV2ERfD02HhahhCGXUyHxQRG4yFKVSdO6g62eoRMcDg==

core-js@^3.6.5:
version "3.9.0"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.9.0.tgz#790b1bb11553a2272b36e2625c7179db345492f8"
integrity sha512-PyFBJaLq93FlyYdsndE5VaueA9K5cNB7CGzeCj191YYLhkQM0gdZR2SKihM70oF0wdqKSKClv/tEBOpoRmdOVQ==

[email protected], core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -15656,7 +15688,7 @@ react-refresh@^0.9.0:
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf"
integrity sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ==

react-sizeme@^2.6.7:
react-sizeme@^2.5.2, react-sizeme@^2.6.7:
version "2.6.12"
resolved "https://registry.yarnpkg.com/react-sizeme/-/react-sizeme-2.6.12.tgz#ed207be5476f4a85bf364e92042520499455453e"
integrity sha512-tL4sCgfmvapYRZ1FO2VmBmjPVzzqgHA7kI8lSJ6JS6L78jXFNRdOZFpXyK6P1NBZvKPPCZxReNgzZNUajAerZw==
Expand Down