Socket
Socket
Sign inDemoInstall

eslint-plugin-jsx-a11y

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jsx-a11y - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

20

lib/rules/valid-aria-role.js

@@ -23,2 +23,9 @@ /**

var report = function report(context, node) {
return context.report({
node: node,
message: errorMessage
});
};
module.exports = function (context) {

@@ -28,4 +35,2 @@ return {

var normalizedName = attribute.name.name.toUpperCase();
var normalizedType = attribute.value.type.toUpperCase();
if (normalizedName !== 'ROLE') {

@@ -35,2 +40,4 @@ return;

var normalizedType = attribute.value === null ? 'NULL' : attribute.value.type.toUpperCase();
// Only check literals, as we cannot enforce variables representing role types.

@@ -43,9 +50,10 @@ // Check expression containers to determine null or undefined values.

if (isUndefinedOrNull) {
context.report({
node: attribute,
message: errorMessage
});
report(context, attribute);
}
return;
} else if (normalizedType === 'NULL') {
// Report when <div role /> -- this assumes property truthiness, which is not a valid role.
report(context, attribute);
return;
} else if (normalizedType !== 'LITERAL') {

@@ -52,0 +60,0 @@ return;

{
"name": "eslint-plugin-jsx-a11y",
"version": "0.5.0",
"version": "0.5.1",
"description": "A static analysis linter of jsx and their accessibility with screen readers.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -79,4 +79,7 @@ <p align="center">

## Contributing
Feel free to contribute! I am currently using [Google Chrome's Audit Rules](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules) to map out as rules for this plugin.
## License
eslint-plugin-jsx-a11y is licensed under the [MIT License](LICENSE.md).

@@ -16,7 +16,10 @@ /**

const report = (context, node) => context.report({
node,
message: errorMessage
});
module.exports = context => ({
JSXAttribute: attribute => {
const normalizedName = attribute.name.name.toUpperCase();
const normalizedType = attribute.value.type.toUpperCase();
if (normalizedName !== 'ROLE') {

@@ -26,2 +29,4 @@ return;

const normalizedType = attribute.value === null ? 'NULL' : attribute.value.type.toUpperCase();
// Only check literals, as we cannot enforce variables representing role types.

@@ -34,9 +39,10 @@ // Check expression containers to determine null or undefined values.

if (isUndefinedOrNull) {
context.report({
node: attribute,
message: errorMessage
});
report(context, attribute);
}
return;
} else if (normalizedType === 'NULL') {
// Report when <div role /> -- this assumes property truthiness, which is not a valid role.
report(context, attribute);
return;
} else if (normalizedType !== 'LITERAL') {

@@ -43,0 +49,0 @@ return;

@@ -48,3 +48,4 @@ /**

{ code: '<div role={role || "button"} />', parserOptions },
{ code: '<div role={role || "foobar"} />', parserOptions }
{ code: '<div role={role || "foobar"} />', parserOptions },
{ code: '<Bar baz />', parserOptions }
].concat(basicValidityTests),

@@ -57,4 +58,5 @@ invalid: [

{ code: '<div role={undefined}></div>', errors: [ errorMessage ], parserOptions },
{ code: '<div role />', errors: [ errorMessage ], parserOptions },
{ code: '<div role={null}></div>', errors: [ errorMessage ], parserOptions }
]
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc