Skip to content

Commit

Permalink
feat(jest): add jest accessibility matcher (#9)
Browse files Browse the repository at this point in the history
* feat(jest): add basic scaffolding for jest integration
* feat(jest): add scaffolding for jest expect matcher
* feat(jest): add toBeAccessibleWith jest a11y matcher for use with config
* feat(test-utils): add a test utilities package
* improvement: fix/silence lint warnings, improve docs
* improvement(jest): add ability to check HTML elements for accessibility
* improvement(jest): fix return types on the matcher interface
* improvement(root): add typescript resolver eslint import plugin
* improvement(root): fix conflicting settings for md files formatting
* improvement(root): fix project references in typescript configs
* refactor(jest): add util func to register a11y matchers
* refactor(jest): move fix a11y config to be a func
* refactor(test-utils): refactor packages to use the common code
* test(jest): add integration test package to test jest config setup
* test(jest): add test for a11y matcher setup; fix import
* test(jest): fix dom lang setup, test names, err msgs
* test(rules,format): fix test names to follow convention
* build: add git pre push hook to build, test
* build: add ts-cleaner to clean dist files
* build(root): add eslint plugin to check code snippets in markdown files
* build(root): add eslint plugins to check imports, comment directives
* build(root): add eslint watcher package and watch scripts
* build(root): add markdown link checker dep, scripts, config
* build(root): add plugin to generate table of contents for markdown files
* build(root): check staged files before invoking commit process
* build(root): update repository urls in package json files
* build(root): update script to upgrade dependencies; upgrade dependencies
* chore(root): update dependencies
* ci: add pr title github action, change code cov github action
* docs: add SPDX license ID at top of license file
* docs: add/refactor docs
* docs(root): add homepage fields in package json to point to readme
* docs(root): add quick start section to contributing doc
* docs(root): update table of contents for all markdown docs
  • Loading branch information
Mohan Raj Rajamanickam committed May 13, 2020
1 parent 1294f76 commit fd586d1
Show file tree
Hide file tree
Showing 56 changed files with 4,083 additions and 1,124 deletions.
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/lcov-reporter-action@v0.2.17
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/coverage-monitor-action@1.1.0
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/pull-request-name-linter-action@v0.1.2
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 git@github.com: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

0 comments on commit fd586d1

Please sign in to comment.