Bedrock: Fix eslint 'no-useless-escape' errors.

Created on 18 Sep 2019  路  10Comments  路  Source: mozilla/bedrock

Description

When running make run to start bedrock you may notice some errors in your console such as:

assets_1      | /app/media/js/base/mozilla-client.js
assets_1      |   99:55  warning  Unnecessary escape character: \ .  no-useless-escape`

The no-useless-escape rule lints for unnecessary characters in regular expressions, .etc. The above error is saying: on line 99 in /app/media/js/base/mozilla-client.js there is an extra \ character.

We should go through and make the recommended eslint fixes to fix these errors.

Good First Bug P3 Papercuts聽馃捀

All 10 comments

I have removed the no-useless-escape rule lints for unnecessary characters in regular expressions, .etc.
Please review it and let me know soon.

Once this is fixed let鈥檚 be sure to remove the rule for it: https://github.com/mozilla/bedrock/blob/master/.eslintrc.js#L8

@alexgibson shouldn't we keep the rule for future regex?

shouldn't we keep the rule for future regex?

The rule is in there as an exception, so it triggers a warning instead of an error. If we remove the rule after this work is done, then it will fall back to the default.

So what should I basically do , should I remove those extra escape char or just remove the rule as suggested by @alexgibson .Please let me know soon @amychurchwell .

Both would be ideal. Thank you, @Shivansh2407

Can you please tell how to fix this snippet :
var regex = RegExp(param + '=([^#\&\?]+).*$');

Here it is showing:
33:49 warning Unnecessary escape character: # no-useless-escape
33:51 warning Unnecessary escape character: \& no-useless-escape
33:53 warning Unnecessary escape character: \? no-useless-escape
Please let me know soon so that I can complete fixing the issue and create a PR for this.

in the error:

/app/media/js/firefox/concerts.js
  33:49  warning  Unnecessary escape character: \#  no-useless-escape
  33:51  warning  Unnecessary escape character: \&  no-useless-escape
  33:53  warning  Unnecessary escape character: \?  no-useless-escape

in /app/media/js/firefox/concerts.js on line 33:
var regex = RegExp(param + '=([^\#\&\?]+).*$');

The errors should stop once the \ characters are removed:
var regex = RegExp(param + '=([^#&?]+).*$');

and running make lint in your console should show that file has been fixed.

I am fixing this issue by creating PRs for changing various files. Please review and merge them accordingly.

Hi @Shivansh2407! we don't need to open a separate PR for every file, they can be added to your original PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoosteeno picture hoosteeno  路  9Comments

amychurchwell picture amychurchwell  路  12Comments

rraue picture rraue  路  9Comments

alexgibson picture alexgibson  路  9Comments

alexgibson picture alexgibson  路  8Comments