Skip to content

Commit

Permalink
fix: validate correctly call chains
Browse files Browse the repository at this point in the history
closes #54
  • Loading branch information
edvardchen committed May 15, 2022
1 parent 3d479a1 commit dc33346
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/rules/no-literal-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 13 additions & 1 deletion tests/lib/rules/no-literal-string/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit dc33346

Please sign in to comment.