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

no-empty-character-class problem #376

@Mister-Hope

Description

@Mister-Hope

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions