Skip to content

Commit

Permalink
fix: disallow uppercase strings in JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
edvardchen committed Apr 8, 2019
1 parent 3f3609a commit 715cba4
Show file tree
Hide file tree
Showing 4 changed files with 778 additions and 1,831 deletions.
6 changes: 3 additions & 3 deletions lib/rules/no-literal-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ module.exports = {
if (typeof node.value === 'string') {
const trimed = node.value.trim();
if (!trimed) return;
if (isUpperCase(trimed)) return;

const { parent } = node;

if (isUpperCase(trimed) && parent.type !== 'JSXElement') return;

if (parent) {
switch (parent.type) {
case 'VariableDeclarator': {
Expand All @@ -94,7 +96,6 @@ module.exports = {
case 'Property': {
// if node is key of property, skip
if (parent.key === node) return;

// name if key is Identifier; value if key is Literal
// dont care whether if this is computed or not
if (isUpperCase(parent.key.name || parent.key.value)) return;
Expand All @@ -104,7 +105,6 @@ module.exports = {
return;
default:
let LOOK_UP_LIMIT = 3;

let temp = parent;
while (temp && LOOK_UP_LIMIT > 0) {
LOOK_UP_LIMIT--;
Expand Down
Loading

0 comments on commit 715cba4

Please sign in to comment.