diff --git a/tests/lib/rules/jsx-no-literals.js b/tests/lib/rules/jsx-no-literals.js index d1cbcecb77..17837fc580 100644 --- a/tests/lib/rules/jsx-no-literals.js +++ b/tests/lib/rules/jsx-no-literals.js @@ -613,5 +613,76 @@ ruleTester.run('jsx-no-literals', rule, { }, ], }, + { + code: ` + import React from 'react'; + + function TestComponent() { + return ( +
+ {/* these are obvious errors */} + Test + { "Test" } +
+ ); + } + + export default TestComponent; + `, + options: [{ noStrings: true, ignoreProps: false, noAttributeStrings: true }], + errors: [ + { + messageId: 'noStringsInAttributes', + data: { text: '`test`' }, + line: 7, + }, + { + messageId: 'noStringsInAttributes', + data: { text: '"test"' }, + line: 8, + }, + { + messageId: 'noStringsInAttributes', + data: { text: '\'test\'' }, + line: 9, + }, + { + messageId: 'invalidPropValue', + data: { text: 'propNoError1="test"' }, + line: 10, + }, + { + messageId: 'noStringsInAttributes', + data: { text: '"test"' }, + line: 10, + }, + { + messageId: 'invalidPropValue', + data: { text: 'propNoError2=\'test\'' }, + line: 11, + }, + { + messageId: 'noStringsInAttributes', + data: { text: '\'test\'' }, + line: 11, + }, + { + messageId: 'literalNotInJSXExpression', + data: { text: 'Test' }, + line: 14, + }, + { + messageId: 'noStringsInJsx', + data: { text: '"Test"' }, + line: 15, + }, + ], + }, ]), });