update
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 6
|
||||
- 8
|
||||
- 10
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","194":"0 9 AB BB CB DB EB FB"},C:{"2":"0 1 2 3 4 5 6 7 8 9 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC"},D:{"1":"GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","194":"0 9 AB BB CB DB EB FB"},E:{"1":"3C","2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC"},F:{"1":"0 u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l 4C 5C 6C 7C FC kC 8C GC","194":"m n o p q r s t"},G:{"2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A B C H FC kC GC"},L:{"1":"I"},M:{"2":"EC"},N:{"2":"A B"},O:{"2":"HC"},P:{"1":"8","2":"1 2 3 4 5 6 7 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"2":"oD"},R:{"2":"pD"},S:{"2":"qD rD"}},B:5,C:"CSS Anchor Positioning",D:true};
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* react-router v7.5.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// lib/types/route-module.ts
|
||||
var route_module_exports = {};
|
||||
module.exports = __toCommonJS(route_module_exports);
|
||||
@@ -0,0 +1,450 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag `else` after a `return` in `if`
|
||||
* @author Ian Christian Myers
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
const FixTracker = require("./utils/fix-tracker");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: [{ allowElseIf: true }],
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow `else` blocks after `return` statements in `if` statements",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-else-return",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowElseIf: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
fixable: "code",
|
||||
|
||||
messages: {
|
||||
unexpected: "Unnecessary 'else' after 'return'.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const [{ allowElseIf }] = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks whether the given names can be safely used to declare block-scoped variables
|
||||
* in the given scope. Name collisions can produce redeclaration syntax errors,
|
||||
* or silently change references and modify behavior of the original code.
|
||||
*
|
||||
* This is not a generic function. In particular, it is assumed that the scope is a function scope or
|
||||
* a function's inner scope, and that the names can be valid identifiers in the given scope.
|
||||
* @param {string[]} names Array of variable names.
|
||||
* @param {eslint-scope.Scope} scope Function scope or a function's inner scope.
|
||||
* @returns {boolean} True if all names can be safely declared, false otherwise.
|
||||
*/
|
||||
function isSafeToDeclare(names, scope) {
|
||||
if (names.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const functionScope = scope.variableScope;
|
||||
|
||||
/*
|
||||
* If this is a function scope, scope.variables will contain parameters, implicit variables such as "arguments",
|
||||
* all function-scoped variables ('var'), and block-scoped variables defined in the scope.
|
||||
* If this is an inner scope, scope.variables will contain block-scoped variables defined in the scope.
|
||||
*
|
||||
* Redeclaring any of these would cause a syntax error, except for the implicit variables.
|
||||
*/
|
||||
const declaredVariables = scope.variables.filter(
|
||||
({ defs }) => defs.length > 0,
|
||||
);
|
||||
|
||||
if (declaredVariables.some(({ name }) => names.includes(name))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Redeclaring a catch variable would also cause a syntax error.
|
||||
if (scope !== functionScope && scope.upper.type === "catch") {
|
||||
if (
|
||||
scope.upper.variables.some(({ name }) =>
|
||||
names.includes(name),
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Redeclaring an implicit variable, such as "arguments", would not cause a syntax error.
|
||||
* However, if the variable was used, declaring a new one with the same name would change references
|
||||
* and modify behavior.
|
||||
*/
|
||||
const usedImplicitVariables = scope.variables.filter(
|
||||
({ defs, references }) =>
|
||||
defs.length === 0 && references.length > 0,
|
||||
);
|
||||
|
||||
if (
|
||||
usedImplicitVariables.some(({ name }) => names.includes(name))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Declaring a variable with a name that was already used to reference a variable from an upper scope
|
||||
* would change references and modify behavior.
|
||||
*/
|
||||
if (scope.through.some(t => names.includes(t.identifier.name))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the scope is an inner scope (not the function scope), an uninitialized `var` variable declared inside
|
||||
* the scope node (directly or in one of its descendants) is neither declared nor 'through' in the scope.
|
||||
*
|
||||
* For example, this would be a syntax error "Identifier 'a' has already been declared":
|
||||
* function foo() { if (bar) { let a; if (baz) { var a; } } }
|
||||
*/
|
||||
if (scope !== functionScope) {
|
||||
const scopeNodeRange = scope.block.range;
|
||||
const variablesToCheck = functionScope.variables.filter(
|
||||
({ name }) => names.includes(name),
|
||||
);
|
||||
|
||||
if (
|
||||
variablesToCheck.some(v =>
|
||||
v.defs.some(
|
||||
({ node: { range } }) =>
|
||||
scopeNodeRange[0] <= range[0] &&
|
||||
range[1] <= scopeNodeRange[1],
|
||||
),
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the removal of `else` and its braces is safe from variable name collisions.
|
||||
* @param {Node} node The 'else' node.
|
||||
* @param {eslint-scope.Scope} scope The scope in which the node and the whole 'if' statement is.
|
||||
* @returns {boolean} True if it is safe, false otherwise.
|
||||
*/
|
||||
function isSafeFromNameCollisions(node, scope) {
|
||||
if (node.type === "FunctionDeclaration") {
|
||||
// Conditional function declaration. Scope and hoisting are unpredictable, different engines work differently.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node.type !== "BlockStatement") {
|
||||
return true;
|
||||
}
|
||||
|
||||
const elseBlockScope = scope.childScopes.find(
|
||||
({ block }) => block === node,
|
||||
);
|
||||
|
||||
if (!elseBlockScope) {
|
||||
// ecmaVersion < 6, `else` block statement cannot have its own scope, no possible collisions.
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* elseBlockScope is supposed to merge into its upper scope. elseBlockScope.variables array contains
|
||||
* only block-scoped variables (such as let and const variables or class and function declarations)
|
||||
* defined directly in the elseBlockScope. These are exactly the only names that could cause collisions.
|
||||
*/
|
||||
const namesToCheck = elseBlockScope.variables.map(
|
||||
({ name }) => name,
|
||||
);
|
||||
|
||||
return isSafeToDeclare(namesToCheck, scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the context report if rule is violated
|
||||
* @param {Node} elseNode The 'else' node
|
||||
* @returns {void}
|
||||
*/
|
||||
function displayReport(elseNode) {
|
||||
const currentScope = sourceCode.getScope(elseNode.parent);
|
||||
|
||||
context.report({
|
||||
node: elseNode,
|
||||
messageId: "unexpected",
|
||||
fix(fixer) {
|
||||
if (!isSafeFromNameCollisions(elseNode, currentScope)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const startToken = sourceCode.getFirstToken(elseNode);
|
||||
const elseToken = sourceCode.getTokenBefore(startToken);
|
||||
const source = sourceCode.getText(elseNode);
|
||||
const lastIfToken = sourceCode.getTokenBefore(elseToken);
|
||||
let fixedSource, firstTokenOfElseBlock;
|
||||
|
||||
if (
|
||||
startToken.type === "Punctuator" &&
|
||||
startToken.value === "{"
|
||||
) {
|
||||
firstTokenOfElseBlock =
|
||||
sourceCode.getTokenAfter(startToken);
|
||||
} else {
|
||||
firstTokenOfElseBlock = startToken;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the if block does not have curly braces and does not end in a semicolon
|
||||
* and the else block starts with (, [, /, +, ` or -, then it is not
|
||||
* safe to remove the else keyword, because ASI will not add a semicolon
|
||||
* after the if block
|
||||
*/
|
||||
const ifBlockMaybeUnsafe =
|
||||
elseNode.parent.consequent.type !== "BlockStatement" &&
|
||||
lastIfToken.value !== ";";
|
||||
const elseBlockUnsafe = /^[([/+`-]/u.test(
|
||||
firstTokenOfElseBlock.value,
|
||||
);
|
||||
|
||||
if (ifBlockMaybeUnsafe && elseBlockUnsafe) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const endToken = sourceCode.getLastToken(elseNode);
|
||||
const lastTokenOfElseBlock =
|
||||
sourceCode.getTokenBefore(endToken);
|
||||
|
||||
if (lastTokenOfElseBlock.value !== ";") {
|
||||
const nextToken = sourceCode.getTokenAfter(endToken);
|
||||
|
||||
const nextTokenUnsafe =
|
||||
nextToken && /^[([/+`-]/u.test(nextToken.value);
|
||||
const nextTokenOnSameLine =
|
||||
nextToken &&
|
||||
nextToken.loc.start.line ===
|
||||
lastTokenOfElseBlock.loc.start.line;
|
||||
|
||||
/*
|
||||
* If the else block contents does not end in a semicolon,
|
||||
* and the else block starts with (, [, /, +, ` or -, then it is not
|
||||
* safe to remove the else block, because ASI will not add a semicolon
|
||||
* after the remaining else block contents
|
||||
*/
|
||||
if (
|
||||
nextTokenUnsafe ||
|
||||
(nextTokenOnSameLine && nextToken.value !== "}")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
startToken.type === "Punctuator" &&
|
||||
startToken.value === "{"
|
||||
) {
|
||||
fixedSource = source.slice(1, -1);
|
||||
} else {
|
||||
fixedSource = source;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extend the replacement range to include the entire
|
||||
* function to avoid conflicting with no-useless-return.
|
||||
* https://github.com/eslint/eslint/issues/8026
|
||||
*
|
||||
* Also, to avoid name collisions between two else blocks.
|
||||
*/
|
||||
return new FixTracker(fixer, sourceCode)
|
||||
.retainEnclosingFunction(elseNode)
|
||||
.replaceTextRange(
|
||||
[elseToken.range[0], elseNode.range[1]],
|
||||
fixedSource,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the node is a ReturnStatement
|
||||
* @param {Node} node The node being evaluated
|
||||
* @returns {boolean} True if node is a return
|
||||
*/
|
||||
function checkForReturn(node) {
|
||||
return node.type === "ReturnStatement";
|
||||
}
|
||||
|
||||
/**
|
||||
* Naive return checking, does not iterate through the whole
|
||||
* BlockStatement because we make the assumption that the ReturnStatement
|
||||
* will be the last node in the body of the BlockStatement.
|
||||
* @param {Node} node The consequent/alternate node
|
||||
* @returns {boolean} True if it has a return
|
||||
*/
|
||||
function naiveHasReturn(node) {
|
||||
if (node.type === "BlockStatement") {
|
||||
const body = node.body,
|
||||
lastChildNode = body.at(-1);
|
||||
|
||||
return lastChildNode && checkForReturn(lastChildNode);
|
||||
}
|
||||
return checkForReturn(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the node is valid for evaluation,
|
||||
* meaning it has an else.
|
||||
* @param {Node} node The node being evaluated
|
||||
* @returns {boolean} True if the node is valid
|
||||
*/
|
||||
function hasElse(node) {
|
||||
return node.alternate && node.consequent;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the consequent is an IfStatement, check to see if it has an else
|
||||
* and both its consequent and alternate path return, meaning this is
|
||||
* a nested case of rule violation. If-Else not considered currently.
|
||||
* @param {Node} node The consequent node
|
||||
* @returns {boolean} True if this is a nested rule violation
|
||||
*/
|
||||
function checkForIf(node) {
|
||||
return (
|
||||
node.type === "IfStatement" &&
|
||||
hasElse(node) &&
|
||||
naiveHasReturn(node.alternate) &&
|
||||
naiveHasReturn(node.consequent)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the consequent/body node to make sure it is not
|
||||
* a ReturnStatement or an IfStatement that returns on both
|
||||
* code paths.
|
||||
* @param {Node} node The consequent or body node
|
||||
* @returns {boolean} `true` if it is a Return/If node that always returns.
|
||||
*/
|
||||
function checkForReturnOrIf(node) {
|
||||
return checkForReturn(node) || checkForIf(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a node returns in every codepath.
|
||||
* @param {Node} node The node to be checked
|
||||
* @returns {boolean} `true` if it returns on every codepath.
|
||||
*/
|
||||
function alwaysReturns(node) {
|
||||
if (node.type === "BlockStatement") {
|
||||
// If we have a BlockStatement, check each consequent body node.
|
||||
return node.body.some(checkForReturnOrIf);
|
||||
}
|
||||
|
||||
/*
|
||||
* If not a block statement, make sure the consequent isn't a
|
||||
* ReturnStatement or an IfStatement with returns on both paths.
|
||||
*/
|
||||
return checkForReturnOrIf(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the if statement, but don't catch else-if blocks.
|
||||
* @returns {void}
|
||||
* @param {Node} node The node for the if statement to check
|
||||
* @private
|
||||
*/
|
||||
function checkIfWithoutElse(node) {
|
||||
const parent = node.parent;
|
||||
|
||||
/*
|
||||
* Fixing this would require splitting one statement into two, so no error should
|
||||
* be reported if this node is in a position where only one statement is allowed.
|
||||
*/
|
||||
if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const consequents = [];
|
||||
let alternate;
|
||||
|
||||
for (
|
||||
let currentNode = node;
|
||||
currentNode.type === "IfStatement";
|
||||
currentNode = currentNode.alternate
|
||||
) {
|
||||
if (!currentNode.alternate) {
|
||||
return;
|
||||
}
|
||||
consequents.push(currentNode.consequent);
|
||||
alternate = currentNode.alternate;
|
||||
}
|
||||
|
||||
if (consequents.every(alwaysReturns)) {
|
||||
displayReport(alternate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the if statement
|
||||
* @returns {void}
|
||||
* @param {Node} node The node for the if statement to check
|
||||
* @private
|
||||
*/
|
||||
function checkIfWithElse(node) {
|
||||
const parent = node.parent;
|
||||
|
||||
/*
|
||||
* Fixing this would require splitting one statement into two, so no error should
|
||||
* be reported if this node is in a position where only one statement is allowed.
|
||||
*/
|
||||
if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const alternate = node.alternate;
|
||||
|
||||
if (alternate && alwaysReturns(node.consequent)) {
|
||||
displayReport(alternate);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public API
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
"IfStatement:exit": allowElseIf
|
||||
? checkIfWithoutElse
|
||||
: checkIfWithElse,
|
||||
};
|
||||
},
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P"},C:{"1":"gB hB iB jB kB lB mB nB oB","2":"0 9 nC LC J PB K D E F pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC","132":"1 2 3 4 5 6 7 8 N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB","164":"A B C L M G"},D:{"1":"0 9 bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB","66":"aB"},E:{"2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"1":"0 6 7 8 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 F B C G N O P QB 4C 5C 6C 7C FC kC 8C GC"},G:{"2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"2":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD","2":"rD"}},B:4,C:"Battery Status API",D:true};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag when regex literals are not wrapped in parens
|
||||
* @author Matt DuVall <http://www.mattduvall.com>
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Formatting rules are being moved out of ESLint core.",
|
||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
||||
deprecatedSince: "8.53.0",
|
||||
availableUntil: "10.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin-js",
|
||||
url: "https://eslint.style/packages/js",
|
||||
},
|
||||
rule: {
|
||||
name: "wrap-regex",
|
||||
url: "https://eslint.style/rules/js/wrap-regex",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description: "Require parenthesis around regex literals",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/wrap-regex",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
fixable: "code",
|
||||
|
||||
messages: {
|
||||
requireParens:
|
||||
"Wrap the regexp literal in parens to disambiguate the slash.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
Literal(node) {
|
||||
const token = sourceCode.getFirstToken(node),
|
||||
nodeType = token.type;
|
||||
|
||||
if (nodeType === "RegularExpression") {
|
||||
const beforeToken = sourceCode.getTokenBefore(node);
|
||||
const afterToken = sourceCode.getTokenAfter(node);
|
||||
const { parent } = node;
|
||||
|
||||
if (
|
||||
parent.type === "MemberExpression" &&
|
||||
parent.object === node &&
|
||||
!(
|
||||
beforeToken &&
|
||||
beforeToken.value === "(" &&
|
||||
afterToken &&
|
||||
afterToken.value === ")"
|
||||
)
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "requireParens",
|
||||
fix: fixer =>
|
||||
fixer.replaceText(
|
||||
node,
|
||||
`(${sourceCode.getText(node)})`,
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"matchContext.js","sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\n// N.B. this only exists so we can conditionally call useContext on it when we are not interested in the nearest match\nexport const dummyMatchContext = React.createContext<string | undefined>(\n undefined,\n)\n"],"names":[],"mappings":";AAEa,MAAA,eAAe,MAAM,cAAkC,MAAS;AAGtE,MAAM,oBAAoB,MAAM;AAAA,EACrC;AACF;"}
|
||||
@@ -0,0 +1,19 @@
|
||||
const SemVer = require('../classes/semver')
|
||||
|
||||
const inc = (version, release, options, identifier, identifierBase) => {
|
||||
if (typeof (options) === 'string') {
|
||||
identifierBase = identifier
|
||||
identifier = options
|
||||
options = undefined
|
||||
}
|
||||
|
||||
try {
|
||||
return new SemVer(
|
||||
version instanceof SemVer ? version.version : version,
|
||||
options
|
||||
).inc(release, identifier, identifierBase).version
|
||||
} catch (er) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
module.exports = inc
|
||||
@@ -0,0 +1,27 @@
|
||||
type VisitorKeys$1 = {
|
||||
readonly [type: string]: ReadonlyArray<string>;
|
||||
};
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
declare const KEYS: VisitorKeys$1;
|
||||
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {Object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
declare function getKeys(node: Object): readonly string[];
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
|
||||
|
||||
type VisitorKeys = VisitorKeys$1;
|
||||
|
||||
export { KEYS, type VisitorKeys, getKeys, unionWith };
|
||||
Reference in New Issue
Block a user