diff --git a/lib/rules/no-literal-string.js b/lib/rules/no-literal-string.js index d06d53a..0d669a1 100644 --- a/lib/rules/no-literal-string.js +++ b/lib/rules/no-literal-string.js @@ -279,11 +279,13 @@ module.exports = { }, 'SwitchCase > Literal:exit': endIndicator, - MemberExpression(node) { + 'MemberExpression > Literal'(node) { // allow Enum['value'] indicatorStack.push(true); }, - 'MemberExpression:exit': endIndicator, + 'MemberExpression > Literal:exit'(node) { + endIndicator(); + }, TemplateLiteral(node) { if (!validateTemplate) { diff --git a/tests/lib/rules/no-literal-string/all.js b/tests/lib/rules/no-literal-string/all.js index 97afa8b..655cff5 100644 --- a/tests/lib/rules/no-literal-string/all.js +++ b/tests/lib/rules/no-literal-string/all.js @@ -3,7 +3,19 @@ const runTest = require('../../helpers/runTest'); const cases = { valid: [testFile('valid.jsx')], - invalid: [{ ...testFile('invalid.jsx'), errors: 13 }], + invalid: [ + { ...testFile('invalid.jsx'), errors: 13 }, + { + code: `export const validationSchema = Yup.object({ + email: Yup + .string() + .email('hello') + .required('world'), + })`, + options: [{ mode: 'all' }], + errors: 2, + }, + ], }; runTest('no-literal-string: mode all', cases);