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

feat(jest): add jest accessibility matcher #9

Merged
merged 61 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d9f0b26
build(root): update repository urls in package json files
Apr 9, 2020
7a41187
test(rules,format): fix test names to follow convention
Apr 9, 2020
483291c
feat(jest): add basic scaffolding for jest integration
Apr 9, 2020
4eaaf65
build(root): fix lint:fix script
Apr 13, 2020
6630be3
build(jest): add jest as a peer dependency
Apr 14, 2020
a91a3e0
docs(root): add homepage fields in package json to point to readme
Apr 14, 2020
51ec35d
feat(jest): add scaffolding for jest expect matcher
Apr 14, 2020
e8055fa
improvement(jest): flesh out custom jest axe matcher
Apr 23, 2020
54be107
build(jest): add jest matcher utils dep
Apr 23, 2020
7609b7b
build(root): add npm update checker util
Apr 23, 2020
6c7e86d
build(root): update script to upgrade dependencies; upgrade dependencies
Apr 23, 2020
f8649b2
improvement(jest): use matcher hint util to format message
Apr 24, 2020
b5bee0f
build(root): check staged files before invoking commit process
Apr 24, 2020
c7184e4
test(jest): fix dom lang setup, test names, err msgs
Apr 27, 2020
1554fdf
build(root): add eslint watcher package and watch scripts
Apr 27, 2020
ecbfbf9
feat(jest): add toBeAccessibleWith jest a11y matcher for use with config
Apr 28, 2020
2a1c1bf
feat(test-utils): add a test utilities package
Apr 28, 2020
ba71b58
refactor(test-utils): refactor packages to use the common code
Apr 28, 2020
2481a06
build(root): add markdown link checker dep, scripts, config
Apr 29, 2020
37f5f8f
build(root): add eslint plugin to check code snippets in markdown files
Apr 29, 2020
28e628f
improvement(jest): fix return types on the matcher interface
Apr 29, 2020
3531458
build(root): upgrade to next version of eslint markdown plugin
Apr 29, 2020
3dbd29a
docs(root): add typescript tag to code blocks in docs
Apr 29, 2020
342f577
build(root): update dependencies
Apr 29, 2020
a88ef4d
build(root): add plugin to generate table of contents for markdown files
Apr 29, 2020
a832256
docs(root): update table of contents for all markdown docs
Apr 29, 2020
97677cb
build(root): add eslint plugins to check imports, comment directives
Apr 29, 2020
23d4c4c
improvement(root): fix conflicting settings for md files formatting
Apr 29, 2020
f54b9ac
improvement(root): add typescript resolver eslint import plugin
Apr 30, 2020
eafdc8c
chore(root): update dependencies
Apr 30, 2020
ca3d7a3
refactor(jest): rename jest module to matcher
Apr 30, 2020
618868c
improvement(root): fix project references in typescript configs
Apr 30, 2020
2546f72
refactor(jest): add util func to register a11y matchers
Apr 30, 2020
7466a6f
test(jest): add test for a11y matcher setup; fix import
Apr 30, 2020
9e56fb0
refactor(jest): move fix a11y config to be a func
Apr 30, 2020
e415437
refactor(jest): consolidate before test setup
Apr 30, 2020
e1e271a
improvement(jest): call fix config from the jest matcher
May 1, 2020
8ca12bf
improvement(jest): make fix a11y config immutable
May 1, 2020
c4a4b8a
build(root): fix missing deps, build clean script
May 1, 2020
4054e00
docs(root): add quick start section to contributing doc
May 1, 2020
4a16474
chore(root): bump versions of changed packages
May 1, 2020
8fc2fa6
build: add git pre push hook to build, test
May 1, 2020
9ad3ee0
fix(preset-rules): revert object freeze on a11y config object
May 1, 2020
6e3ee18
improvement: fix/silence lint warnings, improve docs
May 1, 2020
2f9f9b3
docs: add SPDX license ID at top of license file
May 1, 2020
dbc80f1
refactor(jest): rename fix a11y config func to adapt a11y config
May 4, 2020
349a426
test(jest): add test to check for error when expect is undefined
May 4, 2020
2b64f15
refactor(jest): remove toBeAccessibleWith a11y matcher
May 4, 2020
c77f356
ci: add pr title github action, change code cov github action
May 4, 2020
2b18c4b
improvement(jest): add config to automate setup of a11y matchers
May 4, 2020
56b4893
ci: add missing build step to new github actions
May 4, 2020
3889075
ci(github action): change pr title check to install only req deps
May 4, 2020
eca6850
refactor(jest): remove adaptA11yConfig from package level direct export
May 5, 2020
6eb2a3b
improvement(jest): add ability to check HTML elements for accessibility
May 5, 2020
85609d3
build(jest): fix main entry point in jest package.json
May 5, 2020
36b0087
build: add ts-cleaner to clean dist files
May 7, 2020
cbbe288
test(jest): add integration test package to test jest config setup
May 7, 2020
a6662f6
refactor(test-integration): rename test-integ to test-integration
May 7, 2020
e4c2717
docs: add/refactor docs
May 7, 2020
97249c9
docs: change code block types in docs from ts to js
May 7, 2020
9b1aa3b
test(jest): add doc/tests for checking html elem with jest
May 8, 2020
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
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
'jest',
'prettier',
'notice', // checks for and fixes copyright header in each file
'markdown',
],
extends: [
'eslint:recommended',
Expand All @@ -24,7 +25,19 @@ module.exports = {
'plugin:jest/style',
'plugin:prettier/recommended',
'prettier/@typescript-eslint',
'plugin:import/typescript',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:eslint-comments/recommended',
],
settings: {
'import/resolver': {
// Makes plugin:import work with Typescript interfaces etc
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code
},
},
},
rules: {
'notice/notice': [
'error',
Expand All @@ -34,6 +47,13 @@ module.exports = {
],
'tsdoc/syntax': 'warn',
},
overrides: [
{
// Enable the Markdown processor for all .md files.
files: ['**/*.md'],
processor: 'markdown/markdown',
},
],
env: {
browser: true,
node: true,
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
yarn.lock linguist-generated=true
# generated JS files
dist/* linguist-generated=true
# jest snapshots
*.test.ts.snap linguist-generated=true
14 changes: 5 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# This workflow will do a clean install of node dependencies, build the source code and run tests
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: CI
name: Lint, Test

on:
push:
Expand All @@ -18,10 +18,6 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: yarn ci
- name: Code Coverage Report
uses: romeovs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./coverage/lcov.info

- run: |
yarn ci:build
yarn ci:test
29 changes: 29 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Code coverage

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']

jobs:
codecov:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'

- name: Collect Code Coverage
run: |
yarn ci:build
yarn test

- name: Code Coverage Report
uses: slavcodev/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clover_file: './coverage/clover.xml'
# replace mode removes existing comment and adds a new one at the end
# update mode tries to find existing code cov comment and update it.
comment_mode: 'update'
17 changes: 17 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: PR Title Linter

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install Dependencies
run: npm install @commitlint/config-conventional
- uses: JulienKode/[email protected]
4 changes: 4 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"upgrade": true,
"reject": ["@types/node"]
}
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ module.exports = {
printWidth: 120,
singleQuote: true,
trailingComma: 'es5',
overrides: [
{
files: '*.md',
tabWidth: 2, // To accommodate doctoc formatting (no override for tab width in doctoc)
},
],
};
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [(2020-05-07)](#2020-05-07)
- [Bug Fixes](#bug-fixes)
- [Features](#features)
- [(2020-04-07)](#2020-04-07)
- [Bug Fixes](#bug-fixes-1)
- [Features](#features-1)
- [(2020-03-20)](#2020-03-20)
- [Bug Fixes](#bug-fixes-2)
- [Features](#features-2)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# (2020-05-07)

### Bug Fixes

- **preset-rules:** revert object freeze on a11y config object ([9ad3ee0](https://github.com/salesforce/sa11y/commit/9ad3ee084c31e4bff75b2935052764f52fa15897))

### Features

- **assert:** add assert accessible api ([#7](https://github.com/salesforce/sa11y/issues/7)) ([1294f76](https://github.com/salesforce/sa11y/commit/1294f76a153024045e66d7949b91becf44493e4b))
- **jest:** add basic scaffolding for jest integration ([483291c](https://github.com/salesforce/sa11y/commit/483291cc5b25a194f232e817b66f0c032d013891))
- **jest:** add scaffolding for jest expect matcher ([51ec35d](https://github.com/salesforce/sa11y/commit/51ec35dd1867bf2467cf1fe5f3ffbb8adc880e7c))
- **jest:** add toBeAccessibleWith jest a11y matcher for use with config ([ecbfbf9](https://github.com/salesforce/sa11y/commit/ecbfbf9f1a5c8e148be3e0d3b7c523ac192e46df))
- **test-utils:** add a test utilities package ([2a1c1bf](https://github.com/salesforce/sa11y/commit/2a1c1bfe392be706af3fd2e2d7dd53cbf6e5d2b9))

# (2020-04-07)

### Bug Fixes
Expand Down
44 changes: 29 additions & 15 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Salesforce Open Source Community Code of Conduct

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [About the Code of Conduct](#about-the-code-of-conduct)
- [Our Pledge](#our-pledge)
- [Our Standards](#our-standards)
- [Our Responsibilities](#our-responsibilities)
- [Scope](#scope)
- [Enforcement](#enforcement)
- [Attribution](#attribution)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## About the Code of Conduct

Equality is a core value at Salesforce. We believe a diverse and inclusive
Expand Down Expand Up @@ -35,23 +49,23 @@ socioeconomic status, or other similar personal characteristics.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy toward other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy toward other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Personal attacks, insulting/derogatory comments, or trolling
* Public or private harassment
* Publishing, or threatening to publish, others' private information—such as
a physical or electronic address—without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
* Advocating for or encouraging any of the above behaviors
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Personal attacks, insulting/derogatory comments, or trolling
- Public or private harassment
- Publishing, or threatening to publish, others' private information—such as
a physical or electronic address—without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
- Advocating for or encouraging any of the above behaviors

## Our Responsibilities

Expand Down Expand Up @@ -98,7 +112,7 @@ It includes adaptions and additions from [Go Community Code of Conduct][golang-c

This Code of Conduct is licensed under the [Creative Commons Attribution 3.0 License][cc-by-3-us].

[contributor-covenant-home]: https://www.contributor-covenant.org (https://www.contributor-covenant.org/)
[contributor-covenant-home]: https://www.contributor-covenant.org 'https://www.contributor-covenant.org/'
[golang-coc]: https://golang.org/conduct
[cncf-coc]: https://github.com/cncf/foundation/blob/master/code-of-conduct.md
[microsoft-coc]: https://opensource.microsoft.com/codeofconduct/
Expand Down
90 changes: 56 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,59 @@

We want to encourage the developer community to contribute to Sa11y. This guide has instructions to install, build, test and contribute to the framework. Adapted from [salesforce/lwc](https://github.com/salesforce/lwc/blob/master/CONTRIBUTING.md)

- [Contributing Guidelines](#contributing-guidelines)
- [Requirements](#requirements)
- [Installation](#installation)
- [1) Download the repository](#1-download-the-repository)
- [2) Install Dependencies](#2-install-dependencies)
- [Building](#building)
- [Testing](#testing)
- [Unit Testing](#unit-testing)
- [Integration Testing](#integration-testing)
- [Editor Configurations](#editor-configurations)
- [Types](#types)
- [ESLint](#eslint)
- [Git Workflow](#git-workflow)
- [Fork the repo](#fork-the-repo)
- [Create a feature branch](#create-a-feature-branch)
- [Make your changes](#make-your-changes)
- [Rebase](#rebase)
- [Check your submission](#check-your-submission)
- [Lint your changes](#lint-your-changes)
- [Run tests](#run-tests)
- [Create a pull request](#create-a-pull-request)
- [Pull Request Title](#pull-request-title)
- [Update the pull request](#update-the-pull-request)
- [Commit Message Conventions](#commit-message-conventions)
- [Commit Message Format](#commit-message-format)
- [Reverting a commit](#reverting-a-commit)
- [Commit Type](#commit-type)
- [Commit Scope](#commit-scope)
- [Commit Subject](#commit-subject)
- [Commit Body](#commit-body)
- [Commit Footer](#commit-footer)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Quick start](#quick-start)
- [Requirements](#requirements)
- [Installation](#installation)
- [1) Download the repository](#1-download-the-repository)
- [2) Install Dependencies](#2-install-dependencies)
- [Building](#building)
- [Testing](#testing)
- [Unit Testing](#unit-testing)
- [Integration Testing](#integration-testing)
- [Editor Configurations](#editor-configurations)
- [Types](#types)
- [ESLint](#eslint)
- [Git Workflow](#git-workflow)
- [Fork the repo](#fork-the-repo)
- [Create a feature branch](#create-a-feature-branch)
- [Make your changes](#make-your-changes)
- [Rebase](#rebase)
- [Check your submission](#check-your-submission)
- [Lint your changes](#lint-your-changes)
- [Run tests](#run-tests)
- [Create a pull request](#create-a-pull-request)
- [Pull Request Title](#pull-request-title)
- [Update the pull request](#update-the-pull-request)
- [Commit Message Conventions](#commit-message-conventions)
- [Commit Message Format](#commit-message-format)
- [Reverting a commit](#reverting-a-commit)
- [Commit Type](#commit-type)
- [Commit Scope](#commit-scope)
- [Commit Subject](#commit-subject)
- [Commit Body](#commit-body)
- [Commit Footer](#commit-footer)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Before you start, it helps to be familiar with [Web Accessibility](https://trailhead.salesforce.com/en/content/learn/trails/get-started-with-web-accessibility)

## Quick start

1. `yarn install` to install dependencies
2. Make changes while building, testing and linting the changed files

- `yarn build:watch`
- `yarn test:watch`
- `yarn lint:watch`

3. Update changelog with `yarn changelog`
4. Stage changes in git and do `yarn commit` to check staged changes and commit them with a formatted commit message
5. Push changes to feature branch

## Requirements

- [Node](https://nodejs.org/) >= 12
Expand All @@ -53,7 +72,7 @@ git clone [email protected]:salesforce/sa11y.git

### 2) Install Dependencies

_We use [yarn](https://yarnpkg.com/) because it is significantly faster than npm for our use case. See this command [cheatsheet](https://yarnpkg.com/lang/en/docs/migrating-from-npm/)._
_We use [yarn](https://yarnpkg.com/) because it is significantly faster than npm for our use case. See this command [cheat-sheet](https://yarnpkg.com/lang/en/docs/migrating-from-npm/)._

```bash
yarn install
Expand All @@ -63,8 +82,11 @@ If this fails with an error about _UNABLE_TO_GET_ISSUER_CERT_LOCALLY_, _Error: u

## Building

When developing typescript compiler can be invoked using the `build` target.
With `:watch` the compiler would watch for changes and incrementally compile changed sources as required.

```bash
yarn build
yarn build[:watch]
```

## Testing
Expand All @@ -80,7 +102,7 @@ yarn test
Additionally, the testing can be started in 'watch' mode which allows for automatic test re-runs on save:

```bash
yarn test --watch
yarn test:watch
```

To execute a particular test, use the following command:
Expand Down
26 changes: 21 additions & 5 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
BSD 3-Clause License

Copyright (c) 2020, Salesforce.com, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
* Neither the name of Salesforce.com nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading