UNPKG

eslint-plugin-styled-components-a11y

Version:

This plugin adds the ability to lint styled components according to the rules outlined in eslint-plugin-jsx-a11y.

13 lines (12 loc) 475 B
"use strict"; var _require = require('@babel/parser'), parse = _require.parse; var keyValuePairToProps = require('./keyValuePairToProps'); module.exports = function (styledAttrs, nodeAttrs) { var jsxString = "<div ".concat(styledAttrs.map(keyValuePairToProps).join(' '), "/>"); var ast = parse(jsxString, { plugins: ['jsx', 'estree'] }); var astAttributes = ast.program.body[0].expression.openingElement.attributes; return nodeAttrs.concat(astAttributes); };