Socket
Socket
Sign inDemoInstall

eslint-plugin-jsx-a11y

Package Overview
Dependencies
0
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.2 to 0.4.3

53

lib/util/getAttributeValue.js

@@ -13,2 +13,32 @@ 'use strict';

var getValue = function getValue(value) {
if (value.type === 'Literal') {
return value.value === "" ? undefined : value.value;
} else if (value.type === 'Identifier') {
return value.name === "" ? undefined : value.name;
} else if (value.type === 'JSXExpressionContainer') {
var expression = value.expression;
switch (expression.type) {
case 'Literal':
return expression.value === "" ? undefined : expression.value;
case 'TemplateLiteral':
return (0, _buildTemplateLiteral2.default)(expression);
case 'Identifier':
return expression.name == 'undefined' ? undefined : expression.name;
case 'ArrowFunctionExpression':
case 'FunctionExpression':
return function () {
return void 0;
};
case 'LogicalExpression':
return getValue(expression.left) && getValue(expression.right);
default:
return undefined;
}
}
return undefined;
};
/**

@@ -26,24 +56,3 @@ * Returns the value of a given attribute.

} else if (attribute.type === 'JSXAttribute') {
if (attribute.value.type === 'Literal') {
return attribute.value.value === "" ? undefined : attribute.value.value;
} else if (attribute.value.type === 'JSXExpressionContainer') {
var expression = attribute.value.expression;
switch (expression.type) {
case 'Literal':
return expression.value === "" ? undefined : expression.value;
case 'TemplateLiteral':
return (0, _buildTemplateLiteral2.default)(expression);
case 'Identifier':
return expression.name == 'undefined' ? undefined : expression.name;
case 'ArrowFunctionExpression':
case 'FunctionExpression':
return function () {
return void 0;
};
default:
return undefined;
}
}
return getValue(attribute.value);
}

@@ -50,0 +59,0 @@

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

@@ -30,6 +30,6 @@ "keywords": [

"babel-core": "^6.6.0",
"babel-eslint": "^5.0.0",
"babel-eslint": "^6.0.0",
"babel-preset-es2015": "^6.6.0",
"coveralls": "^2.11.8",
"eslint": "2.2.x",
"eslint": "^2.2.0",
"istanbul": "^1.0.0-alpha.2",

@@ -36,0 +36,0 @@ "mocha": "^2.4.5",

@@ -5,2 +5,30 @@ 'use strict';

const getValue = value => {
if (value.type === 'Literal') {
return value.value === "" ? undefined : value.value;
} else if (value.type === 'Identifier') {
return value.name === "" ? undefined : value.name;
} else if (value.type === 'JSXExpressionContainer') {
const expression = value.expression;
switch (expression.type) {
case 'Literal':
return expression.value === "" ? undefined : expression.value;
case 'TemplateLiteral':
return buildTemplateLiteral(expression);
case 'Identifier':
return expression.name == 'undefined' ? undefined : expression.name;
case 'ArrowFunctionExpression':
case 'FunctionExpression':
return () => void 0;
case 'LogicalExpression':
return getValue(expression.left) && getValue(expression.right);
default:
return undefined;
}
}
return undefined;
};
/**

@@ -18,22 +46,3 @@ * Returns the value of a given attribute.

} else if (attribute.type === 'JSXAttribute') {
if (attribute.value.type === 'Literal') {
return attribute.value.value === "" ? undefined : attribute.value.value;
} else if (attribute.value.type === 'JSXExpressionContainer') {
const expression = attribute.value.expression;
switch (expression.type) {
case 'Literal':
return expression.value === "" ? undefined : expression.value;
case 'TemplateLiteral':
return buildTemplateLiteral(expression);
case 'Identifier':
return expression.name == 'undefined' ? undefined : expression.name;
case 'ArrowFunctionExpression':
case 'FunctionExpression':
return () => void 0;
default:
return undefined;
}
}
return getValue(attribute.value);
}

@@ -40,0 +49,0 @@

@@ -58,2 +58,3 @@ /**

{ code: '<UX.Layout>test</UX.Layout>', parserOptions },
{ code: '<img alt={alt || "Alt text" } />', parserOptions },

@@ -74,2 +75,3 @@ // CUSTOM ELEMENT TESTS FOR STRING OPTION

{ code: '<AVATAR />', options: string, parserOptions },
{ code: '<Avatar alt={alt || "foo" } />', options: string, parserOptions },

@@ -90,2 +92,3 @@ // CUSTOM ELEMENT TESTS FOR ARRAY OPTION TESTS

{ code: '<THUMBNAIL />', options: array, parserOptions },
{ code: '<Thumbnail alt={alt || "foo" } />', options: array, parserOptions },
{ code: '<Image alt="foo" />;', options: array, parserOptions },

@@ -103,3 +106,4 @@ { code: '<Image alt={"foo"} />;', options: array, parserOptions },

{ code: '<Image alt={() => void 0} />', options: array, parserOptions },
{ code: '<IMAGE />', options: array, parserOptions }
{ code: '<IMAGE />', options: array, parserOptions },
{ code: '<Image alt={alt || "foo" } />', options: array, parserOptions }
],

@@ -115,2 +119,3 @@ invalid: [

{ code: '<img {...this.props} />', errors: [ expectedError ], parserOptions },
{ code: '<img alt={false || false} />', errors: [ expectedError ], parserOptions },

@@ -117,0 +122,0 @@ // CUSTOM ELEMENT TESTS FOR STRING OPTION

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc