Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

no-empty-character-class problem #376

Closed
Mister-Hope opened this issue Feb 27, 2019 · 0 comments
Closed

no-empty-character-class problem #376

Mister-Hope opened this issue Feb 27, 2019 · 0 comments

Comments

@Mister-Hope
Copy link

Mister-Hope commented Feb 27, 2019

Here is my code.

  get pText() {
    return this.text.replace(/\n/gu, '<br/>').replace(/\s/gu, '&ensp;');
  }

And I got the hint

WARNING in U:/vue/src/components/BaseP.vue
35:30 don't use empty classes in regular expressions
    33 |   // 对text进行处理以在网页上正常显示空格与换行
    34 |   get pText() {
  > 35 |     return this.text.replace(/\n/gu, '<br/>').replace(/\s/gu, '&ensp;');
       |                              ^
    36 |   }
    37 | 
    38 |   // 图片加载状态
WARNING in U:/vue/src/components/BaseP.vue
35:55 don't use empty classes in regular expressions
    33 |   // 对text进行处理以在网页上正常显示空格与换行
    34 |   get pText() {
  > 35 |     return this.text.replace(/\n/gu, '<br/>').replace(/\s/gu, '&ensp;');
       |                                                       ^
    36 |   }
    37 | 
    38 |   // 图片加载状态
WARNING in U:/vue/src/components/BaseTimeAxis.vue
42:42 don't use empty classes in regular expressions
    40 | 
    41 |     this.timeList.forEach((element, index) => {
  > 42 |       list[index] = element.text.replace(/\n/gu, '<br/>').replace(/\s/gu, '&ensp;');
       |                                          ^
    43 |     });
    44 | 
    45 |     return list;
WARNING in U:/vue/src/components/BaseTimeAxis.vue
42:67 don't use empty classes in regular expressions
    40 | 
    41 |     this.timeList.forEach((element, index) => {
  > 42 |       list[index] = element.text.replace(/\n/gu, '<br/>').replace(/\s/gu, '&ensp;');
       |                                                                   ^
    43 |     });
    44 | 
    45 |     return list;

I don't think it has a empty class, or could anyone tell me how to write \n and \s inroder to prevent this error?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant