Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Style error information
https://eslint.org/docs/rules/no-useless-escape
How to Review
## 1. Apply Patch
## 2. Review Code Changes
## 3. Confirm no Code Standard Errors
yarn & yarn lint:core-js-passing
## 4.1 If `NO` errors, mark the issue as `Reviewed & tested by the community` (Don't be shy, we're all friendly)
## 4.2 If `HAS` errors, fix it and upload a new patch (Just do it and you can!!!)
Background
- #2912962: Step 1 JS codestyle: [meta] Fix JS coding standards in core
- We adapted the airbnb coding standard (#2815077: Adopt airbnb javascript style guide v14.1 as new baseline javascript coding standards for Drupal 8 core and contrib), but we are not fully compliant to it yet.
More Information
- Using ES6 in Core
https://www.drupal.org/node/2815083
- To find JS code standard errors stats
yarn & yarn lint:core-js-stats
Comment | File | Size | Author |
---|---|---|---|
#7 | 2916294-7.patch | 8.7 KB | dawehner |
#4 | 2916294-3.patch | 8.74 KB | dawehner |
#2 | 2916294-2.patch | 5.1 KB | dawehner |
Comments
Comment #2
dawehnerHere is some patch
Comment #3
GrandmaGlassesRopeMan@dawehner Is the transpiled JS missing from this patch?
Comment #4
dawehneroops, I forgot the transpiling.
Comment #5
GrandmaGlassesRopeManI think this looks alright. Some of these were holdovers before template strings. 👍
Comment #7
dawehnerFalling back to patching base and 3-way merge...
🎆Here is a quick reroll.
Comment #9
xjmThis issue has been an exciting test of my regex skills, both in terms of when escaping is and isn't needed for special characters, and in crafting a word diff to diff them. (As well as a test of my eyesight.)
Turns out the word diff is actually super simple. Let's call it a "character diff", even:
git diff --staged --color-words="."
The only changes are removed
\
in places that https://eslint.org/docs/rules/no-useless-escape says they can be removed safely. The aforementioned page helped reassure me that it is in fact safe to not use\
on[
inside a character class. I also learned something. I did not expect the following to work, but the page reassures me that it will not result in a behavior change:In PHP it would have been, just, like, wrong (in HEAD that is).
I read over the changes carefully and linted before and after. Before:
After:
So, committed and pushed to 8.5.x. Thanks!
Comment #10
dawehnerThat's super cool. Thank you for sharing this! Now I jut need to remember it by thinking about no useless escapes.
Me neither to be honest, I'm glad eslint helps us to catch these differences between languages.