Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
51
Frontend-Learner/node_modules/eslint-plugin-regexp/dist/rules/prefer-unicode-codepoint-escapes.js
generated
vendored
Normal file
51
Frontend-Learner/node_modules/eslint-plugin-regexp/dist/rules/prefer-unicode-codepoint-escapes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("../utils");
|
||||
exports.default = (0, utils_1.createRule)("prefer-unicode-codepoint-escapes", {
|
||||
meta: {
|
||||
docs: {
|
||||
description: "enforce use of unicode codepoint escapes",
|
||||
category: "Stylistic Issues",
|
||||
recommended: true,
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [],
|
||||
messages: {
|
||||
disallowSurrogatePair: "Use Unicode codepoint escapes instead of Unicode escapes using surrogate pairs.",
|
||||
},
|
||||
type: "suggestion",
|
||||
},
|
||||
create(context) {
|
||||
function createVisitor(regexpContext) {
|
||||
const { node, flags, getRegexpLocation, fixReplaceNode } = regexpContext;
|
||||
if (!flags.unicode && !flags.unicodeSets) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
onCharacterEnter(cNode) {
|
||||
if (cNode.value >= 0x10000) {
|
||||
if (/^(?:\\u[\dA-Fa-f]{4}){2}$/u.test(cNode.raw)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: getRegexpLocation(cNode),
|
||||
messageId: "disallowSurrogatePair",
|
||||
fix: fixReplaceNode(cNode, () => {
|
||||
let text = String.fromCodePoint(cNode.value)
|
||||
.codePointAt(0)
|
||||
.toString(16);
|
||||
if (/[A-F]/u.test(cNode.raw)) {
|
||||
text = text.toUpperCase();
|
||||
}
|
||||
return `\\u{${text}}`;
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
return (0, utils_1.defineRegexpVisitor)(context, {
|
||||
createVisitor,
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue