Changeset 0c6b92a for imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unescaped-entities.js
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-unescaped-entities.js
rd565449 r0c6b92a 10 10 const jsxUtil = require('../util/jsx'); 11 11 const report = require('../util/report'); 12 const getMessageData = require('../util/message'); 12 13 13 14 // ------------------------------------------------------------------------------ … … 35 36 unescapedEntity: 'HTML entity, `{{entity}}` , must be escaped.', 36 37 unescapedEntityAlts: '`{{entity}}` can be escaped with {{alts}}.', 38 replaceWithAlt: 'Replace with `{{alt}}`.', 37 39 }; 38 40 … … 40 42 module.exports = { 41 43 meta: { 44 hasSuggestions: true, 42 45 docs: { 43 46 description: 'Disallow unescaped HTML entities from appearing in markup', … … 118 121 alts: entities[j].alternatives.map((alt) => `\`${alt}\``).join(', '), 119 122 }, 123 suggest: entities[j].alternatives.map((alt) => Object.assign( 124 getMessageData('replaceWithAlt', messages.replaceWithAlt), 125 { 126 data: { alt }, 127 fix(fixer) { 128 const lineToChange = i - node.loc.start.line; 129 130 const newText = node.raw.split('\n').map((line, idx) => { 131 if (idx === lineToChange) { 132 return line.slice(0, index) + alt + line.slice(index + 1); 133 } 134 135 return line; 136 }).join('\n'); 137 138 return fixer.replaceText(node, newText); 139 }, 140 } 141 )), 120 142 }); 121 143 }
Note:
See TracChangeset
for help on using the changeset viewer.