romeovs / react-a11y

Identifies accessibility issues in your React.js elements
MIT License
19 stars 5 forks source link

Missing dependency #2

Closed gf3 closed 8 years ago

gf3 commented 8 years ago

Getting the following error when attempting to use your version of react-a11y in my project:

WARNING in ./~/react-a11y/lib/util/test-rules.js
Critical dependencies:
28:23-69 the request of a dependency is an expression
 @ ./~/react-a11y/lib/util/test-rules.js 28:23-69

ERROR in ./~/react-a11y/lib/util/test-rules.js
Module not found: Error: Cannot resolve module 'chai' in /Users/gianni.chiappetta/Projects/uniiverse/juno/node_modules/react-a11y/lib/util
 @ ./~/react-a11y/lib/util/test-rules.js 99:12-27
webpack: bundle is now VALID.
gf3 commented 8 years ago

After installing the dependency i get the following warning:

WARNING in ./~/react-a11y/lib/util/test-rules.js
Critical dependencies:
28:23-69 the request of a dependency is an expression
 @ ./~/react-a11y/lib/util/test-rules.js 28:23-69

Which is here.

romeovs commented 8 years ago

Hi @gf3 Thanks for looking into it! I probably needed to mention that to use test-rules.js you need to install chai yourself. It is in react-a11ys devDependencies and so it's not installed automatically.

The second error is harder to fix. I need to look at the web pack config to make sure the require context is generated somehow. This should not be a problem when you are only doing server-side tests though.

gf3 commented 8 years ago

hi @romeovs i actually can't get the package to output any a11y warnings at all (no errors either). do i need to manually include all the rules i'd like to use?

romeovs commented 8 years ago

By default all the rules are turned "off" so you'd need to turn them on:

a11y(React, ReactDOM, {
    rules: {
      'img-uses-alt': 'warn'
    , 'redundant-alt': 'warn'
    // all the rules!
    }
  })
gf3 commented 8 years ago

ahh thanks! i would consider adding that to the README

romeovs commented 8 years ago

I will!

romeovs commented 8 years ago

This should be fixed with 9e43ec32. By including ./src/util/test-rules in the source tree, the error would occur even when you didn't really need test-rules. This is fixed now!