diff --git a/.eslintrc b/.eslintrc index c3f031c..1070878 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,7 +2,8 @@ "env": { "browser": true, "node": true, - "es6": true + "es6": true, + "mocha": true }, "parserOptions": { "ecmaVersion": 2017, @@ -17,6 +18,7 @@ ], "plugins": [ "babel", + "mocha", "react" ], "rules": { diff --git a/package.json b/package.json index 69d411c..f3ff001 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "eslint-plugin-babel": "^3.1.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^3.0.2", + "eslint-plugin-mocha": "^4.9.0", "eslint-plugin-react": "^6.10.3", "karma": "^0.13.22", "karma-chrome-launcher": "^0.1.7", diff --git a/src/rules/no-unsupported-elements-use-aria.js b/src/rules/no-unsupported-elements-use-aria.js index 9f90e2c..8726080 100644 --- a/src/rules/no-unsupported-elements-use-aria.js +++ b/src/rules/no-unsupported-elements-use-aria.js @@ -9,7 +9,7 @@ export default [{ msg: 'This element does not support ARIA roles, states and properties.', AX: 'AX_ARIA_12', test(tagName, props) { - const reserved = DOM[tagName].reserved || false; + const reserved = (Object.prototype.hasOwnProperty.call(DOM, tagName) && DOM[tagName].reserved) || false; const prop = hasProp(props, Object.keys(aria).concat('role')); return !reserved || !prop; @@ -30,9 +30,12 @@ export const fail = [{ }]; export const pass = [{ - when: 'the reserver element is not given an illegal prop', + when: 'the reserved element is not given an illegal prop', render: React => }, { - when: 'an illegal props is given to a non-reserved elemeent', + when: 'an illegal prop is given to a non-reserved element', render: React =>
+}, { + when: 'an illegal prop is given to an unknown element', + render: React => }]; diff --git a/src/test.js b/src/test.js index 14e151d..eba2f13 100644 --- a/src/test.js +++ b/src/test.js @@ -120,7 +120,14 @@ export default class Suite { } // perform the test - const pass = await test(tagName, props, children, ctx); + let pass; + // try/catch so that exceptions are not silently swallowed by await + try { + pass = await test(tagName, props, children, ctx); + } catch (error) { + console.log(error); + pass = false; + } if (!pass) { done({