@browserstack/accessibility-devtools-cli 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE.md +5 -0
  2. package/README.md +72 -0
  3. package/index.js +8784 -0
  4. package/package.json +20 -0
package/LICENSE.md ADDED
@@ -0,0 +1,5 @@
1
+ By using this software, you agree to BrowserStack's Terms of Service and Privacy Policy.
2
+
3
+ For more information, please visit:
4
+ [Terms of service](https://www.browserstack.com/terms)
5
+ and [Privacy Policy](https://www.browserstack.com/privacy)
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # Accessibility DevTools CLI
2
+
3
+ A command line interface to run accessibility checks on your React and HTML files.
4
+
5
+ ## Usage
6
+
7
+ ### Step 1: Installation
8
+
9
+ First, install the BrowserStack Accessibility DevTools CLI via npm
10
+
11
+ ```bash
12
+ npm install -g accessibility-devtools-cli
13
+ ```
14
+
15
+ ### Step 2: Authentication
16
+
17
+ 1. Sign up on http://browserstack.com
18
+ 2. Get your Username and Access Key by logging in to http://browserstack.com and going to Profile → Account & Profile → My Profile → Authentication & Security
19
+ 3. Set up the two environment variables BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY
20
+ a. For Zsh, add in `~/.zshrc`
21
+ b. For Bash, add in `~/.bashrc` or `~/.bash_profile`
22
+ c. For Fish Shell, add in `~/.config/fish/config.fish`
23
+
24
+ ### Step 3: Run your tests
25
+
26
+ Run the CLI on your file(s) or directory
27
+
28
+ ```bash
29
+ npx accessibility-devtools-cli --include src/**.jsx
30
+ ```
31
+
32
+ ## CLI Options
33
+
34
+ ```
35
+ --version: Show version number
36
+ --include or -i: Glob pattern(s) for files to lint
37
+ --exclude or -e: Glob pattern(s) for files to exclude from linting
38
+ --browserstack-username or -u: BrowserStack username (if not provided, taken from BROWSERSTACK_USERNAME env variable)
39
+ --browserstack-access-key or -k: BrowserStack access key (if not provided, taken from BROWSERSTACK_ACCESS_KEY env variable)
40
+ -non-strict or -n: Run in non-strict mode (only print violations, do not exit with non-success code)
41
+ --help: Show help
42
+ ```
43
+
44
+ ## Exit Codes:
45
+
46
+ <span style="color: green;">0</span> - no issues <br />
47
+ <span style="color: orange;">1</span> - open accessibility issues <br />
48
+ <span style="color: red;">2</span> - BrowserStack connection issues <br />
49
+
50
+ ## Sample pre-commit script:
51
+
52
+ ```bash
53
+ #!/usr/bin/env bash
54
+ # Identify project root
55
+ GIT_ROOT=$(git rev-parse --show-toplevel)
56
+
57
+ # Allow skipping a11y checks
58
+ if [ -n "$SKIP_A11Y_CHECKS" ]; then
59
+ echo "Skipping accessibility checks."
60
+ exit 0
61
+ fi
62
+ echo "Running accessibility checks..."
63
+ if [ -n "$NON_STRICT_A11Y_CHECKS" ]; then
64
+ # Run checks, but be lenient
65
+ npx accessibility-devtools-cli --include $GIT_ROOT/src/**.jsx --non-strict
66
+ exit 0
67
+ fi
68
+
69
+ # Run checks and don't let commit pass if exit code is !0
70
+ npx accessibility-devtools-cli --include $GIT_ROOT/src/**.jsx
71
+ exit $?
72
+ ```