Skip to content

Commit 6b5d67a

Browse files
Fixed no-raw-text rule for typescript
- fixed rule for @typescript-eslint/parser - added .DS_Store to .gitignore
1 parent 89c3a11 commit 6b5d67a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ build/Release
2727
node_modules
2828

2929
.idea
30+
31+
# OSX
32+
#
33+
.DS_Store

lib/rules/no-raw-text.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ module.exports = (context) => {
3333
const skippedElements = options.skip ? options.skip : [];
3434
const allowedElements = ['Text', 'TSpan', 'StyledText'].concat(skippedElements);
3535

36+
const hasOnlyLineBreak = value => /^[\r\n\t\f\v]+$/.test(value.replace(/ /g, ''));
37+
3638
const getValidation = node => !allowedElements.includes(elementName(node.parent));
3739

3840
return {
3941
Literal(node) {
4042
const parentType = node.parent.type;
4143
const onlyFor = ['JSXExpressionContainer', 'JSXElement'];
4244
if (typeof node.value !== 'string' ||
43-
/^[\r\n\t\f\v]+$/.test(node.value.replace(/ /g, '')) ||
45+
hasOnlyLineBreak(node.value) ||
4446
!onlyFor.includes(parentType) ||
4547
(node.parent.parent && node.parent.parent.type === 'JSXAttribute')
4648
) return;
@@ -52,6 +54,7 @@ module.exports = (context) => {
5254
},
5355

5456
JSXText(node) {
57+
if (typeof node.value !== 'string' || hasOnlyLineBreak(node.value)) return;
5558
if (getValidation(node)) {
5659
report(node);
5760
}

0 commit comments

Comments
 (0)