vitaly-t / decomment

:hammer: Removes comments from JSON, JavaScript, CSS, HTML, etc.
75 stars 21 forks source link

trim supports deleting the blank characters before and after the comment #21

Closed wll8 closed 2 years ago

wll8 commented 3 years ago

trim supports deleting the blank characters before and after the comment

Supported options:

Source code:

const api = new CustomApi({
   axiosConfig: {
     timeout: 10000, // timeouttimeout
     baseURL: config.baseApi,
   },
})

Configuration:

outStr = decomment(str, {
   trim: true,
});

Actual:

Note: timeout: 10000, there is a space after it

const api = new CustomApi({
  axiosConfig: {
    timeout: 10000, 
    baseURL: config.baseApi,
  },
})

expect:

Note: timeout: 10000, there is no space after

const api = new CustomApi({
   axiosConfig: {
     timeout: 10000,
     baseURL: config.baseApi,
   },
})
vitaly-t commented 2 years ago

Documentation tells you - remove empty lines that follow removed full-line comments. It is not relevant to space characters on the same line, only to extraneous lines that follow a comment line.