Initial import with skill sheet working

This commit is contained in:
2024-12-04 00:11:23 +01:00
commit 9050c80ab4
4488 changed files with 671048 additions and 0 deletions

2476
node_modules/eslint/lib/rules/utils/ast-utils.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

240
node_modules/eslint/lib/rules/utils/char-source.js generated vendored Normal file
View File

@ -0,0 +1,240 @@
/**
* @fileoverview Utility functions to locate the source text of each code unit in the value of a string literal or template token.
* @author Francesco Trotta
*/
"use strict";
/**
* Represents a code unit produced by the evaluation of a JavaScript common token like a string
* literal or template token.
*/
class CodeUnit {
constructor(start, source) {
this.start = start;
this.source = source;
}
get end() {
return this.start + this.length;
}
get length() {
return this.source.length;
}
}
/**
* An object used to keep track of the position in a source text where the next characters will be read.
*/
class TextReader {
constructor(source) {
this.source = source;
this.pos = 0;
}
/**
* Advances the reading position of the specified number of characters.
* @param {number} length Number of characters to advance.
* @returns {void}
*/
advance(length) {
this.pos += length;
}
/**
* Reads characters from the source.
* @param {number} [offset=0] The offset where reading starts, relative to the current position.
* @param {number} [length=1] Number of characters to read.
* @returns {string} A substring of source characters.
*/
read(offset = 0, length = 1) {
const start = offset + this.pos;
return this.source.slice(start, start + length);
}
}
const SIMPLE_ESCAPE_SEQUENCES =
{ __proto__: null, b: "\b", f: "\f", n: "\n", r: "\r", t: "\t", v: "\v" };
/**
* Reads a hex escape sequence.
* @param {TextReader} reader The reader should be positioned on the first hexadecimal digit.
* @param {number} length The number of hexadecimal digits.
* @returns {string} A code unit.
*/
function readHexSequence(reader, length) {
const str = reader.read(0, length);
const charCode = parseInt(str, 16);
reader.advance(length);
return String.fromCharCode(charCode);
}
/**
* Reads a Unicode escape sequence.
* @param {TextReader} reader The reader should be positioned after the "u".
* @returns {string} A code unit.
*/
function readUnicodeSequence(reader) {
const regExp = /\{(?<hexDigits>[\dA-Fa-f]+)\}/uy;
regExp.lastIndex = reader.pos;
const match = regExp.exec(reader.source);
if (match) {
const codePoint = parseInt(match.groups.hexDigits, 16);
reader.pos = regExp.lastIndex;
return String.fromCodePoint(codePoint);
}
return readHexSequence(reader, 4);
}
/**
* Reads an octal escape sequence.
* @param {TextReader} reader The reader should be positioned after the first octal digit.
* @param {number} maxLength The maximum number of octal digits.
* @returns {string} A code unit.
*/
function readOctalSequence(reader, maxLength) {
const [octalStr] = reader.read(-1, maxLength).match(/^[0-7]+/u);
reader.advance(octalStr.length - 1);
const octal = parseInt(octalStr, 8);
return String.fromCharCode(octal);
}
/**
* Reads an escape sequence or line continuation.
* @param {TextReader} reader The reader should be positioned on the backslash.
* @returns {string} A string of zero, one or two code units.
*/
function readEscapeSequenceOrLineContinuation(reader) {
const char = reader.read(1);
reader.advance(2);
const unitChar = SIMPLE_ESCAPE_SEQUENCES[char];
if (unitChar) {
return unitChar;
}
switch (char) {
case "x":
return readHexSequence(reader, 2);
case "u":
return readUnicodeSequence(reader);
case "\r":
if (reader.read() === "\n") {
reader.advance(1);
}
// fallthrough
case "\n":
case "\u2028":
case "\u2029":
return "";
case "0":
case "1":
case "2":
case "3":
return readOctalSequence(reader, 3);
case "4":
case "5":
case "6":
case "7":
return readOctalSequence(reader, 2);
default:
return char;
}
}
/**
* Reads an escape sequence or line continuation and generates the respective `CodeUnit` elements.
* @param {TextReader} reader The reader should be positioned on the backslash.
* @returns {Generator<CodeUnit>} Zero, one or two `CodeUnit` elements.
*/
function *mapEscapeSequenceOrLineContinuation(reader) {
const start = reader.pos;
const str = readEscapeSequenceOrLineContinuation(reader);
const end = reader.pos;
const source = reader.source.slice(start, end);
switch (str.length) {
case 0:
break;
case 1:
yield new CodeUnit(start, source);
break;
default:
yield new CodeUnit(start, source);
yield new CodeUnit(start, source);
break;
}
}
/**
* Parses a string literal.
* @param {string} source The string literal to parse, including the delimiting quotes.
* @returns {CodeUnit[]} A list of code units produced by the string literal.
*/
function parseStringLiteral(source) {
const reader = new TextReader(source);
const quote = reader.read();
reader.advance(1);
const codeUnits = [];
for (;;) {
const char = reader.read();
if (char === quote) {
break;
}
if (char === "\\") {
codeUnits.push(...mapEscapeSequenceOrLineContinuation(reader));
} else {
codeUnits.push(new CodeUnit(reader.pos, char));
reader.advance(1);
}
}
return codeUnits;
}
/**
* Parses a template token.
* @param {string} source The template token to parse, including the delimiting sequences `` ` ``, `${` and `}`.
* @returns {CodeUnit[]} A list of code units produced by the template token.
*/
function parseTemplateToken(source) {
const reader = new TextReader(source);
reader.advance(1);
const codeUnits = [];
for (;;) {
const char = reader.read();
if (char === "`" || char === "$" && reader.read(1) === "{") {
break;
}
if (char === "\\") {
codeUnits.push(...mapEscapeSequenceOrLineContinuation(reader));
} else {
let unitSource;
if (char === "\r" && reader.read(1) === "\n") {
unitSource = "\r\n";
} else {
unitSource = char;
}
codeUnits.push(new CodeUnit(reader.pos, unitSource));
reader.advance(unitSource.length);
}
}
return codeUnits;
}
module.exports = { parseStringLiteral, parseTemplateToken };

114
node_modules/eslint/lib/rules/utils/fix-tracker.js generated vendored Normal file
View File

@ -0,0 +1,114 @@
/**
* @fileoverview Helper class to aid in constructing fix commands.
* @author Alan Pierce
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./ast-utils");
//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
/**
* A helper class to combine fix options into a fix command. Currently, it
* exposes some "retain" methods that extend the range of the text being
* replaced so that other fixes won't touch that region in the same pass.
*/
class FixTracker {
/**
* Create a new FixTracker.
* @param {ruleFixer} fixer A ruleFixer instance.
* @param {SourceCode} sourceCode A SourceCode object for the current code.
*/
constructor(fixer, sourceCode) {
this.fixer = fixer;
this.sourceCode = sourceCode;
this.retainedRange = null;
}
/**
* Mark the given range as "retained", meaning that other fixes may not
* may not modify this region in the same pass.
* @param {int[]} range The range to retain.
* @returns {FixTracker} The same RuleFixer, for chained calls.
*/
retainRange(range) {
this.retainedRange = range;
return this;
}
/**
* Given a node, find the function containing it (or the entire program) and
* mark it as retained, meaning that other fixes may not modify it in this
* pass. This is useful for avoiding conflicts in fixes that modify control
* flow.
* @param {ASTNode} node The node to use as a starting point.
* @returns {FixTracker} The same RuleFixer, for chained calls.
*/
retainEnclosingFunction(node) {
const functionNode = astUtils.getUpperFunction(node);
return this.retainRange(functionNode ? functionNode.range : this.sourceCode.ast.range);
}
/**
* Given a node or token, find the token before and afterward, and mark that
* range as retained, meaning that other fixes may not modify it in this
* pass. This is useful for avoiding conflicts in fixes that make a small
* change to the code where the AST should not be changed.
* @param {ASTNode|Token} nodeOrToken The node or token to use as a starting
* point. The token to the left and right are use in the range.
* @returns {FixTracker} The same RuleFixer, for chained calls.
*/
retainSurroundingTokens(nodeOrToken) {
const tokenBefore = this.sourceCode.getTokenBefore(nodeOrToken) || nodeOrToken;
const tokenAfter = this.sourceCode.getTokenAfter(nodeOrToken) || nodeOrToken;
return this.retainRange([tokenBefore.range[0], tokenAfter.range[1]]);
}
/**
* Create a fix command that replaces the given range with the given text,
* accounting for any retained ranges.
* @param {int[]} range The range to remove in the fix.
* @param {string} text The text to insert in place of the range.
* @returns {Object} The fix command.
*/
replaceTextRange(range, text) {
let actualRange;
if (this.retainedRange) {
actualRange = [
Math.min(this.retainedRange[0], range[0]),
Math.max(this.retainedRange[1], range[1])
];
} else {
actualRange = range;
}
return this.fixer.replaceTextRange(
actualRange,
this.sourceCode.text.slice(actualRange[0], range[0]) +
text +
this.sourceCode.text.slice(range[1], actualRange[1])
);
}
/**
* Create a fix command that removes the given node or token, accounting for
* any retained ranges.
* @param {ASTNode|Token} nodeOrToken The node or token to remove.
* @returns {Object} The fix command.
*/
remove(nodeOrToken) {
return this.replaceTextRange(nodeOrToken.range, "");
}
}
module.exports = FixTracker;

67
node_modules/eslint/lib/rules/utils/keywords.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
/**
* @fileoverview A shared list of ES3 keywords.
* @author Josh Perez
*/
"use strict";
module.exports = [
"abstract",
"boolean",
"break",
"byte",
"case",
"catch",
"char",
"class",
"const",
"continue",
"debugger",
"default",
"delete",
"do",
"double",
"else",
"enum",
"export",
"extends",
"false",
"final",
"finally",
"float",
"for",
"function",
"goto",
"if",
"implements",
"import",
"in",
"instanceof",
"int",
"interface",
"long",
"native",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"short",
"static",
"super",
"switch",
"synchronized",
"this",
"throw",
"throws",
"transient",
"true",
"try",
"typeof",
"var",
"void",
"volatile",
"while",
"with"
];

View File

@ -0,0 +1,115 @@
/**
* @fileoverview `Map` to load rules lazily.
* @author Toru Nagashima <https://github.com/mysticatea>
*/
"use strict";
const debug = require("debug")("eslint:rules");
/** @typedef {import("../../shared/types").Rule} Rule */
/**
* The `Map` object that loads each rule when it's accessed.
* @example
* const rules = new LazyLoadingRuleMap([
* ["eqeqeq", () => require("eqeqeq")],
* ["semi", () => require("semi")],
* ["no-unused-vars", () => require("no-unused-vars")]
* ]);
*
* rules.get("semi"); // call `() => require("semi")` here.
*
* @extends {Map<string, () => Rule>}
*/
class LazyLoadingRuleMap extends Map {
/**
* Initialize this map.
* @param {Array<[string, function(): Rule]>} loaders The rule loaders.
*/
constructor(loaders) {
let remaining = loaders.length;
super(
debug.enabled
? loaders.map(([ruleId, load]) => {
let cache = null;
return [
ruleId,
() => {
if (!cache) {
debug("Loading rule %o (remaining=%d)", ruleId, --remaining);
cache = load();
}
return cache;
}
];
})
: loaders
);
// `super(...iterable)` uses `this.set()`, so disable it here.
Object.defineProperty(LazyLoadingRuleMap.prototype, "set", {
configurable: true,
value: void 0
});
}
/**
* Get a rule.
* Each rule will be loaded on the first access.
* @param {string} ruleId The rule ID to get.
* @returns {Rule|undefined} The rule.
*/
get(ruleId) {
const load = super.get(ruleId);
return load && load();
}
/**
* Iterate rules.
* @returns {IterableIterator<Rule>} Rules.
*/
*values() {
for (const load of super.values()) {
yield load();
}
}
/**
* Iterate rules.
* @returns {IterableIterator<[string, Rule]>} Rules.
*/
*entries() {
for (const [ruleId, load] of super.entries()) {
yield [ruleId, load()];
}
}
/**
* Call a function with each rule.
* @param {Function} callbackFn The callback function.
* @param {any} [thisArg] The object to pass to `this` of the callback function.
* @returns {void}
*/
forEach(callbackFn, thisArg) {
for (const [ruleId, load] of super.entries()) {
callbackFn.call(thisArg, load(), ruleId, this);
}
}
}
// Forbid mutation.
Object.defineProperties(LazyLoadingRuleMap.prototype, {
clear: { configurable: true, value: void 0 },
delete: { configurable: true, value: void 0 },
[Symbol.iterator]: {
configurable: true,
writable: true,
value: LazyLoadingRuleMap.prototype.entries
}
});
module.exports = { LazyLoadingRuleMap };

View File

@ -0,0 +1,50 @@
/**
* @fileoverview Common utils for regular expressions.
* @author Josh Goldberg
* @author Toru Nagashima
*/
"use strict";
const { RegExpValidator } = require("@eslint-community/regexpp");
const REGEXPP_LATEST_ECMA_VERSION = 2025;
/**
* Checks if the given regular expression pattern would be valid with the `u` flag.
* @param {number} ecmaVersion ECMAScript version to parse in.
* @param {string} pattern The regular expression pattern to verify.
* @param {"u"|"v"} flag The type of Unicode flag
* @returns {boolean} `true` if the pattern would be valid with the `u` flag.
* `false` if the pattern would be invalid with the `u` flag or the configured
* ecmaVersion doesn't support the `u` flag.
*/
function isValidWithUnicodeFlag(ecmaVersion, pattern, flag = "u") {
if (flag === "u" && ecmaVersion <= 5) { // ecmaVersion <= 5 doesn't support the 'u' flag
return false;
}
if (flag === "v" && ecmaVersion <= 2023) {
return false;
}
const validator = new RegExpValidator({
ecmaVersion: Math.min(ecmaVersion, REGEXPP_LATEST_ECMA_VERSION)
});
try {
validator.validatePattern(pattern, void 0, void 0, flag === "u" ? {
unicode: /* uFlag = */ true
} : {
unicodeSets: true
});
} catch {
return false;
}
return true;
}
module.exports = {
isValidWithUnicodeFlag,
REGEXPP_LATEST_ECMA_VERSION
};

16
node_modules/eslint/lib/rules/utils/unicode/index.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
*/
"use strict";
const isCombiningCharacter = require("./is-combining-character");
const isEmojiModifier = require("./is-emoji-modifier");
const isRegionalIndicatorSymbol = require("./is-regional-indicator-symbol");
const isSurrogatePair = require("./is-surrogate-pair");
module.exports = {
isCombiningCharacter,
isEmojiModifier,
isRegionalIndicatorSymbol,
isSurrogatePair
};

View File

@ -0,0 +1,13 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
*/
"use strict";
/**
* Check whether a given character is a combining mark or not.
* @param {number} codePoint The character code to check.
* @returns {boolean} `true` if the character belongs to the category, any of `Mc`, `Me`, and `Mn`.
*/
module.exports = function isCombiningCharacter(codePoint) {
return /^[\p{Mc}\p{Me}\p{Mn}]$/u.test(String.fromCodePoint(codePoint));
};

View File

@ -0,0 +1,13 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
*/
"use strict";
/**
* Check whether a given character is an emoji modifier.
* @param {number} code The character code to check.
* @returns {boolean} `true` if the character is an emoji modifier.
*/
module.exports = function isEmojiModifier(code) {
return code >= 0x1F3FB && code <= 0x1F3FF;
};

View File

@ -0,0 +1,13 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
*/
"use strict";
/**
* Check whether a given character is a regional indicator symbol.
* @param {number} code The character code to check.
* @returns {boolean} `true` if the character is a regional indicator symbol.
*/
module.exports = function isRegionalIndicatorSymbol(code) {
return code >= 0x1F1E6 && code <= 0x1F1FF;
};

View File

@ -0,0 +1,14 @@
/**
* @author Toru Nagashima <https://github.com/mysticatea>
*/
"use strict";
/**
* Check whether given two characters are a surrogate pair.
* @param {number} lead The code of the lead character.
* @param {number} tail The code of the tail character.
* @returns {boolean} `true` if the character pair is a surrogate pair.
*/
module.exports = function isSurrogatePair(lead, tail) {
return lead >= 0xD800 && lead < 0xDC00 && tail >= 0xDC00 && tail < 0xE000;
};