thingies
This commit is contained in:
parent
c44d00c625
commit
a561131d0c
1260 changed files with 295975 additions and 0 deletions
22
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/LICENSE
generated
vendored
Normal file
22
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
|
||||
Copyright (c) 2023-PRESENT eslint-stylistic and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
7
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/README.md
generated
vendored
Normal file
7
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# @stylistic/eslint-plugin-js
|
||||
|
||||
JavaScript stylistic rules for ESLint, migrated from [eslint core](https://github.com/eslint/eslint).
|
||||
|
||||
Credits to all contributors who have committed to the original rules.
|
||||
|
||||
Check the [documentation](https://eslint.style/packages/js) for more details.
|
||||
233
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/configs.js
generated
vendored
Normal file
233
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/configs.js
generated
vendored
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
import { p as createAllConfigs } from './utils.js';
|
||||
import arrayBracketNewline from './rules/array-bracket-newline.js';
|
||||
import arrayBracketSpacing from './rules/array-bracket-spacing.js';
|
||||
import arrayElementNewline from './rules/array-element-newline.js';
|
||||
import arrowParens from './rules/arrow-parens.js';
|
||||
import arrowSpacing from './rules/arrow-spacing.js';
|
||||
import blockSpacing from './rules/block-spacing.js';
|
||||
import braceStyle from './rules/brace-style.js';
|
||||
import commaDangle from './rules/comma-dangle.js';
|
||||
import commaSpacing from './rules/comma-spacing.js';
|
||||
import commaStyle from './rules/comma-style.js';
|
||||
import computedPropertySpacing from './rules/computed-property-spacing.js';
|
||||
import dotLocation from './rules/dot-location.js';
|
||||
import eolLast from './rules/eol-last.js';
|
||||
import functionCallArgumentNewline from './rules/function-call-argument-newline.js';
|
||||
import functionCallSpacing from './rules/function-call-spacing.js';
|
||||
import functionParenNewline from './rules/function-paren-newline.js';
|
||||
import generatorStarSpacing from './rules/generator-star-spacing.js';
|
||||
import implicitArrowLinebreak from './rules/implicit-arrow-linebreak.js';
|
||||
import indent from './rules/indent.js';
|
||||
import jsxQuotes from './rules/jsx-quotes.js';
|
||||
import keySpacing from './rules/key-spacing.js';
|
||||
import keywordSpacing from './rules/keyword-spacing.js';
|
||||
import lineCommentPosition from './rules/line-comment-position.js';
|
||||
import linebreakStyle from './rules/linebreak-style.js';
|
||||
import linesAroundComment from './rules/lines-around-comment.js';
|
||||
import linesBetweenClassMembers from './rules/lines-between-class-members.js';
|
||||
import maxLen from './rules/max-len.js';
|
||||
import maxStatementsPerLine from './rules/max-statements-per-line.js';
|
||||
import multilineCommentStyle from './rules/multiline-comment-style.js';
|
||||
import multilineTernary from './rules/multiline-ternary.js';
|
||||
import newParens from './rules/new-parens.js';
|
||||
import newlinePerChainedCall from './rules/newline-per-chained-call.js';
|
||||
import noConfusingArrow from './rules/no-confusing-arrow.js';
|
||||
import noExtraParens from './rules/no-extra-parens.js';
|
||||
import noExtraSemi from './rules/no-extra-semi.js';
|
||||
import noFloatingDecimal from './rules/no-floating-decimal.js';
|
||||
import noMixedOperators from './rules/no-mixed-operators.js';
|
||||
import noMixedSpacesAndTabs from './rules/no-mixed-spaces-and-tabs.js';
|
||||
import noMultiSpaces from './rules/no-multi-spaces.js';
|
||||
import noMultipleEmptyLines from './rules/no-multiple-empty-lines.js';
|
||||
import noTabs from './rules/no-tabs.js';
|
||||
import noTrailingSpaces from './rules/no-trailing-spaces.js';
|
||||
import noWhitespaceBeforeProperty from './rules/no-whitespace-before-property.js';
|
||||
import nonblockStatementBodyPosition from './rules/nonblock-statement-body-position.js';
|
||||
import objectCurlyNewline from './rules/object-curly-newline.js';
|
||||
import objectCurlySpacing from './rules/object-curly-spacing.js';
|
||||
import objectPropertyNewline from './rules/object-property-newline.js';
|
||||
import oneVarDeclarationPerLine from './rules/one-var-declaration-per-line.js';
|
||||
import operatorLinebreak from './rules/operator-linebreak.js';
|
||||
import paddedBlocks from './rules/padded-blocks.js';
|
||||
import paddingLineBetweenStatements from './rules/padding-line-between-statements.js';
|
||||
import quoteProps from './rules/quote-props.js';
|
||||
import quotes from './rules/quotes.js';
|
||||
import restSpreadSpacing from './rules/rest-spread-spacing.js';
|
||||
import semiSpacing from './rules/semi-spacing.js';
|
||||
import semiStyle from './rules/semi-style.js';
|
||||
import semi from './rules/semi.js';
|
||||
import spaceBeforeBlocks from './rules/space-before-blocks.js';
|
||||
import spaceBeforeFunctionParen from './rules/space-before-function-paren.js';
|
||||
import spaceInParens from './rules/space-in-parens.js';
|
||||
import spaceInfixOps from './rules/space-infix-ops.js';
|
||||
import spaceUnaryOps from './rules/space-unary-ops.js';
|
||||
import spacedComment from './rules/spaced-comment.js';
|
||||
import switchColonSpacing from './rules/switch-colon-spacing.js';
|
||||
import templateCurlySpacing from './rules/template-curly-spacing.js';
|
||||
import templateTagSpacing from './rules/template-tag-spacing.js';
|
||||
import wrapIife from './rules/wrap-iife.js';
|
||||
import wrapRegex from './rules/wrap-regex.js';
|
||||
import yieldStarSpacing from './rules/yield-star-spacing.js';
|
||||
|
||||
var rules = {
|
||||
"array-bracket-newline": arrayBracketNewline,
|
||||
"array-bracket-spacing": arrayBracketSpacing,
|
||||
"array-element-newline": arrayElementNewline,
|
||||
"arrow-parens": arrowParens,
|
||||
"arrow-spacing": arrowSpacing,
|
||||
"block-spacing": blockSpacing,
|
||||
"brace-style": braceStyle,
|
||||
"comma-dangle": commaDangle,
|
||||
"comma-spacing": commaSpacing,
|
||||
"comma-style": commaStyle,
|
||||
"computed-property-spacing": computedPropertySpacing,
|
||||
"dot-location": dotLocation,
|
||||
"eol-last": eolLast,
|
||||
"func-call-spacing": functionCallSpacing,
|
||||
"function-call-argument-newline": functionCallArgumentNewline,
|
||||
"function-call-spacing": functionCallSpacing,
|
||||
"function-paren-newline": functionParenNewline,
|
||||
"generator-star-spacing": generatorStarSpacing,
|
||||
"implicit-arrow-linebreak": implicitArrowLinebreak,
|
||||
"indent": indent,
|
||||
"jsx-quotes": jsxQuotes,
|
||||
"key-spacing": keySpacing,
|
||||
"keyword-spacing": keywordSpacing,
|
||||
"line-comment-position": lineCommentPosition,
|
||||
"linebreak-style": linebreakStyle,
|
||||
"lines-around-comment": linesAroundComment,
|
||||
"lines-between-class-members": linesBetweenClassMembers,
|
||||
"max-len": maxLen,
|
||||
"max-statements-per-line": maxStatementsPerLine,
|
||||
"multiline-comment-style": multilineCommentStyle,
|
||||
"multiline-ternary": multilineTernary,
|
||||
"new-parens": newParens,
|
||||
"newline-per-chained-call": newlinePerChainedCall,
|
||||
"no-confusing-arrow": noConfusingArrow,
|
||||
"no-extra-parens": noExtraParens,
|
||||
"no-extra-semi": noExtraSemi,
|
||||
"no-floating-decimal": noFloatingDecimal,
|
||||
"no-mixed-operators": noMixedOperators,
|
||||
"no-mixed-spaces-and-tabs": noMixedSpacesAndTabs,
|
||||
"no-multi-spaces": noMultiSpaces,
|
||||
"no-multiple-empty-lines": noMultipleEmptyLines,
|
||||
"no-tabs": noTabs,
|
||||
"no-trailing-spaces": noTrailingSpaces,
|
||||
"no-whitespace-before-property": noWhitespaceBeforeProperty,
|
||||
"nonblock-statement-body-position": nonblockStatementBodyPosition,
|
||||
"object-curly-newline": objectCurlyNewline,
|
||||
"object-curly-spacing": objectCurlySpacing,
|
||||
"object-property-newline": objectPropertyNewline,
|
||||
"one-var-declaration-per-line": oneVarDeclarationPerLine,
|
||||
"operator-linebreak": operatorLinebreak,
|
||||
"padded-blocks": paddedBlocks,
|
||||
"padding-line-between-statements": paddingLineBetweenStatements,
|
||||
"quote-props": quoteProps,
|
||||
"quotes": quotes,
|
||||
"rest-spread-spacing": restSpreadSpacing,
|
||||
"semi": semi,
|
||||
"semi-spacing": semiSpacing,
|
||||
"semi-style": semiStyle,
|
||||
"space-before-blocks": spaceBeforeBlocks,
|
||||
"space-before-function-paren": spaceBeforeFunctionParen,
|
||||
"space-in-parens": spaceInParens,
|
||||
"space-infix-ops": spaceInfixOps,
|
||||
"space-unary-ops": spaceUnaryOps,
|
||||
"spaced-comment": spacedComment,
|
||||
"switch-colon-spacing": switchColonSpacing,
|
||||
"template-curly-spacing": templateCurlySpacing,
|
||||
"template-tag-spacing": templateTagSpacing,
|
||||
"wrap-iife": wrapIife,
|
||||
"wrap-regex": wrapRegex,
|
||||
"yield-star-spacing": yieldStarSpacing
|
||||
};
|
||||
|
||||
var plugin = {
|
||||
rules
|
||||
};
|
||||
|
||||
const config = {
|
||||
rules: {
|
||||
"array-bracket-newline": 0,
|
||||
"array-bracket-spacing": 0,
|
||||
"array-element-newline": 0,
|
||||
"arrow-parens": 0,
|
||||
"arrow-spacing": 0,
|
||||
"block-spacing": 0,
|
||||
"brace-style": 0,
|
||||
"comma-dangle": 0,
|
||||
"comma-spacing": 0,
|
||||
"comma-style": 0,
|
||||
"computed-property-spacing": 0,
|
||||
"dot-location": 0,
|
||||
"eol-last": 0,
|
||||
"func-call-spacing": 0,
|
||||
"function-call-argument-newline": 0,
|
||||
"function-paren-newline": 0,
|
||||
"generator-star-spacing": 0,
|
||||
"implicit-arrow-linebreak": 0,
|
||||
"indent": 0,
|
||||
"jsx-quotes": 0,
|
||||
"key-spacing": 0,
|
||||
"keyword-spacing": 0,
|
||||
"line-comment-position": 0,
|
||||
"linebreak-style": 0,
|
||||
"lines-around-comment": 0,
|
||||
"lines-between-class-members": 0,
|
||||
"max-len": 0,
|
||||
"max-statements-per-line": 0,
|
||||
"multiline-comment-style": 0,
|
||||
"multiline-ternary": 0,
|
||||
"new-parens": 0,
|
||||
"newline-per-chained-call": 0,
|
||||
"no-confusing-arrow": 0,
|
||||
"no-extra-parens": 0,
|
||||
"no-extra-semi": 0,
|
||||
"no-floating-decimal": 0,
|
||||
"no-mixed-operators": 0,
|
||||
"no-mixed-spaces-and-tabs": 0,
|
||||
"no-multi-spaces": 0,
|
||||
"no-multiple-empty-lines": 0,
|
||||
"no-tabs": 0,
|
||||
"no-trailing-spaces": 0,
|
||||
"no-whitespace-before-property": 0,
|
||||
"nonblock-statement-body-position": 0,
|
||||
"object-curly-newline": 0,
|
||||
"object-curly-spacing": 0,
|
||||
"object-property-newline": 0,
|
||||
"one-var-declaration-per-line": 0,
|
||||
"operator-linebreak": 0,
|
||||
"padded-blocks": 0,
|
||||
"padding-line-between-statements": 0,
|
||||
"quote-props": 0,
|
||||
"quotes": 0,
|
||||
"rest-spread-spacing": 0,
|
||||
"semi": 0,
|
||||
"semi-spacing": 0,
|
||||
"semi-style": 0,
|
||||
"space-before-blocks": 0,
|
||||
"space-before-function-paren": 0,
|
||||
"space-in-parens": 0,
|
||||
"space-infix-ops": 0,
|
||||
"space-unary-ops": 0,
|
||||
"spaced-comment": 0,
|
||||
"switch-colon-spacing": 0,
|
||||
"template-curly-spacing": 0,
|
||||
"template-tag-spacing": 0,
|
||||
"wrap-iife": 0,
|
||||
"wrap-regex": 0,
|
||||
"yield-star-spacing": 0
|
||||
}
|
||||
};
|
||||
|
||||
const all = /* @__PURE__ */ createAllConfigs(plugin, "@stylistic/js");
|
||||
const configs = {
|
||||
"disable-legacy": config,
|
||||
all,
|
||||
/**
|
||||
* @deprecated use `all` instead.
|
||||
*/
|
||||
"all-flat": all
|
||||
};
|
||||
|
||||
export { configs as c, plugin as p };
|
||||
5
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/dts/define-config-support.d.ts
generated
vendored
Normal file
5
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/dts/define-config-support.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { RuleOptions } from './rule-options.js';
|
||||
|
||||
declare module 'eslint-define-config' {
|
||||
export interface CustomRuleOptions extends RuleOptions {}
|
||||
}
|
||||
32
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/dts/index.d.ts
generated
vendored
Normal file
32
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/dts/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { Rule, Linter } from 'eslint';
|
||||
import { UnprefixedRuleOptions } from './rule-options.js';
|
||||
export { RuleOptions } from './rule-options.js';
|
||||
|
||||
type Rules = {
|
||||
[K in keyof UnprefixedRuleOptions]: Rule.RuleModule
|
||||
}
|
||||
|
||||
declare const plugin: {
|
||||
rules: Rules
|
||||
configs: {
|
||||
/**
|
||||
* Disable all legacy rules from `eslint`
|
||||
*
|
||||
* This config works for both flat and legacy config format
|
||||
*/
|
||||
'disable-legacy': Linter.Config
|
||||
/**
|
||||
* Enable all rules, in Flat Config Format
|
||||
*/
|
||||
'all': Linter.Config
|
||||
/**
|
||||
* Enable all rules, in Flat Config Format
|
||||
*
|
||||
* @deprecated use `all` instead
|
||||
*/
|
||||
'all-flat': Linter.Config
|
||||
}
|
||||
}
|
||||
|
||||
export { UnprefixedRuleOptions, plugin as default };
|
||||
export type { Rules };
|
||||
2207
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/dts/rule-options.d.ts
generated
vendored
Normal file
2207
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/dts/rule-options.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
79
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/index.js
generated
vendored
Normal file
79
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import { p as plugin, c as configs } from './configs.js';
|
||||
import './utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
import './rules/array-bracket-newline.js';
|
||||
import './rules/array-bracket-spacing.js';
|
||||
import './rules/array-element-newline.js';
|
||||
import './rules/arrow-parens.js';
|
||||
import './rules/arrow-spacing.js';
|
||||
import './rules/block-spacing.js';
|
||||
import './rules/brace-style.js';
|
||||
import './rules/comma-dangle.js';
|
||||
import './rules/comma-spacing.js';
|
||||
import './rules/comma-style.js';
|
||||
import './rules/computed-property-spacing.js';
|
||||
import './rules/dot-location.js';
|
||||
import './rules/eol-last.js';
|
||||
import './rules/function-call-argument-newline.js';
|
||||
import './rules/function-call-spacing.js';
|
||||
import './rules/function-paren-newline.js';
|
||||
import './rules/generator-star-spacing.js';
|
||||
import './rules/implicit-arrow-linebreak.js';
|
||||
import './rules/indent.js';
|
||||
import './rules/jsx-quotes.js';
|
||||
import './rules/key-spacing.js';
|
||||
import './rules/keyword-spacing.js';
|
||||
import './rules/line-comment-position.js';
|
||||
import './rules/linebreak-style.js';
|
||||
import './rules/lines-around-comment.js';
|
||||
import './rules/lines-between-class-members.js';
|
||||
import './rules/max-len.js';
|
||||
import './rules/max-statements-per-line.js';
|
||||
import './rules/multiline-comment-style.js';
|
||||
import './rules/multiline-ternary.js';
|
||||
import './rules/new-parens.js';
|
||||
import './rules/newline-per-chained-call.js';
|
||||
import './rules/no-confusing-arrow.js';
|
||||
import './rules/no-extra-parens.js';
|
||||
import './rules/no-extra-semi.js';
|
||||
import './rules/no-floating-decimal.js';
|
||||
import './rules/no-mixed-operators.js';
|
||||
import './rules/no-mixed-spaces-and-tabs.js';
|
||||
import './rules/no-multi-spaces.js';
|
||||
import './rules/no-multiple-empty-lines.js';
|
||||
import './rules/no-tabs.js';
|
||||
import './rules/no-trailing-spaces.js';
|
||||
import './rules/no-whitespace-before-property.js';
|
||||
import './rules/nonblock-statement-body-position.js';
|
||||
import './rules/object-curly-newline.js';
|
||||
import './rules/object-curly-spacing.js';
|
||||
import './rules/object-property-newline.js';
|
||||
import './rules/one-var-declaration-per-line.js';
|
||||
import './rules/operator-linebreak.js';
|
||||
import './rules/padded-blocks.js';
|
||||
import './rules/padding-line-between-statements.js';
|
||||
import './rules/quote-props.js';
|
||||
import './rules/quotes.js';
|
||||
import './rules/rest-spread-spacing.js';
|
||||
import './rules/semi-spacing.js';
|
||||
import './rules/semi-style.js';
|
||||
import './rules/semi.js';
|
||||
import './rules/space-before-blocks.js';
|
||||
import './rules/space-before-function-paren.js';
|
||||
import './rules/space-in-parens.js';
|
||||
import './rules/space-infix-ops.js';
|
||||
import './rules/space-unary-ops.js';
|
||||
import './rules/spaced-comment.js';
|
||||
import './vendor.js';
|
||||
import './rules/switch-colon-spacing.js';
|
||||
import './rules/template-curly-spacing.js';
|
||||
import './rules/template-tag-spacing.js';
|
||||
import './rules/wrap-iife.js';
|
||||
import './rules/wrap-regex.js';
|
||||
import './rules/yield-star-spacing.js';
|
||||
|
||||
const index = Object.assign(plugin, { configs });
|
||||
console.log("[@stylistic/eslint-plugin-js] This package is deprecated in favor of the unified @stylistic/eslint-plugin, please consider migrating to the main package");
|
||||
|
||||
export { index as default, index as "module.exports" };
|
||||
149
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/array-bracket-newline.js
generated
vendored
Normal file
149
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/array-bracket-newline.js
generated
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
import { c as createRule, i as isTokenOnSameLine, a as isCommentToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var arrayBracketNewline = createRule({
|
||||
name: "array-bracket-newline",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce linebreaks after opening and before closing array brackets"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never", "consistent"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
multiline: {
|
||||
type: "boolean"
|
||||
},
|
||||
minItems: {
|
||||
type: ["integer", "null"],
|
||||
minimum: 0
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedOpeningLinebreak: "There should be no linebreak after '['.",
|
||||
unexpectedClosingLinebreak: "There should be no linebreak before ']'.",
|
||||
missingOpeningLinebreak: "A linebreak is required after '['.",
|
||||
missingClosingLinebreak: "A linebreak is required before ']'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
function normalizeOptionValue(option) {
|
||||
let consistent = false;
|
||||
let multiline = false;
|
||||
let minItems = 0;
|
||||
if (option) {
|
||||
if (option === "consistent") {
|
||||
consistent = true;
|
||||
minItems = Number.POSITIVE_INFINITY;
|
||||
} else if (option === "always" || typeof option !== "string" && option.minItems === 0) {
|
||||
minItems = 0;
|
||||
} else if (option === "never") {
|
||||
minItems = Number.POSITIVE_INFINITY;
|
||||
} else {
|
||||
multiline = Boolean(option.multiline);
|
||||
minItems = option.minItems || Number.POSITIVE_INFINITY;
|
||||
}
|
||||
} else {
|
||||
consistent = false;
|
||||
multiline = true;
|
||||
minItems = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
return { consistent, multiline, minItems };
|
||||
}
|
||||
function normalizeOptions(options) {
|
||||
const value = normalizeOptionValue(options);
|
||||
return { ArrayExpression: value, ArrayPattern: value };
|
||||
}
|
||||
function reportNoBeginningLinebreak(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "unexpectedOpeningLinebreak",
|
||||
fix(fixer) {
|
||||
const nextToken = sourceCode.getTokenAfter(token, { includeComments: true });
|
||||
if (!nextToken || isCommentToken(nextToken))
|
||||
return null;
|
||||
return fixer.removeRange([token.range[1], nextToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportNoEndingLinebreak(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "unexpectedClosingLinebreak",
|
||||
fix(fixer) {
|
||||
const previousToken = sourceCode.getTokenBefore(token, { includeComments: true });
|
||||
if (!previousToken || isCommentToken(previousToken))
|
||||
return null;
|
||||
return fixer.removeRange([previousToken.range[1], token.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredBeginningLinebreak(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingOpeningLinebreak",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredEndingLinebreak(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingClosingLinebreak",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(token, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
function check(node) {
|
||||
const elements = node.elements;
|
||||
const normalizedOptions = normalizeOptions(context.options[0]);
|
||||
const options = normalizedOptions[node.type];
|
||||
const openBracket = sourceCode.getFirstToken(node);
|
||||
const closeBracket = sourceCode.getLastToken(node);
|
||||
const firstIncComment = sourceCode.getTokenAfter(openBracket, { includeComments: true });
|
||||
const lastIncComment = sourceCode.getTokenBefore(closeBracket, { includeComments: true });
|
||||
const first = sourceCode.getTokenAfter(openBracket);
|
||||
const last = sourceCode.getTokenBefore(closeBracket);
|
||||
const needsLinebreaks = elements.length >= options.minItems || options.multiline && elements.length > 0 && firstIncComment.loc.start.line !== lastIncComment.loc.end.line || elements.length === 0 && firstIncComment.type === "Block" && firstIncComment.loc.start.line !== lastIncComment.loc.end.line && firstIncComment === lastIncComment || options.consistent && openBracket.loc.end.line !== first.loc.start.line;
|
||||
if (needsLinebreaks) {
|
||||
if (isTokenOnSameLine(openBracket, first))
|
||||
reportRequiredBeginningLinebreak(node, openBracket);
|
||||
if (isTokenOnSameLine(last, closeBracket))
|
||||
reportRequiredEndingLinebreak(node, closeBracket);
|
||||
} else {
|
||||
if (!isTokenOnSameLine(openBracket, first))
|
||||
reportNoBeginningLinebreak(node, openBracket);
|
||||
if (!isTokenOnSameLine(last, closeBracket))
|
||||
reportNoEndingLinebreak(node, closeBracket);
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrayPattern: check,
|
||||
ArrayExpression: check
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { arrayBracketNewline as default };
|
||||
145
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/array-bracket-spacing.js
generated
vendored
Normal file
145
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/array-bracket-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
import { c as createRule, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var arrayBracketSpacing = createRule({
|
||||
name: "array-bracket-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing inside array brackets"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
singleValue: {
|
||||
type: "boolean"
|
||||
},
|
||||
objectsInArrays: {
|
||||
type: "boolean"
|
||||
},
|
||||
arraysInArrays: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
|
||||
unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
|
||||
missingSpaceAfter: "A space is required after '{{tokenValue}}'.",
|
||||
missingSpaceBefore: "A space is required before '{{tokenValue}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const spaced = context.options[0] === "always";
|
||||
const sourceCode = context.sourceCode;
|
||||
function isOptionSet(option) {
|
||||
return context.options[1] ? context.options[1][option] === !spaced : false;
|
||||
}
|
||||
const options = {
|
||||
spaced,
|
||||
singleElementException: isOptionSet("singleValue"),
|
||||
objectsInArraysException: isOptionSet("objectsInArrays"),
|
||||
arraysInArraysException: isOptionSet("arraysInArrays")
|
||||
};
|
||||
function reportNoBeginningSpace(node, token) {
|
||||
const nextToken = sourceCode.getTokenAfter(token);
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: token.loc.end, end: nextToken.loc.start },
|
||||
messageId: "unexpectedSpaceAfter",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([token.range[1], nextToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportNoEndingSpace(node, token) {
|
||||
const previousToken = sourceCode.getTokenBefore(token);
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: previousToken.loc.end, end: token.loc.start },
|
||||
messageId: "unexpectedSpaceBefore",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([previousToken.range[1], token.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredBeginningSpace(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingSpaceAfter",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredEndingSpace(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingSpaceBefore",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
function isObjectType(node) {
|
||||
return node && (node.type === "ObjectExpression" || node.type === "ObjectPattern");
|
||||
}
|
||||
function isArrayType(node) {
|
||||
return node && (node.type === "ArrayExpression" || node.type === "ArrayPattern");
|
||||
}
|
||||
function validateArraySpacing(node) {
|
||||
if (options.spaced && node.elements.length === 0)
|
||||
return;
|
||||
const first = sourceCode.getFirstToken(node);
|
||||
const second = sourceCode.getFirstToken(node, 1);
|
||||
const last = node.type === "ArrayPattern" && node.typeAnnotation ? sourceCode.getTokenBefore(node.typeAnnotation) : sourceCode.getLastToken(node);
|
||||
const penultimate = sourceCode.getTokenBefore(last);
|
||||
const firstElement = node.elements[0];
|
||||
const lastElement = node.elements[node.elements.length - 1];
|
||||
const openingBracketMustBeSpaced = firstElement && options.objectsInArraysException && isObjectType(firstElement) || firstElement && options.arraysInArraysException && isArrayType(firstElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
|
||||
const closingBracketMustBeSpaced = lastElement && options.objectsInArraysException && isObjectType(lastElement) || lastElement && options.arraysInArraysException && isArrayType(lastElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
|
||||
if (isTokenOnSameLine(first, second)) {
|
||||
if (openingBracketMustBeSpaced && !sourceCode.isSpaceBetween(first, second))
|
||||
reportRequiredBeginningSpace(node, first);
|
||||
if (!openingBracketMustBeSpaced && sourceCode.isSpaceBetween(first, second))
|
||||
reportNoBeginningSpace(node, first);
|
||||
}
|
||||
if (first !== penultimate && isTokenOnSameLine(penultimate, last)) {
|
||||
if (closingBracketMustBeSpaced && !sourceCode.isSpaceBetween(penultimate, last))
|
||||
reportRequiredEndingSpace(node, last);
|
||||
if (!closingBracketMustBeSpaced && sourceCode.isSpaceBetween(penultimate, last))
|
||||
reportNoEndingSpace(node, last);
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrayPattern: validateArraySpacing,
|
||||
ArrayExpression: validateArraySpacing
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { arrayBracketSpacing as default };
|
||||
182
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/array-element-newline.js
generated
vendored
Normal file
182
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/array-element-newline.js
generated
vendored
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
import { c as createRule, b as isCommaToken, i as isTokenOnSameLine, a as isCommentToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var arrayElementNewline = createRule({
|
||||
name: "array-element-newline",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce line breaks after each array element"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: {
|
||||
definitions: {
|
||||
basicConfig: {
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never", "consistent"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
consistent: {
|
||||
type: "boolean"
|
||||
},
|
||||
multiline: {
|
||||
type: "boolean"
|
||||
},
|
||||
minItems: {
|
||||
type: ["integer", "null"],
|
||||
minimum: 0
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
$ref: "#/definitions/basicConfig"
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
ArrayExpression: {
|
||||
$ref: "#/definitions/basicConfig"
|
||||
},
|
||||
ArrayPattern: {
|
||||
$ref: "#/definitions/basicConfig"
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
minProperties: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
messages: {
|
||||
unexpectedLineBreak: "There should be no linebreak here.",
|
||||
missingLineBreak: "There should be a linebreak after this element."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
function normalizeOptionValue(providedOption) {
|
||||
let consistent = false;
|
||||
let multiline = false;
|
||||
let minItems;
|
||||
const option = providedOption || "always";
|
||||
if (option === "always" || typeof option === "object" && option.minItems === 0) {
|
||||
minItems = 0;
|
||||
} else if (option === "never") {
|
||||
minItems = Number.POSITIVE_INFINITY;
|
||||
} else if (option === "consistent") {
|
||||
consistent = true;
|
||||
minItems = Number.POSITIVE_INFINITY;
|
||||
} else {
|
||||
consistent = Boolean(option.consistent);
|
||||
multiline = Boolean(option.multiline);
|
||||
minItems = option.minItems || Number.POSITIVE_INFINITY;
|
||||
}
|
||||
return { consistent, multiline, minItems };
|
||||
}
|
||||
function normalizeOptions(options) {
|
||||
if (options && (options.ArrayExpression || options.ArrayPattern)) {
|
||||
let expressionOptions, patternOptions;
|
||||
if (options.ArrayExpression)
|
||||
expressionOptions = normalizeOptionValue(options.ArrayExpression);
|
||||
if (options.ArrayPattern)
|
||||
patternOptions = normalizeOptionValue(options.ArrayPattern);
|
||||
return { ArrayExpression: expressionOptions, ArrayPattern: patternOptions };
|
||||
}
|
||||
const value = normalizeOptionValue(options);
|
||||
return { ArrayExpression: value, ArrayPattern: value };
|
||||
}
|
||||
function reportNoLineBreak(token) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true });
|
||||
context.report({
|
||||
loc: {
|
||||
start: tokenBefore.loc.end,
|
||||
end: token.loc.start
|
||||
},
|
||||
messageId: "unexpectedLineBreak",
|
||||
fix(fixer) {
|
||||
if (isCommentToken(tokenBefore))
|
||||
return null;
|
||||
if (!isTokenOnSameLine(tokenBefore, token))
|
||||
return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ");
|
||||
const twoTokensBefore = sourceCode.getTokenBefore(tokenBefore, { includeComments: true });
|
||||
if (isCommentToken(twoTokensBefore))
|
||||
return null;
|
||||
return fixer.replaceTextRange([twoTokensBefore.range[1], tokenBefore.range[0]], "");
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredLineBreak(token) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true });
|
||||
context.report({
|
||||
loc: {
|
||||
start: tokenBefore.loc.end,
|
||||
end: token.loc.start
|
||||
},
|
||||
messageId: "missingLineBreak",
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
function check(node) {
|
||||
const elements = node.elements;
|
||||
const normalizedOptions = normalizeOptions(context.options[0]);
|
||||
const options = normalizedOptions[node.type];
|
||||
if (!options)
|
||||
return;
|
||||
let elementBreak = false;
|
||||
if (options.multiline) {
|
||||
elementBreak = elements.filter((element) => element !== null).some((element) => element.loc.start.line !== element.loc.end.line);
|
||||
}
|
||||
let linebreaksCount = 0;
|
||||
for (let i = 0; i < node.elements.length; i++) {
|
||||
const element = node.elements[i];
|
||||
const previousElement = elements[i - 1];
|
||||
if (i === 0 || element === null || previousElement === null)
|
||||
continue;
|
||||
const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, isCommaToken);
|
||||
const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
|
||||
const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
|
||||
if (!isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement))
|
||||
linebreaksCount++;
|
||||
}
|
||||
const needsLinebreaks = elements.length >= options.minItems || options.multiline && elementBreak || options.consistent && linebreaksCount > 0 && linebreaksCount < node.elements.length;
|
||||
elements.forEach((element, i) => {
|
||||
const previousElement = elements[i - 1];
|
||||
if (i === 0 || element === null || previousElement === null)
|
||||
return;
|
||||
const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, isCommaToken);
|
||||
const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
|
||||
const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
|
||||
if (needsLinebreaks) {
|
||||
if (isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement))
|
||||
reportRequiredLineBreak(firstTokenOfCurrentElement);
|
||||
} else {
|
||||
if (!isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement))
|
||||
reportNoLineBreak(firstTokenOfCurrentElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
ArrayPattern: check,
|
||||
ArrayExpression: check
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { arrayElementNewline as default };
|
||||
99
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/arrow-parens.js
generated
vendored
Normal file
99
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/arrow-parens.js
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
import { c as createRule, d as canTokensBeAdjacent, e as isOpeningParenToken, f as isClosingParenToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
function hasBlockBody(node) {
|
||||
return node.body.type === "BlockStatement";
|
||||
}
|
||||
var arrowParens = createRule({
|
||||
name: "arrow-parens",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require parentheses around arrow function arguments"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "as-needed"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
requireForBlockBody: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedParens: "Unexpected parentheses around single function argument.",
|
||||
expectedParens: "Expected parentheses around arrow function argument.",
|
||||
unexpectedParensInline: "Unexpected parentheses around single function argument having a body with no curly braces.",
|
||||
expectedParensBlock: "Expected parentheses around arrow function argument having a body with curly braces."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const asNeeded = context.options[0] === "as-needed";
|
||||
const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true;
|
||||
const sourceCode = context.sourceCode;
|
||||
function findOpeningParenOfParams(node) {
|
||||
const tokenBeforeParams = sourceCode.getTokenBefore(node.params[0]);
|
||||
if (tokenBeforeParams && isOpeningParenToken(tokenBeforeParams) && node.range[0] <= tokenBeforeParams.range[0]) {
|
||||
return tokenBeforeParams;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getClosingParenOfParams(node) {
|
||||
return sourceCode.getTokenAfter(node.params[0], isClosingParenToken);
|
||||
}
|
||||
function hasCommentsInParensOfParams(node, openingParen) {
|
||||
return sourceCode.commentsExistBetween(openingParen, getClosingParenOfParams(node));
|
||||
}
|
||||
function hasUnexpectedTokensBeforeOpeningParen(node, openingParen) {
|
||||
const expectedCount = node.async ? 1 : 0;
|
||||
return sourceCode.getFirstToken(node, { skip: expectedCount }) !== openingParen;
|
||||
}
|
||||
return {
|
||||
"ArrowFunctionExpression[params.length=1]": function(node) {
|
||||
const shouldHaveParens = !asNeeded || requireForBlockBody && hasBlockBody(node);
|
||||
const openingParen = findOpeningParenOfParams(node);
|
||||
const hasParens = openingParen !== null;
|
||||
const [param] = node.params;
|
||||
if (shouldHaveParens && !hasParens) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: requireForBlockBody ? "expectedParensBlock" : "expectedParens",
|
||||
loc: param.loc,
|
||||
*fix(fixer) {
|
||||
yield fixer.insertTextBefore(param, "(");
|
||||
yield fixer.insertTextAfter(param, ")");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!shouldHaveParens && hasParens && param.type === "Identifier" && !param.optional && !param.typeAnnotation && !node.returnType && !hasCommentsInParensOfParams(node, openingParen) && !hasUnexpectedTokensBeforeOpeningParen(node, openingParen)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: requireForBlockBody ? "unexpectedParensInline" : "unexpectedParens",
|
||||
loc: param.loc,
|
||||
*fix(fixer) {
|
||||
const tokenBeforeOpeningParen = sourceCode.getTokenBefore(openingParen);
|
||||
const closingParen = getClosingParenOfParams(node);
|
||||
if (tokenBeforeOpeningParen && tokenBeforeOpeningParen.range[1] === openingParen.range[0] && !canTokensBeAdjacent(tokenBeforeOpeningParen, sourceCode.getFirstToken(param))) {
|
||||
yield fixer.insertTextBefore(openingParen, " ");
|
||||
}
|
||||
yield fixer.removeRange([openingParen.range[0], param.range[0]]);
|
||||
yield fixer.removeRange([param.range[1], closingParen.range[1]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { arrowParens as default };
|
||||
107
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/arrow-spacing.js
generated
vendored
Normal file
107
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/arrow-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
import { c as createRule, g as isArrowToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var arrowSpacing = createRule({
|
||||
name: "arrow-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after the arrow in arrow functions"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
},
|
||||
after: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expectedBefore: "Missing space before =>.",
|
||||
unexpectedBefore: "Unexpected space before =>.",
|
||||
expectedAfter: "Missing space after =>.",
|
||||
unexpectedAfter: "Unexpected space after =>."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const rule = Object.assign({}, context.options[0]);
|
||||
rule.before = rule.before !== false;
|
||||
rule.after = rule.after !== false;
|
||||
const sourceCode = context.sourceCode;
|
||||
function getTokens(node) {
|
||||
const arrow = sourceCode.getTokenBefore(node.body, isArrowToken);
|
||||
return {
|
||||
before: sourceCode.getTokenBefore(arrow),
|
||||
arrow,
|
||||
after: sourceCode.getTokenAfter(arrow)
|
||||
};
|
||||
}
|
||||
function countSpaces(tokens) {
|
||||
const before = tokens.arrow.range[0] - tokens.before.range[1];
|
||||
const after = tokens.after.range[0] - tokens.arrow.range[1];
|
||||
return { before, after };
|
||||
}
|
||||
function spaces(node) {
|
||||
const tokens = getTokens(node);
|
||||
const countSpace = countSpaces(tokens);
|
||||
if (rule.before) {
|
||||
if (countSpace.before === 0) {
|
||||
context.report({
|
||||
node: tokens.before,
|
||||
messageId: "expectedBefore",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(tokens.arrow, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (countSpace.before > 0) {
|
||||
context.report({
|
||||
node: tokens.before,
|
||||
messageId: "unexpectedBefore",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (rule.after) {
|
||||
if (countSpace.after === 0) {
|
||||
context.report({
|
||||
node: tokens.after,
|
||||
messageId: "expectedAfter",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(tokens.arrow, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (countSpace.after > 0) {
|
||||
context.report({
|
||||
node: tokens.after,
|
||||
messageId: "unexpectedAfter",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrowFunctionExpression: spaces
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { arrowSpacing as default };
|
||||
104
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/block-spacing.js
generated
vendored
Normal file
104
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/block-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import { c as createRule, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var blockSpacing = createRule({
|
||||
name: "block-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow or enforce spaces inside of blocks after opening block and before closing block"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{ type: "string", enum: ["always", "never"] }
|
||||
],
|
||||
messages: {
|
||||
missing: "Requires a space {{location}} '{{token}}'.",
|
||||
extra: "Unexpected space(s) {{location}} '{{token}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const always = context.options[0] !== "never";
|
||||
const messageId = always ? "missing" : "extra";
|
||||
const sourceCode = context.sourceCode;
|
||||
function getOpenBrace(node) {
|
||||
if (node.type === "SwitchStatement") {
|
||||
if (node.cases.length > 0)
|
||||
return sourceCode.getTokenBefore(node.cases[0]);
|
||||
return sourceCode.getLastToken(node, 1);
|
||||
}
|
||||
if (node.type === "StaticBlock")
|
||||
return sourceCode.getFirstToken(node, { skip: 1 });
|
||||
return sourceCode.getFirstToken(node);
|
||||
}
|
||||
function isValid(left, right) {
|
||||
return !isTokenOnSameLine(left, right) || sourceCode.isSpaceBetween(left, right) === always;
|
||||
}
|
||||
function checkSpacingInsideBraces(node) {
|
||||
const openBrace = getOpenBrace(node);
|
||||
const closeBrace = sourceCode.getLastToken(node);
|
||||
const firstToken = sourceCode.getTokenAfter(openBrace, { includeComments: true });
|
||||
const lastToken = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
|
||||
if (openBrace.type !== "Punctuator" || openBrace.value !== "{" || closeBrace.type !== "Punctuator" || closeBrace.value !== "}" || firstToken === closeBrace) {
|
||||
return;
|
||||
}
|
||||
if (!always && firstToken.type === "Line")
|
||||
return;
|
||||
if (!isValid(openBrace, firstToken)) {
|
||||
let loc = openBrace.loc;
|
||||
if (messageId === "extra") {
|
||||
loc = {
|
||||
start: openBrace.loc.end,
|
||||
end: firstToken.loc.start
|
||||
};
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId,
|
||||
data: {
|
||||
location: "after",
|
||||
token: openBrace.value
|
||||
},
|
||||
fix(fixer) {
|
||||
if (always)
|
||||
return fixer.insertTextBefore(firstToken, " ");
|
||||
return fixer.removeRange([openBrace.range[1], firstToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!isValid(lastToken, closeBrace)) {
|
||||
let loc = closeBrace.loc;
|
||||
if (messageId === "extra") {
|
||||
loc = {
|
||||
start: lastToken.loc.end,
|
||||
end: closeBrace.loc.start
|
||||
};
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId,
|
||||
data: {
|
||||
location: "before",
|
||||
token: closeBrace.value
|
||||
},
|
||||
fix(fixer) {
|
||||
if (always)
|
||||
return fixer.insertTextAfter(lastToken, " ");
|
||||
return fixer.removeRange([lastToken.range[1], closeBrace.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
BlockStatement: checkSpacingInsideBraces,
|
||||
StaticBlock: checkSpacingInsideBraces,
|
||||
SwitchStatement: checkSpacingInsideBraces
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { blockSpacing as default };
|
||||
139
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/brace-style.js
generated
vendored
Normal file
139
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/brace-style.js
generated
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
import { c as createRule, S as STATEMENT_LIST_PARENTS, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var braceStyle = createRule({
|
||||
name: "brace-style",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent brace style for blocks"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["1tbs", "stroustrup", "allman"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowSingleLine: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
fixable: "whitespace",
|
||||
messages: {
|
||||
nextLineOpen: "Opening curly brace does not appear on the same line as controlling statement.",
|
||||
sameLineOpen: "Opening curly brace appears on the same line as controlling statement.",
|
||||
blockSameLine: "Statement inside of curly braces should be on next line.",
|
||||
nextLineClose: "Closing curly brace does not appear on the same line as the subsequent block.",
|
||||
singleLineClose: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.",
|
||||
sameLineClose: "Closing curly brace appears on the same line as the subsequent block."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const style = context.options[0] || "1tbs";
|
||||
const params = context.options[1] || {};
|
||||
const sourceCode = context.sourceCode;
|
||||
function removeNewlineBetween(firstToken, secondToken) {
|
||||
const textRange = [firstToken.range[1], secondToken.range[0]];
|
||||
const textBetween = sourceCode.text.slice(textRange[0], textRange[1]);
|
||||
if (textBetween.trim())
|
||||
return null;
|
||||
return (fixer) => fixer.replaceTextRange(textRange, " ");
|
||||
}
|
||||
function validateCurlyPair(openingCurly, closingCurly) {
|
||||
const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly);
|
||||
const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly);
|
||||
const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly);
|
||||
const singleLineException = params.allowSingleLine && isTokenOnSameLine(openingCurly, closingCurly);
|
||||
if (style !== "allman" && !isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) {
|
||||
context.report({
|
||||
node: openingCurly,
|
||||
messageId: "nextLineOpen",
|
||||
fix: removeNewlineBetween(
|
||||
tokenBeforeOpeningCurly,
|
||||
openingCurly
|
||||
)
|
||||
});
|
||||
}
|
||||
if (style === "allman" && isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) {
|
||||
context.report({
|
||||
node: openingCurly,
|
||||
messageId: "sameLineOpen",
|
||||
fix: (fixer) => fixer.insertTextBefore(openingCurly, "\n")
|
||||
});
|
||||
}
|
||||
if (isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly) && tokenAfterOpeningCurly !== closingCurly && !singleLineException) {
|
||||
context.report({
|
||||
node: openingCurly,
|
||||
messageId: "blockSameLine",
|
||||
fix: (fixer) => fixer.insertTextAfter(openingCurly, "\n")
|
||||
});
|
||||
}
|
||||
if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly)) {
|
||||
context.report({
|
||||
node: closingCurly,
|
||||
messageId: "singleLineClose",
|
||||
fix: (fixer) => fixer.insertTextBefore(closingCurly, "\n")
|
||||
});
|
||||
}
|
||||
}
|
||||
function validateCurlyBeforeKeyword(curlyToken) {
|
||||
const keywordToken = sourceCode.getTokenAfter(curlyToken);
|
||||
if (style === "1tbs" && !isTokenOnSameLine(curlyToken, keywordToken)) {
|
||||
context.report({
|
||||
node: curlyToken,
|
||||
messageId: "nextLineClose",
|
||||
fix: removeNewlineBetween(curlyToken, keywordToken)
|
||||
});
|
||||
}
|
||||
if (style !== "1tbs" && isTokenOnSameLine(curlyToken, keywordToken)) {
|
||||
context.report({
|
||||
node: curlyToken,
|
||||
messageId: "sameLineClose",
|
||||
fix: (fixer) => fixer.insertTextAfter(curlyToken, "\n")
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
BlockStatement(node) {
|
||||
if (!STATEMENT_LIST_PARENTS.has(node.parent.type))
|
||||
validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
|
||||
},
|
||||
StaticBlock(node) {
|
||||
validateCurlyPair(
|
||||
sourceCode.getFirstToken(node, { skip: 1 }),
|
||||
// skip the `static` token
|
||||
sourceCode.getLastToken(node)
|
||||
);
|
||||
},
|
||||
ClassBody(node) {
|
||||
validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
|
||||
},
|
||||
SwitchStatement(node) {
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
const openingCurly = sourceCode.getTokenBefore(node.cases.length ? node.cases[0] : closingCurly);
|
||||
validateCurlyPair(openingCurly, closingCurly);
|
||||
},
|
||||
IfStatement(node) {
|
||||
if (node.consequent.type === "BlockStatement" && node.alternate) {
|
||||
validateCurlyBeforeKeyword(sourceCode.getLastToken(node.consequent));
|
||||
}
|
||||
},
|
||||
TryStatement(node) {
|
||||
validateCurlyBeforeKeyword(sourceCode.getLastToken(node.block));
|
||||
if (node.handler && node.finalizer) {
|
||||
validateCurlyBeforeKeyword(sourceCode.getLastToken(node.handler.body));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { braceStyle as default };
|
||||
302
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/comma-dangle.js
generated
vendored
Normal file
302
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/comma-dangle.js
generated
vendored
Normal file
|
|
@ -0,0 +1,302 @@
|
|||
import { c as createRule, b as isCommaToken, h as getNextLocation } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const DEFAULT_OPTIONS = Object.freeze({
|
||||
arrays: "never",
|
||||
objects: "never",
|
||||
imports: "never",
|
||||
exports: "never",
|
||||
functions: "never",
|
||||
importAttributes: "never",
|
||||
dynamicImports: "never"
|
||||
});
|
||||
const closeBraces = ["}", "]", ")", ">"];
|
||||
function isTrailingCommaAllowed(lastItem) {
|
||||
return lastItem.type !== "RestElement";
|
||||
}
|
||||
function normalizeOptions(optionValue, ecmaVersion) {
|
||||
if (typeof optionValue === "string") {
|
||||
return {
|
||||
arrays: optionValue,
|
||||
objects: optionValue,
|
||||
imports: optionValue,
|
||||
exports: optionValue,
|
||||
functions: !ecmaVersion || ecmaVersion === "latest" ? optionValue : ecmaVersion < 2017 ? "ignore" : optionValue,
|
||||
importAttributes: optionValue,
|
||||
dynamicImports: !ecmaVersion || ecmaVersion === "latest" ? optionValue : ecmaVersion < 2025 ? "ignore" : optionValue
|
||||
};
|
||||
}
|
||||
if (typeof optionValue === "object" && optionValue !== null) {
|
||||
return {
|
||||
arrays: optionValue.arrays || DEFAULT_OPTIONS.arrays,
|
||||
objects: optionValue.objects || DEFAULT_OPTIONS.objects,
|
||||
imports: optionValue.imports || DEFAULT_OPTIONS.imports,
|
||||
exports: optionValue.exports || DEFAULT_OPTIONS.exports,
|
||||
functions: optionValue.functions || DEFAULT_OPTIONS.functions,
|
||||
importAttributes: optionValue.importAttributes || DEFAULT_OPTIONS.importAttributes,
|
||||
dynamicImports: optionValue.dynamicImports || DEFAULT_OPTIONS.dynamicImports
|
||||
};
|
||||
}
|
||||
return DEFAULT_OPTIONS;
|
||||
}
|
||||
var commaDangle = createRule({
|
||||
name: "comma-dangle",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow trailing commas"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: {
|
||||
definitions: {
|
||||
value: {
|
||||
type: "string",
|
||||
enum: [
|
||||
"always-multiline",
|
||||
"always",
|
||||
"never",
|
||||
"only-multiline"
|
||||
]
|
||||
},
|
||||
valueWithIgnore: {
|
||||
type: "string",
|
||||
enum: [
|
||||
"always-multiline",
|
||||
"always",
|
||||
"ignore",
|
||||
"never",
|
||||
"only-multiline"
|
||||
]
|
||||
}
|
||||
},
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
$ref: "#/definitions/value"
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
arrays: { $ref: "#/definitions/valueWithIgnore" },
|
||||
objects: { $ref: "#/definitions/valueWithIgnore" },
|
||||
imports: { $ref: "#/definitions/valueWithIgnore" },
|
||||
exports: { $ref: "#/definitions/valueWithIgnore" },
|
||||
functions: { $ref: "#/definitions/valueWithIgnore" },
|
||||
importAttributes: { $ref: "#/definitions/valueWithIgnore" },
|
||||
dynamicImports: { $ref: "#/definitions/valueWithIgnore" }
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
additionalItems: false
|
||||
},
|
||||
messages: {
|
||||
unexpected: "Unexpected trailing comma.",
|
||||
missing: "Missing trailing comma."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const ecmaVersion = context?.languageOptions?.ecmaVersion ?? context.parserOptions.ecmaVersion;
|
||||
const options = normalizeOptions(context.options[0], ecmaVersion);
|
||||
const sourceCode = context.sourceCode;
|
||||
function last(array) {
|
||||
if (!array)
|
||||
return null;
|
||||
return array[array.length - 1] ?? null;
|
||||
}
|
||||
function getTrailingToken(info) {
|
||||
switch (info.node.type) {
|
||||
case "ObjectExpression":
|
||||
case "ArrayExpression":
|
||||
case "CallExpression":
|
||||
case "NewExpression":
|
||||
case "ImportExpression":
|
||||
return sourceCode.getLastToken(info.node, 1);
|
||||
default: {
|
||||
const lastItem = info.lastItem;
|
||||
if (!lastItem)
|
||||
return null;
|
||||
const nextToken = sourceCode.getTokenAfter(lastItem);
|
||||
if (isCommaToken(nextToken))
|
||||
return nextToken;
|
||||
return sourceCode.getLastToken(lastItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
function isMultiline(info) {
|
||||
const lastItem = info.lastItem;
|
||||
if (!lastItem)
|
||||
return false;
|
||||
const penultimateToken = getTrailingToken(info);
|
||||
if (!penultimateToken)
|
||||
return false;
|
||||
const lastToken = sourceCode.getTokenAfter(penultimateToken);
|
||||
if (!lastToken)
|
||||
return false;
|
||||
return lastToken.loc.end.line !== penultimateToken.loc.end.line;
|
||||
}
|
||||
function forbidTrailingComma(info) {
|
||||
const lastItem = info.lastItem;
|
||||
if (!lastItem)
|
||||
return;
|
||||
const trailingToken = getTrailingToken(info);
|
||||
if (trailingToken && isCommaToken(trailingToken)) {
|
||||
context.report({
|
||||
node: lastItem,
|
||||
loc: trailingToken.loc,
|
||||
messageId: "unexpected",
|
||||
*fix(fixer) {
|
||||
yield fixer.remove(trailingToken);
|
||||
yield fixer.insertTextBefore(sourceCode.getTokenBefore(trailingToken), "");
|
||||
yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), "");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function forceTrailingComma(info) {
|
||||
const lastItem = info.lastItem;
|
||||
if (!lastItem)
|
||||
return;
|
||||
if (!isTrailingCommaAllowed(lastItem)) {
|
||||
forbidTrailingComma(info);
|
||||
return;
|
||||
}
|
||||
const trailingToken = getTrailingToken(info);
|
||||
if (!trailingToken || trailingToken.value === ",")
|
||||
return;
|
||||
const nextToken = sourceCode.getTokenAfter(trailingToken);
|
||||
if (!nextToken || !closeBraces.includes(nextToken.value))
|
||||
return;
|
||||
context.report({
|
||||
node: lastItem,
|
||||
loc: {
|
||||
start: trailingToken.loc.end,
|
||||
end: getNextLocation(sourceCode, trailingToken.loc.end)
|
||||
},
|
||||
messageId: "missing",
|
||||
*fix(fixer) {
|
||||
yield fixer.insertTextAfter(trailingToken, ",");
|
||||
yield fixer.insertTextBefore(trailingToken, "");
|
||||
yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), "");
|
||||
}
|
||||
});
|
||||
}
|
||||
function forceTrailingCommaIfMultiline(info) {
|
||||
if (isMultiline(info))
|
||||
forceTrailingComma(info);
|
||||
else
|
||||
forbidTrailingComma(info);
|
||||
}
|
||||
function allowTrailingCommaIfMultiline(info) {
|
||||
if (!isMultiline(info))
|
||||
forbidTrailingComma(info);
|
||||
}
|
||||
const predicate = {
|
||||
"always": forceTrailingComma,
|
||||
"always-multiline": forceTrailingCommaIfMultiline,
|
||||
"only-multiline": allowTrailingCommaIfMultiline,
|
||||
"never": forbidTrailingComma,
|
||||
ignore() {
|
||||
}
|
||||
};
|
||||
return {
|
||||
ObjectExpression: (node) => {
|
||||
predicate[options.objects]({
|
||||
node,
|
||||
lastItem: last(node.properties)
|
||||
});
|
||||
},
|
||||
ObjectPattern: (node) => {
|
||||
predicate[options.objects]({
|
||||
node,
|
||||
lastItem: last(node.properties)
|
||||
});
|
||||
},
|
||||
ArrayExpression: (node) => {
|
||||
predicate[options.arrays]({
|
||||
node,
|
||||
lastItem: last(node.elements)
|
||||
});
|
||||
},
|
||||
ArrayPattern: (node) => {
|
||||
predicate[options.arrays]({
|
||||
node,
|
||||
lastItem: last(node.elements)
|
||||
});
|
||||
},
|
||||
ImportDeclaration: (node) => {
|
||||
const lastSpecifier = last(node.specifiers);
|
||||
if (lastSpecifier?.type === "ImportSpecifier") {
|
||||
predicate[options.imports]({
|
||||
node,
|
||||
lastItem: lastSpecifier
|
||||
});
|
||||
}
|
||||
predicate[options.importAttributes]({
|
||||
node,
|
||||
lastItem: last(node.attributes)
|
||||
});
|
||||
},
|
||||
ExportNamedDeclaration: (node) => {
|
||||
predicate[options.exports]({
|
||||
node,
|
||||
lastItem: last(node.specifiers)
|
||||
});
|
||||
predicate[options.importAttributes]({
|
||||
node,
|
||||
lastItem: last(node.attributes)
|
||||
});
|
||||
},
|
||||
ExportAllDeclaration: (node) => {
|
||||
predicate[options.importAttributes]({
|
||||
node,
|
||||
lastItem: last(node.attributes)
|
||||
});
|
||||
},
|
||||
FunctionDeclaration: (node) => {
|
||||
predicate[options.functions]({
|
||||
node,
|
||||
lastItem: last(node.params)
|
||||
});
|
||||
},
|
||||
FunctionExpression: (node) => {
|
||||
predicate[options.functions]({
|
||||
node,
|
||||
lastItem: last(node.params)
|
||||
});
|
||||
},
|
||||
ArrowFunctionExpression: (node) => {
|
||||
predicate[options.functions]({
|
||||
node,
|
||||
lastItem: last(node.params)
|
||||
});
|
||||
},
|
||||
CallExpression: (node) => {
|
||||
predicate[options.functions]({
|
||||
node,
|
||||
lastItem: last(node.arguments)
|
||||
});
|
||||
},
|
||||
NewExpression: (node) => {
|
||||
predicate[options.functions]({
|
||||
node,
|
||||
lastItem: last(node.arguments)
|
||||
});
|
||||
},
|
||||
ImportExpression: (node) => {
|
||||
predicate[options.dynamicImports]({
|
||||
node,
|
||||
lastItem: node.options ?? node.source
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { commaDangle as default };
|
||||
104
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/comma-spacing.js
generated
vendored
Normal file
104
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/comma-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import { c as createRule, b as isCommaToken, i as isTokenOnSameLine, f as isClosingParenToken, j as isClosingBracketToken, k as isClosingBraceToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var commaSpacing = createRule({
|
||||
name: "comma-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after commas"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
after: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missing: "A space is required {{loc}} ','.",
|
||||
unexpected: "There should be no space {{loc}} ','."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const tokensAndComments = sourceCode.tokensAndComments;
|
||||
const options = {
|
||||
before: context.options[0] ? context.options[0].before : false,
|
||||
after: context.options[0] ? context.options[0].after : true
|
||||
};
|
||||
const commaTokensToIgnore = [];
|
||||
function report(node, loc, otherNode) {
|
||||
context.report({
|
||||
node,
|
||||
fix(fixer) {
|
||||
if (options[loc]) {
|
||||
if (loc === "before")
|
||||
return fixer.insertTextBefore(node, " ");
|
||||
return fixer.insertTextAfter(node, " ");
|
||||
}
|
||||
let start, end;
|
||||
const newText = "";
|
||||
if (loc === "before") {
|
||||
start = otherNode.range[1];
|
||||
end = node.range[0];
|
||||
} else {
|
||||
start = node.range[1];
|
||||
end = otherNode.range[0];
|
||||
}
|
||||
return fixer.replaceTextRange([start, end], newText);
|
||||
},
|
||||
messageId: options[loc] ? "missing" : "unexpected",
|
||||
data: {
|
||||
loc
|
||||
}
|
||||
});
|
||||
}
|
||||
function addNullElementsToIgnoreList(node) {
|
||||
let previousToken = sourceCode.getFirstToken(node);
|
||||
node.elements.forEach((element) => {
|
||||
let token;
|
||||
if (element === null) {
|
||||
token = sourceCode.getTokenAfter(previousToken);
|
||||
if (isCommaToken(token))
|
||||
commaTokensToIgnore.push(token);
|
||||
} else {
|
||||
token = sourceCode.getTokenAfter(element);
|
||||
}
|
||||
previousToken = token;
|
||||
});
|
||||
}
|
||||
return {
|
||||
"Program:exit": function() {
|
||||
tokensAndComments.forEach((token, i) => {
|
||||
if (!isCommaToken(token))
|
||||
return;
|
||||
const previousToken = tokensAndComments[i - 1];
|
||||
const nextToken = tokensAndComments[i + 1];
|
||||
if (previousToken && !isCommaToken(previousToken) && !commaTokensToIgnore.includes(token) && isTokenOnSameLine(previousToken, token) && options.before !== sourceCode.isSpaceBetween(previousToken, token)) {
|
||||
report(token, "before", previousToken);
|
||||
}
|
||||
if (nextToken && !isCommaToken(nextToken) && !isClosingParenToken(nextToken) && !isClosingBracketToken(nextToken) && !isClosingBraceToken(nextToken) && !(!options.after && nextToken.type === "Line") && isTokenOnSameLine(token, nextToken) && options.after !== sourceCode.isSpaceBetween(token, nextToken)) {
|
||||
report(token, "after", nextToken);
|
||||
}
|
||||
});
|
||||
},
|
||||
"ArrayExpression": addNullElementsToIgnoreList,
|
||||
"ArrayPattern": addNullElementsToIgnoreList
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { commaSpacing as default };
|
||||
288
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/comma-style.js
generated
vendored
Normal file
288
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/comma-style.js
generated
vendored
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
import { c as createRule, l as isOpeningBracketToken, b as isCommaToken, m as isNotCommaToken, i as isTokenOnSameLine, n as isNotOpeningParenToken, o as isNotClosingParenToken, L as LINEBREAK_MATCHER } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var commaStyle = createRule({
|
||||
name: "comma-style",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent comma style"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["first", "last"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptions: {
|
||||
type: "object",
|
||||
additionalProperties: {
|
||||
type: "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.",
|
||||
expectedCommaFirst: "',' should be placed first.",
|
||||
expectedCommaLast: "',' should be placed last."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const style = context.options[0] || "last";
|
||||
const sourceCode = context.sourceCode;
|
||||
const exceptions = {};
|
||||
if (context.options.length === 2 && Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
|
||||
context.options[1] ??= { exceptions: {} };
|
||||
const rawExceptions = context.options[1].exceptions;
|
||||
const keys = Object.keys(rawExceptions);
|
||||
for (let i = 0; i < keys.length; i++)
|
||||
exceptions[keys[i]] = rawExceptions[keys[i]];
|
||||
}
|
||||
function getReplacedText(styleType, text) {
|
||||
switch (styleType) {
|
||||
case "between":
|
||||
return `,${text.replace(LINEBREAK_MATCHER, "")}`;
|
||||
case "first":
|
||||
return `${text},`;
|
||||
case "last":
|
||||
return `,${text}`;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
function getFixerFunction(styleType, tokenBeforeComma, commaToken, tokenAfterComma) {
|
||||
const text = sourceCode.text.slice(tokenBeforeComma.range[1], commaToken.range[0]) + sourceCode.text.slice(commaToken.range[1], tokenAfterComma.range[0]);
|
||||
const range = [tokenBeforeComma.range[1], tokenAfterComma.range[0]];
|
||||
return function(fixer) {
|
||||
return fixer.replaceTextRange(range, getReplacedText(styleType, text));
|
||||
};
|
||||
}
|
||||
function validateCommaItemSpacing(tokenBeforeComma, commaToken, tokenAfterComma) {
|
||||
if (isTokenOnSameLine(commaToken, tokenAfterComma) && isTokenOnSameLine(tokenBeforeComma, commaToken)) ; else if (!isTokenOnSameLine(commaToken, tokenAfterComma) && !isTokenOnSameLine(tokenBeforeComma, commaToken)) {
|
||||
const comment = sourceCode.getCommentsAfter(commaToken)[0];
|
||||
const styleType = comment && comment.type === "Block" && isTokenOnSameLine(commaToken, comment) ? style : "between";
|
||||
context.report({
|
||||
node: commaToken,
|
||||
messageId: "unexpectedLineBeforeAndAfterComma",
|
||||
fix: getFixerFunction(styleType, tokenBeforeComma, commaToken, tokenAfterComma)
|
||||
});
|
||||
} else if (style === "first" && !isTokenOnSameLine(commaToken, tokenAfterComma)) {
|
||||
context.report({
|
||||
node: commaToken,
|
||||
messageId: "expectedCommaFirst",
|
||||
fix: getFixerFunction(style, tokenBeforeComma, commaToken, tokenAfterComma)
|
||||
});
|
||||
} else if (style === "last" && isTokenOnSameLine(commaToken, tokenAfterComma)) {
|
||||
context.report({
|
||||
node: commaToken,
|
||||
messageId: "expectedCommaLast",
|
||||
fix: getFixerFunction(style, tokenBeforeComma, commaToken, tokenAfterComma)
|
||||
});
|
||||
}
|
||||
}
|
||||
function extractCommaTokens(node, items) {
|
||||
if (items.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const definedItems = items.filter((item) => Boolean(item));
|
||||
if (definedItems.length === 0) {
|
||||
return sourceCode.getTokens(node).filter(isCommaToken);
|
||||
}
|
||||
const commaTokens = [];
|
||||
const firstItem = definedItems[0];
|
||||
let prevToken = sourceCode.getTokenBefore(firstItem);
|
||||
while (prevToken && node.range[0] <= prevToken.range[0]) {
|
||||
if (isCommaToken(prevToken)) {
|
||||
commaTokens.unshift(prevToken);
|
||||
} else if (isNotOpeningParenToken(prevToken)) {
|
||||
break;
|
||||
}
|
||||
prevToken = sourceCode.getTokenBefore(prevToken);
|
||||
}
|
||||
let prevItem = null;
|
||||
for (const item of definedItems) {
|
||||
if (prevItem) {
|
||||
commaTokens.push(
|
||||
...sourceCode.getTokensBetween(prevItem, item).filter(isCommaToken)
|
||||
);
|
||||
}
|
||||
const tokenLastItem = sourceCode.getLastToken(item);
|
||||
if (tokenLastItem && isCommaToken(tokenLastItem)) {
|
||||
commaTokens.push(tokenLastItem);
|
||||
}
|
||||
prevItem = item;
|
||||
}
|
||||
let nextToken = sourceCode.getTokenAfter(prevItem);
|
||||
while (nextToken && nextToken.range[1] <= node.range[1]) {
|
||||
if (isCommaToken(nextToken)) {
|
||||
commaTokens.push(nextToken);
|
||||
} else if (isNotClosingParenToken(nextToken)) {
|
||||
break;
|
||||
}
|
||||
nextToken = sourceCode.getTokenAfter(nextToken);
|
||||
}
|
||||
return commaTokens;
|
||||
}
|
||||
function validateComma(node, items) {
|
||||
const commaTokens = extractCommaTokens(node, items);
|
||||
commaTokens.forEach((commaToken) => {
|
||||
const tokenBeforeComma = sourceCode.getTokenBefore(commaToken);
|
||||
const tokenAfterComma = sourceCode.getTokenAfter(commaToken);
|
||||
if (isOpeningBracketToken(tokenBeforeComma)) {
|
||||
return;
|
||||
}
|
||||
if (isCommaToken(tokenBeforeComma) && isOpeningBracketToken(sourceCode.getTokenBefore(tokenBeforeComma, isNotCommaToken))) {
|
||||
return;
|
||||
}
|
||||
if (isCommaToken(tokenAfterComma) && !isTokenOnSameLine(commaToken, tokenAfterComma)) {
|
||||
return;
|
||||
}
|
||||
validateCommaItemSpacing(tokenBeforeComma, commaToken, tokenAfterComma);
|
||||
});
|
||||
}
|
||||
const nodes = {};
|
||||
if (!exceptions.VariableDeclaration) {
|
||||
nodes.VariableDeclaration = (node) => validateComma(node, node.declarations);
|
||||
}
|
||||
if (!exceptions.ObjectExpression) {
|
||||
nodes.ObjectExpression = validateObjectProperties;
|
||||
}
|
||||
if (!exceptions.ObjectPattern) {
|
||||
nodes.ObjectPattern = validateObjectProperties;
|
||||
}
|
||||
if (!exceptions.ArrayExpression) {
|
||||
nodes.ArrayExpression = validateArrayElements;
|
||||
}
|
||||
if (!exceptions.ArrayPattern) {
|
||||
nodes.ArrayPattern = validateArrayElements;
|
||||
}
|
||||
if (!exceptions.FunctionDeclaration) {
|
||||
nodes.FunctionDeclaration = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.FunctionExpression) {
|
||||
nodes.FunctionExpression = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.ArrowFunctionExpression) {
|
||||
nodes.ArrowFunctionExpression = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.CallExpression) {
|
||||
nodes.CallExpression = validateCallArguments;
|
||||
}
|
||||
if (!exceptions.ImportDeclaration) {
|
||||
nodes.ImportDeclaration = (node) => {
|
||||
validateComma(node, node.specifiers);
|
||||
visitImportAttributes(node);
|
||||
};
|
||||
}
|
||||
if (!exceptions.NewExpression) {
|
||||
nodes.NewExpression = validateCallArguments;
|
||||
}
|
||||
if (!exceptions.ExportAllDeclaration) {
|
||||
nodes.ExportAllDeclaration = visitImportAttributes;
|
||||
}
|
||||
if (!exceptions.ExportNamedDeclaration) {
|
||||
nodes.ExportNamedDeclaration = (node) => {
|
||||
validateComma(node, node.specifiers);
|
||||
visitImportAttributes(node);
|
||||
};
|
||||
}
|
||||
if (!exceptions.ImportExpression) {
|
||||
nodes.ImportExpression = (node) => {
|
||||
validateComma(node, [node.source, node.options ?? null]);
|
||||
};
|
||||
}
|
||||
if (!exceptions.SequenceExpression) {
|
||||
nodes.SequenceExpression = (node) => validateComma(node, node.expressions);
|
||||
}
|
||||
if (!exceptions.ClassDeclaration) {
|
||||
nodes.ClassDeclaration = visitClassImplements;
|
||||
}
|
||||
if (!exceptions.ClassExpression) {
|
||||
nodes.ClassExpression = visitClassImplements;
|
||||
}
|
||||
if (!exceptions.TSDeclareFunction) {
|
||||
nodes.TSDeclareFunction = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.TSFunctionType) {
|
||||
nodes.TSFunctionType = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.TSConstructorType) {
|
||||
nodes.TSConstructorType = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.TSEmptyBodyFunctionExpression) {
|
||||
nodes.TSEmptyBodyFunctionExpression = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.TSMethodSignature) {
|
||||
nodes.TSMethodSignature = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.TSCallSignatureDeclaration) {
|
||||
nodes.TSCallSignatureDeclaration = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.TSConstructSignatureDeclaration) {
|
||||
nodes.TSConstructSignatureDeclaration = validateFunctionParams;
|
||||
}
|
||||
if (!exceptions.TSTypeParameterDeclaration) {
|
||||
nodes.TSTypeParameterDeclaration = validateTypeParams;
|
||||
}
|
||||
if (!exceptions.TSTypeParameterInstantiation) {
|
||||
nodes.TSTypeParameterInstantiation = validateTypeParams;
|
||||
}
|
||||
if (!exceptions.TSEnumBody) {
|
||||
nodes.TSEnumBody = visitMembers;
|
||||
}
|
||||
if (!exceptions.TSTypeLiteral) {
|
||||
nodes.TSTypeLiteral = visitMembers;
|
||||
}
|
||||
if (!exceptions.TSIndexSignature) {
|
||||
nodes.TSIndexSignature = (node) => validateComma(node, node.parameters);
|
||||
}
|
||||
if (!exceptions.TSInterfaceDeclaration) {
|
||||
nodes.TSInterfaceDeclaration = (node) => validateComma(node, node.extends);
|
||||
}
|
||||
if (!exceptions.TSInterfaceBody) {
|
||||
nodes.TSInterfaceBody = (node) => validateComma(node, node.body);
|
||||
}
|
||||
if (!exceptions.TSTupleType) {
|
||||
nodes.TSTupleType = (node) => validateComma(node, node.elementTypes);
|
||||
}
|
||||
return nodes;
|
||||
function validateObjectProperties(node) {
|
||||
validateComma(node, node.properties);
|
||||
}
|
||||
function validateArrayElements(node) {
|
||||
validateComma(node, node.elements);
|
||||
}
|
||||
function validateFunctionParams(node) {
|
||||
validateComma(node, node.params);
|
||||
}
|
||||
function validateCallArguments(node) {
|
||||
validateComma(node, node.arguments);
|
||||
}
|
||||
function visitImportAttributes(node) {
|
||||
if (!node.attributes)
|
||||
return;
|
||||
validateComma(node, node.attributes);
|
||||
}
|
||||
function visitClassImplements(node) {
|
||||
if (!node.implements)
|
||||
return;
|
||||
validateComma(node, node.implements);
|
||||
}
|
||||
function visitMembers(node) {
|
||||
validateComma(node, node.members);
|
||||
}
|
||||
function validateTypeParams(node) {
|
||||
validateComma(node, node.params);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export { commaStyle as default };
|
||||
134
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/computed-property-spacing.js
generated
vendored
Normal file
134
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/computed-property-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
import { c as createRule, l as isOpeningBracketToken, j as isClosingBracketToken, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var computedPropertySpacing = createRule({
|
||||
name: "computed-property-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing inside computed property brackets"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
enforceForClassMembers: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
|
||||
unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
|
||||
missingSpaceBefore: "A space is required before '{{tokenValue}}'.",
|
||||
missingSpaceAfter: "A space is required after '{{tokenValue}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const propertyNameMustBeSpaced = context.options[0] === "always";
|
||||
const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers;
|
||||
function reportNoBeginningSpace(node, token, tokenAfter) {
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: token.loc.end, end: tokenAfter.loc.start },
|
||||
messageId: "unexpectedSpaceAfter",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportNoEndingSpace(node, token, tokenBefore) {
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: tokenBefore.loc.end, end: token.loc.start },
|
||||
messageId: "unexpectedSpaceBefore",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredBeginningSpace(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingSpaceAfter",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredEndingSpace(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingSpaceBefore",
|
||||
data: {
|
||||
tokenValue: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
function checkSpacing(propertyName) {
|
||||
return function(node) {
|
||||
if (!node.computed)
|
||||
return;
|
||||
const property = node[propertyName];
|
||||
const before = sourceCode.getTokenBefore(property, isOpeningBracketToken);
|
||||
const first = sourceCode.getTokenAfter(before, { includeComments: true });
|
||||
const after = sourceCode.getTokenAfter(property, isClosingBracketToken);
|
||||
const last = sourceCode.getTokenBefore(after, { includeComments: true });
|
||||
if (isTokenOnSameLine(before, first)) {
|
||||
if (propertyNameMustBeSpaced) {
|
||||
if (!sourceCode.isSpaceBetween(before, first) && isTokenOnSameLine(before, first))
|
||||
reportRequiredBeginningSpace(node, before);
|
||||
} else {
|
||||
if (sourceCode.isSpaceBetween(before, first))
|
||||
reportNoBeginningSpace(node, before, first);
|
||||
}
|
||||
}
|
||||
if (isTokenOnSameLine(last, after)) {
|
||||
if (propertyNameMustBeSpaced) {
|
||||
if (!sourceCode.isSpaceBetween(last, after) && isTokenOnSameLine(last, after))
|
||||
reportRequiredEndingSpace(node, after);
|
||||
} else {
|
||||
if (sourceCode.isSpaceBetween(last, after))
|
||||
reportNoEndingSpace(node, after, last);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
const listeners = {
|
||||
Property: checkSpacing("key"),
|
||||
MemberExpression: checkSpacing("property")
|
||||
};
|
||||
if (enforceForClassMembers) {
|
||||
listeners.MethodDefinition = checkSpacing("key");
|
||||
listeners.PropertyDefinition = checkSpacing("key");
|
||||
}
|
||||
return listeners;
|
||||
}
|
||||
});
|
||||
|
||||
export { computedPropertySpacing as default };
|
||||
70
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/dot-location.js
generated
vendored
Normal file
70
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/dot-location.js
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import { c as createRule, i as isTokenOnSameLine, q as isDecimalIntegerNumericToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var dotLocation = createRule({
|
||||
name: "dot-location",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent newlines before and after dots"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["object", "property"]
|
||||
}
|
||||
],
|
||||
fixable: "code",
|
||||
messages: {
|
||||
expectedDotAfterObject: "Expected dot to be on same line as object.",
|
||||
expectedDotBeforeProperty: "Expected dot to be on same line as property."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const config = context.options[0];
|
||||
const onObject = config === "object" || !config;
|
||||
const sourceCode = context.sourceCode;
|
||||
function checkDotLocation(node) {
|
||||
const property = node.property;
|
||||
const dotToken = sourceCode.getTokenBefore(property);
|
||||
if (onObject && dotToken) {
|
||||
const tokenBeforeDot = sourceCode.getTokenBefore(dotToken);
|
||||
if (tokenBeforeDot && !isTokenOnSameLine(tokenBeforeDot, dotToken)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: dotToken.loc,
|
||||
messageId: "expectedDotAfterObject",
|
||||
*fix(fixer) {
|
||||
if (dotToken.value.startsWith(".") && isDecimalIntegerNumericToken(tokenBeforeDot))
|
||||
yield fixer.insertTextAfter(tokenBeforeDot, ` ${dotToken.value}`);
|
||||
else
|
||||
yield fixer.insertTextAfter(tokenBeforeDot, dotToken.value);
|
||||
yield fixer.remove(dotToken);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (!isTokenOnSameLine(dotToken, property) && dotToken) {
|
||||
context.report({
|
||||
node,
|
||||
loc: dotToken.loc,
|
||||
messageId: "expectedDotBeforeProperty",
|
||||
*fix(fixer) {
|
||||
yield fixer.remove(dotToken);
|
||||
yield fixer.insertTextBefore(property, dotToken.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function checkNode(node) {
|
||||
if (node.type === "MemberExpression" && !node.computed)
|
||||
checkDotLocation(node);
|
||||
}
|
||||
return {
|
||||
MemberExpression: checkNode
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { dotLocation as default };
|
||||
81
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/eol-last.js
generated
vendored
Normal file
81
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/eol-last.js
generated
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var eolLast = createRule({
|
||||
name: "eol-last",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow newline at the end of files"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never", "unix", "windows"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missing: "Newline required at end of file but not found.",
|
||||
unexpected: "Newline not allowed at end of file."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
Program: function checkBadEOF(node) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const src = sourceCode.getText();
|
||||
const lastLine = sourceCode.lines[sourceCode.lines.length - 1];
|
||||
const location = {
|
||||
column: lastLine.length,
|
||||
line: sourceCode.lines.length
|
||||
};
|
||||
const LF = "\n";
|
||||
const CRLF = `\r${LF}`;
|
||||
const endsWithNewline = src.endsWith(LF);
|
||||
if (!src.length)
|
||||
return;
|
||||
let mode = context.options[0] || "always";
|
||||
let appendCRLF = false;
|
||||
if (mode === "unix") {
|
||||
mode = "always";
|
||||
}
|
||||
if (mode === "windows") {
|
||||
mode = "always";
|
||||
appendCRLF = true;
|
||||
}
|
||||
if (mode === "always" && !endsWithNewline) {
|
||||
context.report({
|
||||
node,
|
||||
loc: location,
|
||||
messageId: "missing",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfterRange([0, src.length], appendCRLF ? CRLF : LF);
|
||||
}
|
||||
});
|
||||
} else if (mode === "never" && endsWithNewline) {
|
||||
const secondLastLine = sourceCode.lines[sourceCode.lines.length - 2];
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: { line: sourceCode.lines.length - 1, column: secondLastLine.length },
|
||||
end: { line: sourceCode.lines.length, column: 0 }
|
||||
},
|
||||
messageId: "unexpected",
|
||||
fix(fixer) {
|
||||
const finalEOLs = /(?:\r?\n)+$/u;
|
||||
const match = finalEOLs.exec(sourceCode.text);
|
||||
const start = match.index;
|
||||
const end = sourceCode.text.length;
|
||||
return fixer.replaceTextRange([start, end], "");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { eolLast as default };
|
||||
90
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/function-call-argument-newline.js
generated
vendored
Normal file
90
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/function-call-argument-newline.js
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var functionCallArgumentNewline = createRule({
|
||||
name: "function-call-argument-newline",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce line breaks between arguments of a function call"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never", "consistent"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedLineBreak: "There should be no line break here.",
|
||||
missingLineBreak: "There should be a line break after this argument."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const checkers = {
|
||||
unexpected: {
|
||||
messageId: "unexpectedLineBreak",
|
||||
check: (prevToken, currentToken) => prevToken.loc.end.line !== currentToken.loc.start.line,
|
||||
createFix: (token, tokenBefore) => (fixer) => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ")
|
||||
},
|
||||
missing: {
|
||||
messageId: "missingLineBreak",
|
||||
check: (prevToken, currentToken) => prevToken.loc.end.line === currentToken.loc.start.line,
|
||||
createFix: (token, tokenBefore) => (fixer) => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n")
|
||||
}
|
||||
};
|
||||
function checkArguments(argumentNodes, checker) {
|
||||
for (let i = 1; i < argumentNodes.length; i++) {
|
||||
const argumentNode = argumentNodes[i - 1];
|
||||
const prevArgToken = sourceCode.getLastToken(argumentNode);
|
||||
const currentArgToken = sourceCode.getFirstToken(argumentNodes[i]);
|
||||
if (checker.check(prevArgToken, currentArgToken)) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(
|
||||
currentArgToken,
|
||||
{ includeComments: true }
|
||||
);
|
||||
const hasLineCommentBefore = tokenBefore.type === "Line";
|
||||
context.report({
|
||||
node: argumentNodes[i - 1],
|
||||
loc: {
|
||||
start: tokenBefore.loc.end,
|
||||
end: currentArgToken.loc.start
|
||||
},
|
||||
messageId: checker.messageId,
|
||||
fix: hasLineCommentBefore ? null : checker.createFix(currentArgToken, tokenBefore)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function check(argumentNodes) {
|
||||
if (argumentNodes.length < 2)
|
||||
return;
|
||||
const option = context.options[0] || "always";
|
||||
if (option === "never") {
|
||||
checkArguments(argumentNodes, checkers.unexpected);
|
||||
} else if (option === "always") {
|
||||
checkArguments(argumentNodes, checkers.missing);
|
||||
} else if (option === "consistent") {
|
||||
const firstArgToken = sourceCode.getLastToken(argumentNodes[0]);
|
||||
const secondArgToken = sourceCode.getFirstToken(argumentNodes[1]);
|
||||
if (firstArgToken?.loc.end.line === secondArgToken?.loc.start.line)
|
||||
checkArguments(argumentNodes, checkers.unexpected);
|
||||
else
|
||||
checkArguments(argumentNodes, checkers.missing);
|
||||
}
|
||||
}
|
||||
return {
|
||||
CallExpression: (node) => check(node.arguments),
|
||||
NewExpression: (node) => check(node.arguments),
|
||||
ImportExpression: (node) => {
|
||||
if (node.options)
|
||||
check([node.source, node.options]);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { functionCallArgumentNewline as default };
|
||||
145
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/function-call-spacing.js
generated
vendored
Normal file
145
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/function-call-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
import { c as createRule, e as isOpeningParenToken, r as isNotQuestionDotToken, L as LINEBREAK_MATCHER } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var functionCallSpacing = createRule({
|
||||
name: "function-call-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow spacing between function identifiers and their invocations"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["never"]
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 1
|
||||
},
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowNewlines: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2
|
||||
}
|
||||
]
|
||||
},
|
||||
messages: {
|
||||
unexpectedWhitespace: "Unexpected whitespace between function name and paren.",
|
||||
unexpectedNewline: "Unexpected newline between function name and paren.",
|
||||
missing: "Missing space between function name and paren."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const never = context.options[0] !== "always";
|
||||
const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines;
|
||||
const sourceCode = context.sourceCode;
|
||||
const text = sourceCode.getText();
|
||||
function checkSpacing(node, leftToken, rightToken) {
|
||||
const textBetweenTokens = text.slice(leftToken.range[1], rightToken.range[0]).replace(/\/\*.*?\*\//gu, "");
|
||||
const hasWhitespace = /\s/u.test(textBetweenTokens);
|
||||
const hasNewline = hasWhitespace && LINEBREAK_MATCHER.test(textBetweenTokens);
|
||||
if (never && hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: leftToken.loc.end,
|
||||
end: {
|
||||
line: rightToken.loc.start.line,
|
||||
column: rightToken.loc.start.column - 1
|
||||
}
|
||||
},
|
||||
messageId: "unexpectedWhitespace",
|
||||
fix(fixer) {
|
||||
if (sourceCode.commentsExistBetween(leftToken, rightToken))
|
||||
return null;
|
||||
if ("optional" in node && node.optional)
|
||||
return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], "?.");
|
||||
if (hasNewline)
|
||||
return null;
|
||||
return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
|
||||
}
|
||||
});
|
||||
} else if (!never && !hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: {
|
||||
line: leftToken.loc.end.line,
|
||||
column: leftToken.loc.end.column - 1
|
||||
},
|
||||
end: rightToken.loc.start
|
||||
},
|
||||
messageId: "missing",
|
||||
fix(fixer) {
|
||||
if ("optional" in node && node.optional)
|
||||
return null;
|
||||
return fixer.insertTextBefore(rightToken, " ");
|
||||
}
|
||||
});
|
||||
} else if (!never && !allowNewlines && hasNewline) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: leftToken.loc.end,
|
||||
end: rightToken.loc.start
|
||||
},
|
||||
messageId: "unexpectedNewline",
|
||||
fix(fixer) {
|
||||
if (!("optional" in node) || !node.optional)
|
||||
return null;
|
||||
if (sourceCode.commentsExistBetween(leftToken, rightToken))
|
||||
return null;
|
||||
const range = [leftToken.range[1], rightToken.range[0]];
|
||||
const qdToken = sourceCode.getTokenAfter(leftToken);
|
||||
if (qdToken.range[0] === leftToken.range[1])
|
||||
return fixer.replaceTextRange(range, "?. ");
|
||||
if (qdToken.range[1] === rightToken.range[0])
|
||||
return fixer.replaceTextRange(range, " ?.");
|
||||
return fixer.replaceTextRange(range, " ?. ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
"CallExpression, NewExpression": function(node) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
const lastCalleeToken = sourceCode.getLastToken(node.callee);
|
||||
const parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, isOpeningParenToken);
|
||||
const prevToken = parenToken && sourceCode.getTokenBefore(parenToken, isNotQuestionDotToken);
|
||||
if (!(parenToken && parenToken.range[1] < node.range[1]))
|
||||
return;
|
||||
checkSpacing(node, prevToken, parenToken);
|
||||
},
|
||||
ImportExpression(node) {
|
||||
const leftToken = sourceCode.getFirstToken(node);
|
||||
const rightToken = sourceCode.getTokenAfter(leftToken);
|
||||
checkSpacing(node, leftToken, rightToken);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { functionCallSpacing as default };
|
||||
196
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/function-paren-newline.js
generated
vendored
Normal file
196
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/function-paren-newline.js
generated
vendored
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
import { c as createRule, s as isFunction, i as isTokenOnSameLine, e as isOpeningParenToken, f as isClosingParenToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var functionParenNewline = createRule({
|
||||
name: "function-paren-newline",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent line breaks inside function parentheses"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never", "consistent", "multiline", "multiline-arguments"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
minItems: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expectedBefore: "Expected newline before ')'.",
|
||||
expectedAfter: "Expected newline after '('.",
|
||||
expectedBetween: "Expected newline between arguments/params.",
|
||||
unexpectedBefore: "Unexpected newline before ')'.",
|
||||
unexpectedAfter: "Unexpected newline after '('."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const rawOption = context.options[0] || "multiline";
|
||||
const multilineOption = rawOption === "multiline";
|
||||
const multilineArgumentsOption = rawOption === "multiline-arguments";
|
||||
const consistentOption = rawOption === "consistent";
|
||||
let minItems;
|
||||
if (typeof rawOption === "object")
|
||||
minItems = rawOption.minItems;
|
||||
else if (rawOption === "always")
|
||||
minItems = 0;
|
||||
else if (rawOption === "never")
|
||||
minItems = Infinity;
|
||||
function shouldHaveNewlines(elements, hasLeftNewline) {
|
||||
if (multilineArgumentsOption && elements.length === 1)
|
||||
return hasLeftNewline;
|
||||
if (multilineOption || multilineArgumentsOption)
|
||||
return elements.some((element, index) => index !== elements.length - 1 && element.loc.end.line !== elements[index + 1].loc.start.line);
|
||||
if (consistentOption)
|
||||
return hasLeftNewline;
|
||||
return minItems == null || elements.length >= minItems;
|
||||
}
|
||||
function validateParens(parens, elements) {
|
||||
const leftParen = parens.leftParen;
|
||||
const rightParen = parens.rightParen;
|
||||
const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
|
||||
const tokenBeforeRightParen = sourceCode.getTokenBefore(rightParen);
|
||||
const hasLeftNewline = !isTokenOnSameLine(leftParen, tokenAfterLeftParen);
|
||||
const hasRightNewline = !isTokenOnSameLine(tokenBeforeRightParen, rightParen);
|
||||
const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
|
||||
if (hasLeftNewline && !needsNewlines) {
|
||||
context.report({
|
||||
node: leftParen,
|
||||
messageId: "unexpectedAfter",
|
||||
fix(fixer) {
|
||||
return sourceCode.getText().slice(leftParen.range[1], tokenAfterLeftParen.range[0]).trim() ? null : fixer.removeRange([leftParen.range[1], tokenAfterLeftParen.range[0]]);
|
||||
}
|
||||
});
|
||||
} else if (!hasLeftNewline && needsNewlines) {
|
||||
context.report({
|
||||
node: leftParen,
|
||||
messageId: "expectedAfter",
|
||||
fix: (fixer) => fixer.insertTextAfter(leftParen, "\n")
|
||||
});
|
||||
}
|
||||
if (hasRightNewline && !needsNewlines) {
|
||||
context.report({
|
||||
node: rightParen,
|
||||
messageId: "unexpectedBefore",
|
||||
fix(fixer) {
|
||||
return sourceCode.getText().slice(tokenBeforeRightParen.range[1], rightParen.range[0]).trim() ? null : fixer.removeRange([tokenBeforeRightParen.range[1], rightParen.range[0]]);
|
||||
}
|
||||
});
|
||||
} else if (!hasRightNewline && needsNewlines) {
|
||||
context.report({
|
||||
node: rightParen,
|
||||
messageId: "expectedBefore",
|
||||
fix: (fixer) => fixer.insertTextBefore(rightParen, "\n")
|
||||
});
|
||||
}
|
||||
}
|
||||
function validateArguments(parens, elements) {
|
||||
const leftParen = parens.leftParen;
|
||||
const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
|
||||
const hasLeftNewline = !isTokenOnSameLine(leftParen, tokenAfterLeftParen);
|
||||
const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
|
||||
for (let i = 0; i <= elements.length - 2; i++) {
|
||||
const currentElement = elements[i];
|
||||
const nextElement = elements[i + 1];
|
||||
const hasNewLine = currentElement.loc.end.line !== nextElement.loc.start.line;
|
||||
if (!hasNewLine && needsNewlines) {
|
||||
context.report({
|
||||
node: currentElement,
|
||||
messageId: "expectedBetween",
|
||||
fix: (fixer) => fixer.insertTextBefore(nextElement, "\n")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function getParenTokens(node) {
|
||||
const isOpeningParenTokenOutsideTypeParameter = () => {
|
||||
let typeParameterOpeningLevel = 0;
|
||||
return (token) => {
|
||||
if (token.type === "Punctuator" && token.value === "<")
|
||||
typeParameterOpeningLevel += 1;
|
||||
if (token.type === "Punctuator" && token.value === ">")
|
||||
typeParameterOpeningLevel -= 1;
|
||||
return typeParameterOpeningLevel !== 0 ? false : isOpeningParenToken(token);
|
||||
};
|
||||
};
|
||||
switch (node.type) {
|
||||
case "NewExpression":
|
||||
if (!node.arguments.length && !(isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) && isClosingParenToken(sourceCode.getLastToken(node)) && node.callee.range[1] < node.range[1])) {
|
||||
return null;
|
||||
}
|
||||
// falls through
|
||||
case "CallExpression":
|
||||
return {
|
||||
leftParen: sourceCode.getTokenAfter(node.callee, isOpeningParenTokenOutsideTypeParameter()),
|
||||
rightParen: sourceCode.getLastToken(node)
|
||||
};
|
||||
case "FunctionDeclaration":
|
||||
case "FunctionExpression": {
|
||||
const leftParen = sourceCode.getFirstToken(node, isOpeningParenTokenOutsideTypeParameter());
|
||||
const rightParen = node.params.length ? sourceCode.getTokenAfter(node.params[node.params.length - 1], isClosingParenToken) : sourceCode.getTokenAfter(leftParen);
|
||||
return { leftParen, rightParen };
|
||||
}
|
||||
case "ArrowFunctionExpression": {
|
||||
const firstToken = sourceCode.getFirstToken(node, { skip: node.async ? 1 : 0 });
|
||||
if (!isOpeningParenToken(firstToken)) {
|
||||
return null;
|
||||
}
|
||||
const rightParen = node.params.length ? sourceCode.getTokenAfter(node.params[node.params.length - 1], isClosingParenToken) : sourceCode.getTokenAfter(firstToken);
|
||||
return {
|
||||
leftParen: firstToken,
|
||||
rightParen
|
||||
};
|
||||
}
|
||||
case "ImportExpression": {
|
||||
const leftParen = sourceCode.getFirstToken(node, 1);
|
||||
const rightParen = sourceCode.getLastToken(node);
|
||||
return { leftParen, rightParen };
|
||||
}
|
||||
default:
|
||||
throw new TypeError(`unexpected node with type ${node.type}`);
|
||||
}
|
||||
}
|
||||
return {
|
||||
[[
|
||||
"ArrowFunctionExpression",
|
||||
"CallExpression",
|
||||
"FunctionDeclaration",
|
||||
"FunctionExpression",
|
||||
"ImportExpression",
|
||||
"NewExpression"
|
||||
].join(", ")](node) {
|
||||
const parens = getParenTokens(node);
|
||||
let params;
|
||||
if (node.type === "ImportExpression")
|
||||
params = [node.source, ...node.options ? [node.options] : []];
|
||||
else if (isFunction(node))
|
||||
params = node.params;
|
||||
else
|
||||
params = node.arguments;
|
||||
if (parens) {
|
||||
validateParens(parens, params);
|
||||
if (multilineArgumentsOption)
|
||||
validateArguments(parens, params);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { functionParenNewline as default };
|
||||
133
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/generator-star-spacing.js
generated
vendored
Normal file
133
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/generator-star-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const OVERRIDE_SCHEMA = {
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["before", "after", "both", "neither"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean" },
|
||||
after: { type: "boolean" }
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
};
|
||||
var generatorStarSpacing = createRule({
|
||||
name: "generator-star-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing around `*` operators in generator functions"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["before", "after", "both", "neither"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean" },
|
||||
after: { type: "boolean" },
|
||||
named: OVERRIDE_SCHEMA,
|
||||
anonymous: OVERRIDE_SCHEMA,
|
||||
method: OVERRIDE_SCHEMA
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missingBefore: "Missing space before *.",
|
||||
missingAfter: "Missing space after *.",
|
||||
unexpectedBefore: "Unexpected space before *.",
|
||||
unexpectedAfter: "Unexpected space after *."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const optionDefinitions = {
|
||||
before: { before: true, after: false },
|
||||
after: { before: false, after: true },
|
||||
both: { before: true, after: true },
|
||||
neither: { before: false, after: false }
|
||||
};
|
||||
function optionToDefinition(option, defaults) {
|
||||
if (!option)
|
||||
return defaults;
|
||||
return typeof option === "string" ? optionDefinitions[option] : Object.assign({}, defaults, option);
|
||||
}
|
||||
const modes = function(option) {
|
||||
const defaults = optionToDefinition(option, optionDefinitions.before);
|
||||
return {
|
||||
named: optionToDefinition(option.named, defaults),
|
||||
anonymous: optionToDefinition(option.anonymous, defaults),
|
||||
method: optionToDefinition(option.method, defaults)
|
||||
};
|
||||
}(context.options[0] || {});
|
||||
const sourceCode = context.sourceCode;
|
||||
function isStarToken(token) {
|
||||
return token.value === "*" && token.type === "Punctuator";
|
||||
}
|
||||
function getStarToken(node) {
|
||||
return sourceCode.getFirstToken(
|
||||
"method" in node.parent && node.parent.method || node.parent.type === "MethodDefinition" ? node.parent : node,
|
||||
isStarToken
|
||||
);
|
||||
}
|
||||
function capitalize(str) {
|
||||
return str[0].toUpperCase() + str.slice(1);
|
||||
}
|
||||
function checkSpacing(kind, side, leftToken, rightToken) {
|
||||
if (!!(rightToken.range[0] - leftToken.range[1]) !== modes[kind][side]) {
|
||||
const after = leftToken.value === "*";
|
||||
const spaceRequired = modes[kind][side];
|
||||
const node = after ? leftToken : rightToken;
|
||||
const messageId = `${spaceRequired ? "missing" : "unexpected"}${capitalize(side)}`;
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
fix(fixer) {
|
||||
if (spaceRequired) {
|
||||
if (after)
|
||||
return fixer.insertTextAfter(node, " ");
|
||||
return fixer.insertTextBefore(node, " ");
|
||||
}
|
||||
return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function checkFunction(node) {
|
||||
if (!node.generator)
|
||||
return;
|
||||
const starToken = getStarToken(node);
|
||||
const prevToken = sourceCode.getTokenBefore(starToken);
|
||||
const nextToken = sourceCode.getTokenAfter(starToken);
|
||||
let kind = "named";
|
||||
if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method)
|
||||
kind = "method";
|
||||
else if (!node.id)
|
||||
kind = "anonymous";
|
||||
if (!(kind === "method" && starToken === sourceCode.getFirstToken(node.parent)))
|
||||
checkSpacing(kind, "before", prevToken, starToken);
|
||||
checkSpacing(kind, "after", starToken, nextToken);
|
||||
}
|
||||
return {
|
||||
FunctionDeclaration: checkFunction,
|
||||
FunctionExpression: checkFunction
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { generatorStarSpacing as default };
|
||||
57
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/implicit-arrow-linebreak.js
generated
vendored
Normal file
57
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/implicit-arrow-linebreak.js
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { c as createRule, n as isNotOpeningParenToken, a as isCommentToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var implicitArrowLinebreak = createRule({
|
||||
name: "implicit-arrow-linebreak",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce the location of arrow function bodies"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["beside", "below"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expected: "Expected a linebreak before this expression.",
|
||||
unexpected: "Expected no linebreak before this expression."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0] || "beside";
|
||||
function validateExpression(node) {
|
||||
if (node.body.type === "BlockStatement")
|
||||
return;
|
||||
const arrowToken = sourceCode.getTokenBefore(node.body, isNotOpeningParenToken);
|
||||
const firstTokenOfBody = sourceCode.getTokenAfter(arrowToken);
|
||||
if (arrowToken.loc.end.line === firstTokenOfBody.loc.start.line && option === "below") {
|
||||
context.report({
|
||||
node: firstTokenOfBody,
|
||||
messageId: "expected",
|
||||
fix: (fixer) => fixer.insertTextBefore(firstTokenOfBody, "\n")
|
||||
});
|
||||
} else if (arrowToken.loc.end.line !== firstTokenOfBody.loc.start.line && option === "beside") {
|
||||
context.report({
|
||||
node: firstTokenOfBody,
|
||||
messageId: "unexpected",
|
||||
fix(fixer) {
|
||||
if (sourceCode.getFirstTokenBetween(arrowToken, firstTokenOfBody, { includeComments: true, filter: isCommentToken }))
|
||||
return null;
|
||||
return fixer.replaceTextRange([arrowToken.range[1], firstTokenOfBody.range[0]], " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrowFunctionExpression: (node) => validateExpression(node)
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { implicitArrowLinebreak as default };
|
||||
1332
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/indent.js
generated
vendored
Normal file
1332
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/indent.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
66
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/jsx-quotes.js
generated
vendored
Normal file
66
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/jsx-quotes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { c as createRule, A as isStringLiteral, B as isSurroundedBy } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const QUOTE_SETTINGS = {
|
||||
"prefer-double": {
|
||||
quote: '"',
|
||||
description: "singlequote",
|
||||
convert(str) {
|
||||
return str.replace(/'/gu, '"');
|
||||
}
|
||||
},
|
||||
"prefer-single": {
|
||||
quote: "'",
|
||||
description: "doublequote",
|
||||
convert(str) {
|
||||
return str.replace(/"/gu, "'");
|
||||
}
|
||||
}
|
||||
};
|
||||
var jsxQuotes = createRule({
|
||||
name: "jsx-quotes",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce the consistent use of either double or single quotes in JSX attributes"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["prefer-single", "prefer-double"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpected: "Unexpected usage of {{description}}."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const quoteOption = context.options[0] || "prefer-double";
|
||||
const setting = QUOTE_SETTINGS[quoteOption];
|
||||
function usesExpectedQuotes(node) {
|
||||
return node.value.includes(setting.quote) || isSurroundedBy(node.raw, setting.quote);
|
||||
}
|
||||
return {
|
||||
JSXAttribute(node) {
|
||||
const attributeValue = node.value;
|
||||
if (attributeValue && isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) {
|
||||
context.report({
|
||||
node: attributeValue,
|
||||
messageId: "unexpected",
|
||||
data: {
|
||||
description: setting.description
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { jsxQuotes as default };
|
||||
512
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/key-spacing.js
generated
vendored
Normal file
512
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/key-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,512 @@
|
|||
import { c as createRule, x as isColonToken, C as getStaticPropertyName, D as getStringLength, v as isOpeningBraceToken, k as isClosingBraceToken, L as LINEBREAK_MATCHER } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const listeningNodes = [
|
||||
"ObjectExpression",
|
||||
"ObjectPattern",
|
||||
"ImportDeclaration",
|
||||
"ExportNamedDeclaration",
|
||||
"ExportAllDeclaration",
|
||||
"TSTypeLiteral",
|
||||
"TSInterfaceBody",
|
||||
"ClassBody"
|
||||
];
|
||||
function containsLineTerminator(str) {
|
||||
return LINEBREAK_MATCHER.test(str);
|
||||
}
|
||||
function last(arr) {
|
||||
return arr[arr.length - 1];
|
||||
}
|
||||
function isSingleLine(node) {
|
||||
return node.loc.end.line === node.loc.start.line;
|
||||
}
|
||||
function isSingleLineImportAttributes(node, sourceCode) {
|
||||
if (node.type === "TSImportType") {
|
||||
if ("options" in node && node.options) {
|
||||
return isSingleLine(node.options);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const openingBrace = sourceCode.getTokenBefore(node.attributes[0], isOpeningBraceToken);
|
||||
const closingBrace = sourceCode.getTokenAfter(node.attributes[node.attributes.length - 1], isClosingBraceToken);
|
||||
return closingBrace.loc.end.line === openingBrace.loc.start.line;
|
||||
}
|
||||
function isSingleLineProperties(properties) {
|
||||
const [firstProp] = properties;
|
||||
const lastProp = last(properties);
|
||||
return firstProp.loc.start.line === lastProp.loc.end.line;
|
||||
}
|
||||
function initOptionProperty(toOptions, fromOptions) {
|
||||
toOptions.mode = fromOptions.mode || "strict";
|
||||
if (typeof fromOptions.beforeColon !== "undefined")
|
||||
toOptions.beforeColon = +fromOptions.beforeColon;
|
||||
else
|
||||
toOptions.beforeColon = 0;
|
||||
if (typeof fromOptions.afterColon !== "undefined")
|
||||
toOptions.afterColon = +fromOptions.afterColon;
|
||||
else
|
||||
toOptions.afterColon = 1;
|
||||
if (typeof fromOptions.align !== "undefined") {
|
||||
if (typeof fromOptions.align === "object") {
|
||||
toOptions.align = fromOptions.align;
|
||||
} else {
|
||||
toOptions.align = {
|
||||
on: fromOptions.align,
|
||||
mode: toOptions.mode,
|
||||
beforeColon: toOptions.beforeColon,
|
||||
afterColon: toOptions.afterColon
|
||||
};
|
||||
}
|
||||
}
|
||||
return toOptions;
|
||||
}
|
||||
function initOptions(toOptions, fromOptions) {
|
||||
if (typeof fromOptions.align === "object") {
|
||||
toOptions.align = initOptionProperty({}, fromOptions.align);
|
||||
toOptions.align.on = fromOptions.align.on || "colon";
|
||||
toOptions.align.mode = fromOptions.align.mode || "strict";
|
||||
toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
|
||||
toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions);
|
||||
} else {
|
||||
toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
|
||||
toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions);
|
||||
if (toOptions.multiLine.align) {
|
||||
toOptions.align = {
|
||||
on: toOptions.multiLine.align.on,
|
||||
mode: toOptions.multiLine.align.mode || toOptions.multiLine.mode,
|
||||
beforeColon: toOptions.multiLine.align.beforeColon,
|
||||
afterColon: toOptions.multiLine.align.afterColon
|
||||
};
|
||||
}
|
||||
}
|
||||
toOptions.ignoredNodes = fromOptions.ignoredNodes || [];
|
||||
return toOptions;
|
||||
}
|
||||
var keySpacing = createRule({
|
||||
name: "key-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing between keys and values in object literal properties"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [{
|
||||
anyOf: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
align: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["colon", "value"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
on: {
|
||||
type: "string",
|
||||
enum: ["colon", "value"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
},
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
ignoredNodes: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
enum: listeningNodes
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
singleLine: {
|
||||
type: "object",
|
||||
properties: {
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
multiLine: {
|
||||
type: "object",
|
||||
properties: {
|
||||
align: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["colon", "value"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
on: {
|
||||
type: "string",
|
||||
enum: ["colon", "value"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
},
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
singleLine: {
|
||||
type: "object",
|
||||
properties: {
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
multiLine: {
|
||||
type: "object",
|
||||
properties: {
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
align: {
|
||||
type: "object",
|
||||
properties: {
|
||||
mode: {
|
||||
type: "string",
|
||||
enum: ["strict", "minimum"]
|
||||
},
|
||||
on: {
|
||||
type: "string",
|
||||
enum: ["colon", "value"]
|
||||
},
|
||||
beforeColon: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterColon: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}],
|
||||
messages: {
|
||||
extraKey: "Extra space after {{computed}}key '{{key}}'.",
|
||||
extraValue: "Extra space before value for {{computed}}key '{{key}}'.",
|
||||
missingKey: "Missing space after {{computed}}key '{{key}}'.",
|
||||
missingValue: "Missing space before value for {{computed}}key '{{key}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = context.options[0] || {};
|
||||
const ruleOptions = initOptions({}, options);
|
||||
const multiLineOptions = ruleOptions.multiLine;
|
||||
const singleLineOptions = ruleOptions.singleLine;
|
||||
const alignmentOptions = ruleOptions.align || null;
|
||||
const ignoredNodes = ruleOptions.ignoredNodes;
|
||||
const sourceCode = context.sourceCode;
|
||||
function isKeyValueProperty(property) {
|
||||
if (property.type === "ImportAttribute")
|
||||
return true;
|
||||
return !("method" in property && property.method || "shorthand" in property && property.shorthand || "kind" in property && property.kind !== "init" || property.type !== "Property");
|
||||
}
|
||||
function getNextColon(node) {
|
||||
return sourceCode.getTokenAfter(node, isColonToken);
|
||||
}
|
||||
function getLastTokenBeforeColon(node) {
|
||||
const colonToken = getNextColon(node);
|
||||
return sourceCode.getTokenBefore(colonToken);
|
||||
}
|
||||
function getFirstTokenAfterColon(node) {
|
||||
const colonToken = getNextColon(node);
|
||||
return sourceCode.getTokenAfter(colonToken);
|
||||
}
|
||||
function continuesPropertyGroup(lastMember, candidate) {
|
||||
const groupEndLine = lastMember.loc.start.line;
|
||||
const candidateValueStartLine = (isKeyValueProperty(candidate) ? getFirstTokenAfterColon(candidate.key) : candidate).loc.start.line;
|
||||
if (candidateValueStartLine - groupEndLine <= 1)
|
||||
return true;
|
||||
const leadingComments = sourceCode.getCommentsBefore(candidate);
|
||||
if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateValueStartLine - last(leadingComments).loc.end.line <= 1) {
|
||||
for (let i = 1; i < leadingComments.length; i++) {
|
||||
if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getKey(property) {
|
||||
const key = property.key;
|
||||
if (property.type !== "ImportAttribute" && property.computed)
|
||||
return sourceCode.getText().slice(key.range[0], key.range[1]);
|
||||
return getStaticPropertyName(property);
|
||||
}
|
||||
function report(property, side, whitespace, expected, mode) {
|
||||
const diff = whitespace.length - expected;
|
||||
if ((diff && mode === "strict" || diff < 0 && mode === "minimum" || diff > 0 && !expected && mode === "minimum") && !(expected && containsLineTerminator(whitespace))) {
|
||||
const nextColon = getNextColon(property.key);
|
||||
const tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: true });
|
||||
const tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: true });
|
||||
const isKeySide = side === "key";
|
||||
const isExtra = diff > 0;
|
||||
const diffAbs = Math.abs(diff);
|
||||
const spaces = new Array(diffAbs + 1).join(" ");
|
||||
const locStart = isKeySide ? tokenBeforeColon.loc.end : nextColon.loc.start;
|
||||
const locEnd = isKeySide ? nextColon.loc.start : tokenAfterColon.loc.start;
|
||||
const missingLoc = isKeySide ? tokenBeforeColon.loc : tokenAfterColon.loc;
|
||||
const loc = isExtra ? { start: locStart, end: locEnd } : missingLoc;
|
||||
let fix;
|
||||
if (isExtra) {
|
||||
let range;
|
||||
if (isKeySide)
|
||||
range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs];
|
||||
else
|
||||
range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]];
|
||||
fix = function(fixer) {
|
||||
return fixer.removeRange(range);
|
||||
};
|
||||
} else {
|
||||
if (isKeySide) {
|
||||
fix = function(fixer) {
|
||||
return fixer.insertTextAfter(tokenBeforeColon, spaces);
|
||||
};
|
||||
} else {
|
||||
fix = function(fixer) {
|
||||
return fixer.insertTextBefore(tokenAfterColon, spaces);
|
||||
};
|
||||
}
|
||||
}
|
||||
let messageId;
|
||||
if (isExtra)
|
||||
messageId = side === "key" ? "extraKey" : "extraValue";
|
||||
else
|
||||
messageId = side === "key" ? "missingKey" : "missingValue";
|
||||
context.report({
|
||||
node: property[side],
|
||||
loc,
|
||||
messageId,
|
||||
data: {
|
||||
computed: property.type !== "ImportAttribute" && property.computed ? "computed " : "",
|
||||
key: getKey(property)
|
||||
},
|
||||
fix
|
||||
});
|
||||
}
|
||||
}
|
||||
function getKeyWidth(property) {
|
||||
const startToken = sourceCode.getFirstToken(property);
|
||||
const endToken = getLastTokenBeforeColon(property.key);
|
||||
return getStringLength(sourceCode.getText().slice(startToken.range[0], endToken.range[1]));
|
||||
}
|
||||
function getPropertyWhitespace(property) {
|
||||
const whitespace = /(\s*):(\s*)/u.exec(sourceCode.getText().slice(
|
||||
property.key.range[1],
|
||||
property.value.range[0]
|
||||
));
|
||||
if (whitespace) {
|
||||
return {
|
||||
beforeColon: whitespace[1],
|
||||
afterColon: whitespace[2]
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function createGroups(properties) {
|
||||
if (properties.length === 1)
|
||||
return [properties];
|
||||
return properties.reduce((groups, property) => {
|
||||
const currentGroup = last(groups);
|
||||
const prev = last(currentGroup);
|
||||
if (!prev || continuesPropertyGroup(prev, property))
|
||||
currentGroup.push(property);
|
||||
else
|
||||
groups.push([property]);
|
||||
return groups;
|
||||
}, [
|
||||
[]
|
||||
]);
|
||||
}
|
||||
function verifyGroupAlignment(properties) {
|
||||
const length = properties.length;
|
||||
const widths = properties.map(getKeyWidth);
|
||||
const align = alignmentOptions.on;
|
||||
let targetWidth = Math.max(...widths);
|
||||
let beforeColon;
|
||||
let afterColon;
|
||||
let mode;
|
||||
if (alignmentOptions && length > 1) {
|
||||
beforeColon = alignmentOptions.beforeColon;
|
||||
afterColon = alignmentOptions.afterColon;
|
||||
mode = alignmentOptions.mode;
|
||||
} else {
|
||||
beforeColon = multiLineOptions.beforeColon;
|
||||
afterColon = multiLineOptions.afterColon;
|
||||
mode = alignmentOptions.mode;
|
||||
}
|
||||
targetWidth += align === "colon" ? beforeColon : afterColon;
|
||||
for (let i = 0; i < length; i++) {
|
||||
const property = properties[i];
|
||||
const whitespace = getPropertyWhitespace(property);
|
||||
if (whitespace) {
|
||||
const width = widths[i];
|
||||
if (align === "value") {
|
||||
report(property, "key", whitespace.beforeColon, beforeColon, mode);
|
||||
report(property, "value", whitespace.afterColon, targetWidth - width, mode);
|
||||
} else {
|
||||
report(property, "key", whitespace.beforeColon, targetWidth - width, mode);
|
||||
report(property, "value", whitespace.afterColon, afterColon, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function verifySpacing(node, lineOptions) {
|
||||
if (ignoredNodes.includes(node.parent.type))
|
||||
return;
|
||||
const actual = getPropertyWhitespace(node);
|
||||
if (actual) {
|
||||
report(node, "key", actual.beforeColon, lineOptions.beforeColon, lineOptions.mode);
|
||||
report(node, "value", actual.afterColon, lineOptions.afterColon, lineOptions.mode);
|
||||
}
|
||||
}
|
||||
function verifyListSpacing(properties, lineOptions) {
|
||||
const length = properties.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
verifySpacing(properties[i], lineOptions);
|
||||
}
|
||||
function verifyAlignment(properties) {
|
||||
createGroups(properties).forEach((group) => {
|
||||
const properties2 = group.filter(isKeyValueProperty);
|
||||
if (properties2.length > 0 && isSingleLineProperties(properties2))
|
||||
verifyListSpacing(properties2, multiLineOptions);
|
||||
else
|
||||
verifyGroupAlignment(properties2);
|
||||
});
|
||||
}
|
||||
function verifyImportAttributes(node) {
|
||||
if (ignoredNodes.includes(node.type))
|
||||
return;
|
||||
if (!node.attributes)
|
||||
return;
|
||||
if (!node.attributes.length)
|
||||
return;
|
||||
if (isSingleLineImportAttributes(node, sourceCode))
|
||||
verifyListSpacing(node.attributes, singleLineOptions);
|
||||
else
|
||||
verifyAlignment(node.attributes);
|
||||
}
|
||||
if (alignmentOptions) {
|
||||
return {
|
||||
ObjectExpression(node) {
|
||||
if (ignoredNodes.includes(node.type))
|
||||
return;
|
||||
if (isSingleLine(node))
|
||||
verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions);
|
||||
else
|
||||
verifyAlignment(node.properties);
|
||||
},
|
||||
ImportDeclaration(node) {
|
||||
verifyImportAttributes(node);
|
||||
},
|
||||
ExportNamedDeclaration(node) {
|
||||
verifyImportAttributes(node);
|
||||
},
|
||||
ExportAllDeclaration(node) {
|
||||
verifyImportAttributes(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
Property(node) {
|
||||
verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
|
||||
},
|
||||
ImportAttribute(node) {
|
||||
const parent = node.parent;
|
||||
verifySpacing(node, isSingleLineImportAttributes(parent, sourceCode) ? singleLineOptions : multiLineOptions);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { keySpacing as default };
|
||||
337
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/keyword-spacing.js
generated
vendored
Normal file
337
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/keyword-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
import { K as KEYWORDS_JS, c as createRule, n as isNotOpeningParenToken, i as isTokenOnSameLine, E as isKeywordToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const PREV_TOKEN = /^[)\]}>]$/u;
|
||||
const NEXT_TOKEN = /^(?:[([{<~!]|\+\+?|--?)$/u;
|
||||
const PREV_TOKEN_M = /^[)\]}>*]$/u;
|
||||
const NEXT_TOKEN_M = /^[{*]$/u;
|
||||
const TEMPLATE_OPEN_PAREN = /\$\{$/u;
|
||||
const TEMPLATE_CLOSE_PAREN = /^\}/u;
|
||||
const CHECK_TYPE = /^(?:JSXElement|RegularExpression|String|Template|PrivateIdentifier)$/u;
|
||||
const KEYS = KEYWORDS_JS.concat(["as", "async", "await", "from", "get", "let", "of", "satisfies", "set", "yield"]);
|
||||
(function() {
|
||||
KEYS.sort();
|
||||
for (let i = 1; i < KEYS.length; ++i) {
|
||||
if (KEYS[i] === KEYS[i - 1])
|
||||
throw new Error(`Duplication was found in the keyword list: ${KEYS[i]}`);
|
||||
}
|
||||
})();
|
||||
function isOpenParenOfTemplate(token) {
|
||||
return token.type === "Template" && TEMPLATE_OPEN_PAREN.test(token.value);
|
||||
}
|
||||
function isCloseParenOfTemplate(token) {
|
||||
return token.type === "Template" && TEMPLATE_CLOSE_PAREN.test(token.value);
|
||||
}
|
||||
var keywordSpacing = createRule({
|
||||
name: "keyword-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after keywords"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean", default: true },
|
||||
after: { type: "boolean", default: true },
|
||||
overrides: {
|
||||
type: "object",
|
||||
properties: KEYS.reduce((retv, key) => {
|
||||
retv[key] = {
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean" },
|
||||
after: { type: "boolean" }
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
return retv;
|
||||
}, {}),
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expectedBefore: 'Expected space(s) before "{{value}}".',
|
||||
expectedAfter: 'Expected space(s) after "{{value}}".',
|
||||
unexpectedBefore: 'Unexpected space(s) before "{{value}}".',
|
||||
unexpectedAfter: 'Unexpected space(s) after "{{value}}".'
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const tokensToIgnore = /* @__PURE__ */ new WeakSet();
|
||||
function expectSpaceBefore(token, pattern) {
|
||||
const prevToken = sourceCode.getTokenBefore(token);
|
||||
if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && !tokensToIgnore.has(prevToken) && isTokenOnSameLine(prevToken, token) && !sourceCode.isSpaceBetween(prevToken, token)) {
|
||||
context.report({
|
||||
loc: token.loc,
|
||||
messageId: "expectedBefore",
|
||||
// @ts-expect-error index signature for string is missing
|
||||
data: token,
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function unexpectSpaceBefore(token, pattern) {
|
||||
const prevToken = sourceCode.getTokenBefore(token);
|
||||
if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && !tokensToIgnore.has(prevToken) && isTokenOnSameLine(prevToken, token) && sourceCode.isSpaceBetween(prevToken, token)) {
|
||||
context.report({
|
||||
loc: { start: prevToken.loc.end, end: token.loc.start },
|
||||
messageId: "unexpectedBefore",
|
||||
// @ts-expect-error index signature for string is missing
|
||||
data: token,
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([prevToken.range[1], token.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function expectSpaceAfter(token, pattern) {
|
||||
const nextToken = sourceCode.getTokenAfter(token);
|
||||
if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && !tokensToIgnore.has(nextToken) && isTokenOnSameLine(token, nextToken) && !sourceCode.isSpaceBetween(token, nextToken)) {
|
||||
context.report({
|
||||
loc: token.loc,
|
||||
messageId: "expectedAfter",
|
||||
// @ts-expect-error index signature for string is missing
|
||||
data: token,
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function unexpectSpaceAfter(token, pattern) {
|
||||
const nextToken = sourceCode.getTokenAfter(token);
|
||||
if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && !tokensToIgnore.has(nextToken) && isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetween(token, nextToken)) {
|
||||
context.report({
|
||||
loc: { start: token.loc.end, end: nextToken.loc.start },
|
||||
messageId: "unexpectedAfter",
|
||||
// @ts-expect-error index signature for string is missing
|
||||
data: token,
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([token.range[1], nextToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function parseOptions(options = {}) {
|
||||
const before = options.before !== false;
|
||||
const after = options.after !== false;
|
||||
const defaultValue = {
|
||||
before: before ? expectSpaceBefore : unexpectSpaceBefore,
|
||||
after: after ? expectSpaceAfter : unexpectSpaceAfter
|
||||
};
|
||||
const overrides = options && options.overrides || {};
|
||||
const retv = /* @__PURE__ */ Object.create(null);
|
||||
for (let i = 0; i < KEYS.length; ++i) {
|
||||
const key = KEYS[i];
|
||||
const override = overrides[key];
|
||||
if (override) {
|
||||
const thisBefore = "before" in override ? override.before : before;
|
||||
const thisAfter = "after" in override ? override.after : after;
|
||||
retv[key] = {
|
||||
before: thisBefore ? expectSpaceBefore : unexpectSpaceBefore,
|
||||
after: thisAfter ? expectSpaceAfter : unexpectSpaceAfter
|
||||
};
|
||||
} else {
|
||||
retv[key] = defaultValue;
|
||||
}
|
||||
}
|
||||
return retv;
|
||||
}
|
||||
const checkMethodMap = parseOptions(context.options[0]);
|
||||
function checkSpacingBefore(token, pattern) {
|
||||
checkMethodMap[token.value].before(token, pattern || PREV_TOKEN);
|
||||
}
|
||||
function checkSpacingAfter(token, pattern) {
|
||||
checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN);
|
||||
}
|
||||
function checkSpacingAround(token) {
|
||||
checkSpacingBefore(token);
|
||||
checkSpacingAfter(token);
|
||||
}
|
||||
function checkSpacingAroundFirstToken(node) {
|
||||
const firstToken = node && sourceCode.getFirstToken(node);
|
||||
if (firstToken && firstToken.type === "Keyword")
|
||||
checkSpacingAround(firstToken);
|
||||
}
|
||||
function checkSpacingBeforeFirstToken(node) {
|
||||
const firstToken = node && sourceCode.getFirstToken(node);
|
||||
if (firstToken && firstToken.type === "Keyword")
|
||||
checkSpacingBefore(firstToken);
|
||||
}
|
||||
function checkSpacingAroundTokenBefore(node) {
|
||||
if (node) {
|
||||
const token = sourceCode.getTokenBefore(node, isKeywordToken);
|
||||
if (token)
|
||||
checkSpacingAround(token);
|
||||
}
|
||||
}
|
||||
function checkSpacingForFunction(node) {
|
||||
const firstToken = node && sourceCode.getFirstToken(node);
|
||||
if (firstToken && (firstToken.type === "Keyword" && firstToken.value === "function" || firstToken.value === "async")) {
|
||||
checkSpacingBefore(firstToken);
|
||||
}
|
||||
}
|
||||
function checkSpacingForClass(node) {
|
||||
checkSpacingAroundFirstToken(node);
|
||||
checkSpacingAroundTokenBefore(node.superClass);
|
||||
}
|
||||
function checkSpacingForIfStatement(node) {
|
||||
checkSpacingAroundFirstToken(node);
|
||||
checkSpacingAroundTokenBefore(node.alternate);
|
||||
}
|
||||
function checkSpacingForTryStatement(node) {
|
||||
checkSpacingAroundFirstToken(node);
|
||||
checkSpacingAroundFirstToken(node.handler);
|
||||
checkSpacingAroundTokenBefore(node.finalizer);
|
||||
}
|
||||
function checkSpacingForDoWhileStatement(node) {
|
||||
checkSpacingAroundFirstToken(node);
|
||||
checkSpacingAroundTokenBefore(node.test);
|
||||
}
|
||||
function checkSpacingForForInStatement(node) {
|
||||
checkSpacingAroundFirstToken(node);
|
||||
const inToken = sourceCode.getTokenBefore(node.right, isNotOpeningParenToken);
|
||||
const previousToken = sourceCode.getTokenBefore(inToken);
|
||||
if (previousToken.type !== "PrivateIdentifier")
|
||||
checkSpacingBefore(inToken);
|
||||
checkSpacingAfter(inToken);
|
||||
}
|
||||
function checkSpacingForForOfStatement(node) {
|
||||
if (node.await) {
|
||||
checkSpacingBefore(sourceCode.getFirstToken(node, 0));
|
||||
checkSpacingAfter(sourceCode.getFirstToken(node, 1));
|
||||
} else {
|
||||
checkSpacingAroundFirstToken(node);
|
||||
}
|
||||
const ofToken = sourceCode.getTokenBefore(node.right, isNotOpeningParenToken);
|
||||
const previousToken = sourceCode.getTokenBefore(ofToken);
|
||||
if (previousToken.type !== "PrivateIdentifier")
|
||||
checkSpacingBefore(ofToken);
|
||||
checkSpacingAfter(ofToken);
|
||||
}
|
||||
function checkSpacingForModuleDeclaration(node) {
|
||||
const firstToken = sourceCode.getFirstToken(node);
|
||||
checkSpacingBefore(firstToken, PREV_TOKEN_M);
|
||||
checkSpacingAfter(firstToken, NEXT_TOKEN_M);
|
||||
if (node.type === "ExportDefaultDeclaration")
|
||||
checkSpacingAround(sourceCode.getTokenAfter(firstToken));
|
||||
if (node.type === "ExportAllDeclaration" && node.exported) {
|
||||
const asToken = sourceCode.getTokenBefore(node.exported);
|
||||
checkSpacingBefore(asToken, PREV_TOKEN_M);
|
||||
checkSpacingAfter(asToken, NEXT_TOKEN_M);
|
||||
}
|
||||
if ("source" in node && node.source) {
|
||||
const fromToken = sourceCode.getTokenBefore(node.source);
|
||||
checkSpacingBefore(fromToken, PREV_TOKEN_M);
|
||||
checkSpacingAfter(fromToken, NEXT_TOKEN_M);
|
||||
}
|
||||
}
|
||||
function checkSpacingForImportSpecifier(node) {
|
||||
if (node.imported.range[0] !== node.local.range[0]) {
|
||||
const asToken = sourceCode.getTokenBefore(node.local);
|
||||
checkSpacingBefore(asToken, PREV_TOKEN_M);
|
||||
}
|
||||
}
|
||||
function checkSpacingForExportSpecifier(node) {
|
||||
if (node.local.range[0] !== node.exported.range[0]) {
|
||||
const asToken = sourceCode.getTokenBefore(node.exported);
|
||||
checkSpacingBefore(asToken, PREV_TOKEN_M);
|
||||
checkSpacingAfter(asToken, NEXT_TOKEN_M);
|
||||
}
|
||||
}
|
||||
function checkSpacingForImportNamespaceSpecifier(node) {
|
||||
const asToken = sourceCode.getFirstToken(node, 1);
|
||||
checkSpacingBefore(asToken, PREV_TOKEN_M);
|
||||
}
|
||||
function checkSpacingForProperty(node) {
|
||||
if ("static" in node && node.static)
|
||||
checkSpacingAroundFirstToken(node);
|
||||
if (node.kind === "get" || node.kind === "set" || ("method" in node && node.method || node.type === "MethodDefinition") && "async" in node.value && node.value.async) {
|
||||
const token = sourceCode.getTokenBefore(
|
||||
node.key,
|
||||
(tok) => {
|
||||
switch (tok.value) {
|
||||
case "get":
|
||||
case "set":
|
||||
case "async":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
if (!token)
|
||||
throw new Error("Failed to find token get, set, or async beside method name");
|
||||
checkSpacingAround(token);
|
||||
}
|
||||
}
|
||||
function checkSpacingForAwaitExpression(node) {
|
||||
checkSpacingBefore(sourceCode.getFirstToken(node));
|
||||
}
|
||||
return {
|
||||
// Statements
|
||||
"DebuggerStatement": checkSpacingAroundFirstToken,
|
||||
"WithStatement": checkSpacingAroundFirstToken,
|
||||
// Statements - Control flow
|
||||
"BreakStatement": checkSpacingAroundFirstToken,
|
||||
"ContinueStatement": checkSpacingAroundFirstToken,
|
||||
"ReturnStatement": checkSpacingAroundFirstToken,
|
||||
"ThrowStatement": checkSpacingAroundFirstToken,
|
||||
"TryStatement": checkSpacingForTryStatement,
|
||||
// Statements - Choice
|
||||
"IfStatement": checkSpacingForIfStatement,
|
||||
"SwitchStatement": checkSpacingAroundFirstToken,
|
||||
"SwitchCase": checkSpacingAroundFirstToken,
|
||||
// Statements - Loops
|
||||
"DoWhileStatement": checkSpacingForDoWhileStatement,
|
||||
"ForInStatement": checkSpacingForForInStatement,
|
||||
"ForOfStatement": checkSpacingForForOfStatement,
|
||||
"ForStatement": checkSpacingAroundFirstToken,
|
||||
"WhileStatement": checkSpacingAroundFirstToken,
|
||||
// Statements - Declarations
|
||||
"ClassDeclaration": checkSpacingForClass,
|
||||
"ExportNamedDeclaration": checkSpacingForModuleDeclaration,
|
||||
"ExportDefaultDeclaration": checkSpacingForModuleDeclaration,
|
||||
"ExportAllDeclaration": checkSpacingForModuleDeclaration,
|
||||
"FunctionDeclaration": checkSpacingForFunction,
|
||||
"ImportDeclaration": checkSpacingForModuleDeclaration,
|
||||
"VariableDeclaration": checkSpacingAroundFirstToken,
|
||||
// Expressions
|
||||
"ArrowFunctionExpression": checkSpacingForFunction,
|
||||
"AwaitExpression": checkSpacingForAwaitExpression,
|
||||
"ClassExpression": checkSpacingForClass,
|
||||
"FunctionExpression": checkSpacingForFunction,
|
||||
"NewExpression": checkSpacingBeforeFirstToken,
|
||||
"Super": checkSpacingBeforeFirstToken,
|
||||
"ThisExpression": checkSpacingBeforeFirstToken,
|
||||
"UnaryExpression": checkSpacingBeforeFirstToken,
|
||||
"YieldExpression": checkSpacingBeforeFirstToken,
|
||||
// Others
|
||||
"ImportSpecifier": checkSpacingForImportSpecifier,
|
||||
"ExportSpecifier": checkSpacingForExportSpecifier,
|
||||
"ImportNamespaceSpecifier": checkSpacingForImportNamespaceSpecifier,
|
||||
"MethodDefinition": checkSpacingForProperty,
|
||||
"PropertyDefinition": checkSpacingForProperty,
|
||||
"StaticBlock": checkSpacingAroundFirstToken,
|
||||
"Property": checkSpacingForProperty,
|
||||
// To avoid conflicts with `space-infix-ops`, e.g. `a > this.b`
|
||||
"BinaryExpression[operator='>']": function(node) {
|
||||
const operatorToken = sourceCode.getTokenBefore(node.right, isNotOpeningParenToken);
|
||||
tokensToIgnore.add(operatorToken);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { keywordSpacing as default };
|
||||
98
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/line-comment-position.js
generated
vendored
Normal file
98
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/line-comment-position.js
generated
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
import { c as createRule, F as COMMENTS_IGNORE_PATTERN } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var lineCommentPosition = createRule({
|
||||
name: "line-comment-position",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce position of line comments"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["above", "beside"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
position: {
|
||||
type: "string",
|
||||
enum: ["above", "beside"]
|
||||
},
|
||||
ignorePattern: {
|
||||
type: "string"
|
||||
},
|
||||
applyDefaultPatterns: {
|
||||
type: "boolean"
|
||||
},
|
||||
applyDefaultIgnorePatterns: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
above: "Expected comment to be above code.",
|
||||
beside: "Expected comment to be beside code."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = context.options[0];
|
||||
let above;
|
||||
let ignorePattern;
|
||||
let applyDefaultIgnorePatterns = true;
|
||||
let customIgnoreRegExp;
|
||||
if (!options || typeof options === "string") {
|
||||
above = !options || options === "above";
|
||||
} else {
|
||||
above = !options.position || options.position === "above";
|
||||
ignorePattern = options.ignorePattern;
|
||||
customIgnoreRegExp = new RegExp(ignorePattern, "u");
|
||||
if (Object.hasOwn(options, "applyDefaultIgnorePatterns"))
|
||||
applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns;
|
||||
else
|
||||
applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false;
|
||||
}
|
||||
const defaultIgnoreRegExp = COMMENTS_IGNORE_PATTERN;
|
||||
const fallThroughRegExp = /^\s*falls?\s?through/u;
|
||||
const sourceCode = context.sourceCode;
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.filter((token) => token.type === "Line").forEach((node) => {
|
||||
if (applyDefaultIgnorePatterns && (defaultIgnoreRegExp.test(node.value) || fallThroughRegExp.test(node.value)))
|
||||
return;
|
||||
if (ignorePattern && customIgnoreRegExp.test(node.value))
|
||||
return;
|
||||
const previous = sourceCode.getTokenBefore(node, { includeComments: true });
|
||||
const isOnSameLine = previous && previous.loc.end.line === node.loc.start.line;
|
||||
if (above) {
|
||||
if (isOnSameLine) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "above"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!isOnSameLine) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "beside"
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { lineCommentPosition as default };
|
||||
68
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/linebreak-style.js
generated
vendored
Normal file
68
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/linebreak-style.js
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { c as createRule, z as createGlobalLinebreakMatcher } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var linebreakStyle = createRule({
|
||||
name: "linebreak-style",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent linebreak style"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["unix", "windows"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expectedLF: "Expected linebreaks to be 'LF' but found 'CRLF'.",
|
||||
expectedCRLF: "Expected linebreaks to be 'CRLF' but found 'LF'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
function createFix(range, text) {
|
||||
return function(fixer) {
|
||||
return fixer.replaceTextRange(range, text);
|
||||
};
|
||||
}
|
||||
return {
|
||||
Program: function checkForLinebreakStyle(node) {
|
||||
const linebreakStyle = context.options[0] || "unix";
|
||||
const expectedLF = linebreakStyle === "unix";
|
||||
const expectedLFChars = expectedLF ? "\n" : "\r\n";
|
||||
const source = sourceCode.getText();
|
||||
const pattern = createGlobalLinebreakMatcher();
|
||||
let match;
|
||||
let i = 0;
|
||||
while ((match = pattern.exec(source)) !== null) {
|
||||
i++;
|
||||
if (match[0] === expectedLFChars)
|
||||
continue;
|
||||
const index = match.index;
|
||||
const range = [index, index + match[0].length];
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: {
|
||||
line: i,
|
||||
column: sourceCode.lines[i - 1].length
|
||||
},
|
||||
end: {
|
||||
line: i + 1,
|
||||
column: 0
|
||||
}
|
||||
},
|
||||
messageId: expectedLF ? "expectedLF" : "expectedCRLF",
|
||||
fix: createFix(range, expectedLFChars)
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { linebreakStyle as default };
|
||||
258
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/lines-around-comment.js
generated
vendored
Normal file
258
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/lines-around-comment.js
generated
vendored
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
import { c as createRule, F as COMMENTS_IGNORE_PATTERN, a as isCommentToken, i as isTokenOnSameLine, v as isOpeningBraceToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
function getEmptyLineNums(lines) {
|
||||
const emptyLines = lines.map((line, i) => ({
|
||||
code: line.trim(),
|
||||
num: i + 1
|
||||
})).filter((line) => !line.code).map((line) => line.num);
|
||||
return emptyLines;
|
||||
}
|
||||
function getCommentLineNums(comments) {
|
||||
const lines = [];
|
||||
comments.forEach((token) => {
|
||||
const start = token.loc.start.line;
|
||||
const end = token.loc.end.line;
|
||||
lines.push(start, end);
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
var linesAroundComment = createRule({
|
||||
name: "lines-around-comment",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require empty lines around comments"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
beforeBlockComment: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
},
|
||||
afterBlockComment: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
beforeLineComment: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
afterLineComment: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
allowBlockStart: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
allowBlockEnd: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
allowClassStart: {
|
||||
type: "boolean"
|
||||
},
|
||||
allowClassEnd: {
|
||||
type: "boolean"
|
||||
},
|
||||
allowObjectStart: {
|
||||
type: "boolean"
|
||||
},
|
||||
allowObjectEnd: {
|
||||
type: "boolean"
|
||||
},
|
||||
allowArrayStart: {
|
||||
type: "boolean"
|
||||
},
|
||||
allowArrayEnd: {
|
||||
type: "boolean"
|
||||
},
|
||||
ignorePattern: {
|
||||
type: "string"
|
||||
},
|
||||
applyDefaultIgnorePatterns: {
|
||||
type: "boolean"
|
||||
},
|
||||
afterHashbangComment: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
after: "Expected line after comment.",
|
||||
before: "Expected line before comment."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = Object.assign({}, context.options[0]);
|
||||
const ignorePattern = options.ignorePattern;
|
||||
const defaultIgnoreRegExp = COMMENTS_IGNORE_PATTERN;
|
||||
const customIgnoreRegExp = ignorePattern && new RegExp(ignorePattern, "u");
|
||||
const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
|
||||
options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true;
|
||||
const sourceCode = context.sourceCode;
|
||||
const lines = sourceCode.lines;
|
||||
const numLines = lines.length + 1;
|
||||
const comments = sourceCode.getAllComments();
|
||||
const commentLines = getCommentLineNums(comments);
|
||||
const emptyLines = getEmptyLineNums(lines);
|
||||
const commentAndEmptyLines = new Set(commentLines.concat(emptyLines));
|
||||
function codeAroundComment(token) {
|
||||
let currentToken = token;
|
||||
do
|
||||
currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true });
|
||||
while (currentToken && isCommentToken(currentToken));
|
||||
if (currentToken && isTokenOnSameLine(currentToken, token))
|
||||
return true;
|
||||
currentToken = token;
|
||||
do
|
||||
currentToken = sourceCode.getTokenAfter(currentToken, { includeComments: true });
|
||||
while (currentToken && isCommentToken(currentToken));
|
||||
if (currentToken && isTokenOnSameLine(token, currentToken))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function isParentNodeType(parent, nodeType) {
|
||||
return parent.type === nodeType;
|
||||
}
|
||||
function getParentNodeOfToken(token) {
|
||||
const node = sourceCode.getNodeByRangeIndex(token.range[0]);
|
||||
if (node && node.type === "StaticBlock") {
|
||||
const openingBrace = sourceCode.getFirstToken(node, { skip: 1 });
|
||||
return openingBrace && token.range[0] >= openingBrace.range[0] ? node : null;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function isCommentAtParentStart(token, nodeType) {
|
||||
const parent = getParentNodeOfToken(token);
|
||||
if (parent && isParentNodeType(parent, nodeType)) {
|
||||
let parentStartNodeOrToken = parent;
|
||||
if (parent.type === "StaticBlock") {
|
||||
parentStartNodeOrToken = sourceCode.getFirstToken(parent, { skip: 1 });
|
||||
} else if (parent.type === "SwitchStatement") {
|
||||
parentStartNodeOrToken = sourceCode.getTokenAfter(parent.discriminant, {
|
||||
filter: isOpeningBraceToken
|
||||
});
|
||||
}
|
||||
return !!parentStartNodeOrToken && token.loc.start.line - parentStartNodeOrToken.loc.start.line === 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isCommentAtParentEnd(token, nodeType) {
|
||||
const parent = getParentNodeOfToken(token);
|
||||
return !!parent && isParentNodeType(parent, nodeType) && parent.loc.end.line - token.loc.end.line === 1;
|
||||
}
|
||||
function isCommentAtBlockStart(token) {
|
||||
return isCommentAtParentStart(token, "ClassBody") || isCommentAtParentStart(token, "BlockStatement") || isCommentAtParentStart(token, "StaticBlock") || isCommentAtParentStart(token, "SwitchCase") || isCommentAtParentStart(token, "SwitchStatement");
|
||||
}
|
||||
function isCommentAtBlockEnd(token) {
|
||||
return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "StaticBlock") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement");
|
||||
}
|
||||
function isCommentAtClassStart(token) {
|
||||
return isCommentAtParentStart(token, "ClassBody");
|
||||
}
|
||||
function isCommentAtClassEnd(token) {
|
||||
return isCommentAtParentEnd(token, "ClassBody");
|
||||
}
|
||||
function isCommentAtObjectStart(token) {
|
||||
return isCommentAtParentStart(token, "ObjectExpression") || isCommentAtParentStart(token, "ObjectPattern");
|
||||
}
|
||||
function isCommentAtObjectEnd(token) {
|
||||
return isCommentAtParentEnd(token, "ObjectExpression") || isCommentAtParentEnd(token, "ObjectPattern");
|
||||
}
|
||||
function isCommentAtArrayStart(token) {
|
||||
return isCommentAtParentStart(token, "ArrayExpression") || isCommentAtParentStart(token, "ArrayPattern");
|
||||
}
|
||||
function isCommentAtArrayEnd(token) {
|
||||
return isCommentAtParentEnd(token, "ArrayExpression") || isCommentAtParentEnd(token, "ArrayPattern");
|
||||
}
|
||||
function checkForEmptyLine(token, opts) {
|
||||
if (applyDefaultIgnorePatterns && defaultIgnoreRegExp.test(token.value))
|
||||
return;
|
||||
if (customIgnoreRegExp && customIgnoreRegExp.test(token.value))
|
||||
return;
|
||||
let after = opts.after;
|
||||
let before = opts.before;
|
||||
const prevLineNum = token.loc.start.line - 1;
|
||||
const nextLineNum = token.loc.end.line + 1;
|
||||
const commentIsNotAlone = codeAroundComment(token);
|
||||
const blockStartAllowed = options.allowBlockStart && isCommentAtBlockStart(token) && !(options.allowClassStart === false && isCommentAtClassStart(token));
|
||||
const blockEndAllowed = options.allowBlockEnd && isCommentAtBlockEnd(token) && !(options.allowClassEnd === false && isCommentAtClassEnd(token));
|
||||
const classStartAllowed = options.allowClassStart && isCommentAtClassStart(token);
|
||||
const classEndAllowed = options.allowClassEnd && isCommentAtClassEnd(token);
|
||||
const objectStartAllowed = options.allowObjectStart && isCommentAtObjectStart(token);
|
||||
const objectEndAllowed = options.allowObjectEnd && isCommentAtObjectEnd(token);
|
||||
const arrayStartAllowed = options.allowArrayStart && isCommentAtArrayStart(token);
|
||||
const arrayEndAllowed = options.allowArrayEnd && isCommentAtArrayEnd(token);
|
||||
const exceptionStartAllowed = blockStartAllowed || classStartAllowed || objectStartAllowed || arrayStartAllowed;
|
||||
const exceptionEndAllowed = blockEndAllowed || classEndAllowed || objectEndAllowed || arrayEndAllowed;
|
||||
if (prevLineNum < 1)
|
||||
before = false;
|
||||
if (nextLineNum >= numLines)
|
||||
after = false;
|
||||
if (commentIsNotAlone)
|
||||
return;
|
||||
const previousTokenOrComment = sourceCode.getTokenBefore(token, { includeComments: true });
|
||||
const nextTokenOrComment = sourceCode.getTokenAfter(token, { includeComments: true });
|
||||
if (!exceptionStartAllowed && before && !commentAndEmptyLines.has(prevLineNum) && !(isCommentToken(previousTokenOrComment) && isTokenOnSameLine(previousTokenOrComment, token))) {
|
||||
const lineStart = token.range[0] - token.loc.start.column;
|
||||
const range = [lineStart, lineStart];
|
||||
context.report({
|
||||
node: token,
|
||||
messageId: "before",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBeforeRange(range, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!exceptionEndAllowed && after && !commentAndEmptyLines.has(nextLineNum) && !(isCommentToken(nextTokenOrComment) && isTokenOnSameLine(token, nextTokenOrComment))) {
|
||||
context.report({
|
||||
node: token,
|
||||
messageId: "after",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
Program() {
|
||||
comments.forEach((token) => {
|
||||
if (token.type === "Line") {
|
||||
if (options.beforeLineComment || options.afterLineComment) {
|
||||
checkForEmptyLine(token, {
|
||||
after: options.afterLineComment,
|
||||
before: options.beforeLineComment
|
||||
});
|
||||
}
|
||||
} else if (token.type === "Block") {
|
||||
if (options.beforeBlockComment || options.afterBlockComment) {
|
||||
checkForEmptyLine(token, {
|
||||
after: options.afterBlockComment,
|
||||
before: options.beforeBlockComment
|
||||
});
|
||||
}
|
||||
} else if (token.type === "Shebang") {
|
||||
if (options.afterHashbangComment) {
|
||||
checkForEmptyLine(token, {
|
||||
after: options.afterHashbangComment,
|
||||
before: false
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { linesAroundComment as default };
|
||||
148
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/lines-between-class-members.js
generated
vendored
Normal file
148
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/lines-between-class-members.js
generated
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
import { c as createRule, i as isTokenOnSameLine, t as isSemicolonToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const ClassMemberTypes = {
|
||||
"*": { test: () => true },
|
||||
"field": { test: (node) => node.type === "PropertyDefinition" },
|
||||
"method": { test: (node) => node.type === "MethodDefinition" }
|
||||
};
|
||||
var linesBetweenClassMembers = createRule(
|
||||
{
|
||||
name: "lines-between-class-members",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow an empty line between class members"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
anyOf: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
enforce: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
blankLine: { type: "string", enum: ["always", "never"] },
|
||||
prev: { type: "string", enum: ["method", "field", "*"] },
|
||||
next: { type: "string", enum: ["method", "field", "*"] }
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ["blankLine", "prev", "next"]
|
||||
},
|
||||
minItems: 1
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ["enforce"]
|
||||
},
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptAfterSingleLine: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
never: "Unexpected blank line between class members.",
|
||||
always: "Expected blank line between class members."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = [];
|
||||
options[0] = context.options[0] || "always";
|
||||
options[1] = context.options[1] || { exceptAfterSingleLine: false };
|
||||
const configureList = typeof options[0] === "object" ? options[0].enforce : [{ blankLine: options[0], prev: "*", next: "*" }];
|
||||
const sourceCode = context.sourceCode;
|
||||
function getBoundaryTokens(curNode, nextNode) {
|
||||
const lastToken = sourceCode.getLastToken(curNode);
|
||||
const prevToken = sourceCode.getTokenBefore(lastToken);
|
||||
const nextToken = sourceCode.getFirstToken(nextNode);
|
||||
const isSemicolonLessStyle = isSemicolonToken(lastToken) && !isTokenOnSameLine(prevToken, lastToken) && isTokenOnSameLine(lastToken, nextToken);
|
||||
return isSemicolonLessStyle ? { curLast: prevToken, nextFirst: lastToken } : { curLast: lastToken, nextFirst: nextToken };
|
||||
}
|
||||
function findLastConsecutiveTokenAfter(prevLastToken, nextFirstToken, maxLine) {
|
||||
const after = sourceCode.getTokenAfter(prevLastToken, { includeComments: true });
|
||||
if (after !== nextFirstToken && after.loc.start.line - prevLastToken.loc.end.line <= maxLine)
|
||||
return findLastConsecutiveTokenAfter(after, nextFirstToken, maxLine);
|
||||
return prevLastToken;
|
||||
}
|
||||
function findFirstConsecutiveTokenBefore(nextFirstToken, prevLastToken, maxLine) {
|
||||
const before = sourceCode.getTokenBefore(nextFirstToken, { includeComments: true });
|
||||
if (before !== prevLastToken && nextFirstToken.loc.start.line - before.loc.end.line <= maxLine)
|
||||
return findFirstConsecutiveTokenBefore(before, prevLastToken, maxLine);
|
||||
return nextFirstToken;
|
||||
}
|
||||
function hasTokenOrCommentBetween(before, after) {
|
||||
return sourceCode.getTokensBetween(before, after, { includeComments: true }).length !== 0;
|
||||
}
|
||||
function match(node, type) {
|
||||
return ClassMemberTypes[type].test(node);
|
||||
}
|
||||
function getPaddingType(prevNode, nextNode) {
|
||||
for (let i = configureList.length - 1; i >= 0; --i) {
|
||||
const configure = configureList[i];
|
||||
const matched = match(prevNode, configure.prev) && match(nextNode, configure.next);
|
||||
if (matched)
|
||||
return configure.blankLine;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
ClassBody(node) {
|
||||
const body = node.body;
|
||||
for (let i = 0; i < body.length - 1; i++) {
|
||||
const curFirst = sourceCode.getFirstToken(body[i]);
|
||||
const { curLast, nextFirst } = getBoundaryTokens(body[i], body[i + 1]);
|
||||
const isMulti = !isTokenOnSameLine(curFirst, curLast);
|
||||
const skip = !isMulti && options[1].exceptAfterSingleLine;
|
||||
const beforePadding = findLastConsecutiveTokenAfter(curLast, nextFirst, 1);
|
||||
const afterPadding = findFirstConsecutiveTokenBefore(nextFirst, curLast, 1);
|
||||
const isPadded = afterPadding.loc.start.line - beforePadding.loc.end.line > 1;
|
||||
const hasTokenInPadding = hasTokenOrCommentBetween(beforePadding, afterPadding);
|
||||
const curLineLastToken = findLastConsecutiveTokenAfter(curLast, nextFirst, 0);
|
||||
const paddingType = getPaddingType(body[i], body[i + 1]);
|
||||
if (paddingType === "never" && isPadded) {
|
||||
context.report({
|
||||
node: body[i + 1],
|
||||
messageId: "never",
|
||||
fix(fixer) {
|
||||
if (hasTokenInPadding)
|
||||
return null;
|
||||
return fixer.replaceTextRange([beforePadding.range[1], afterPadding.range[0]], "\n");
|
||||
}
|
||||
});
|
||||
} else if (paddingType === "always" && !skip && !isPadded) {
|
||||
context.report({
|
||||
node: body[i + 1],
|
||||
messageId: "always",
|
||||
fix(fixer) {
|
||||
if (hasTokenInPadding)
|
||||
return null;
|
||||
return fixer.insertTextAfter(curLineLastToken, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export { linesBetweenClassMembers as default };
|
||||
238
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/max-len.js
generated
vendored
Normal file
238
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/max-len.js
generated
vendored
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const OPTIONS_SCHEMA = {
|
||||
type: "object",
|
||||
properties: {
|
||||
code: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
comments: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
tabWidth: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
ignorePattern: {
|
||||
type: "string"
|
||||
},
|
||||
ignoreComments: {
|
||||
type: "boolean"
|
||||
},
|
||||
ignoreStrings: {
|
||||
type: "boolean"
|
||||
},
|
||||
ignoreUrls: {
|
||||
type: "boolean"
|
||||
},
|
||||
ignoreTemplateLiterals: {
|
||||
type: "boolean"
|
||||
},
|
||||
ignoreRegExpLiterals: {
|
||||
type: "boolean"
|
||||
},
|
||||
ignoreTrailingComments: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
};
|
||||
const OPTIONS_OR_INTEGER_SCHEMA = {
|
||||
anyOf: [
|
||||
OPTIONS_SCHEMA,
|
||||
{
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
}
|
||||
]
|
||||
};
|
||||
var maxLen = createRule({
|
||||
name: "max-len",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce a maximum line length"
|
||||
},
|
||||
schema: [
|
||||
OPTIONS_OR_INTEGER_SCHEMA,
|
||||
OPTIONS_OR_INTEGER_SCHEMA,
|
||||
OPTIONS_SCHEMA
|
||||
],
|
||||
messages: {
|
||||
max: "This line has a length of {{lineLength}}. Maximum allowed is {{maxLength}}.",
|
||||
maxComment: "This line has a comment length of {{lineLength}}. Maximum allowed is {{maxCommentLength}}."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u;
|
||||
const sourceCode = context.sourceCode;
|
||||
function computeLineLength(line, tabWidth2) {
|
||||
let extraCharacterCount = 0;
|
||||
line.replace(/\t/gu, (_, offset) => {
|
||||
const totalOffset = offset + extraCharacterCount;
|
||||
const previousTabStopOffset = tabWidth2 ? totalOffset % tabWidth2 : 0;
|
||||
const spaceCount = tabWidth2 - previousTabStopOffset;
|
||||
extraCharacterCount += spaceCount - 1;
|
||||
return "";
|
||||
});
|
||||
return Array.from(line).length + extraCharacterCount;
|
||||
}
|
||||
const options = Object.assign({}, context.options[context.options.length - 1]);
|
||||
if (typeof context.options[0] === "number")
|
||||
options.code = context.options[0];
|
||||
if (typeof context.options[1] === "number")
|
||||
options.tabWidth = context.options[1];
|
||||
const maxLength = typeof options.code === "number" ? options.code : 80;
|
||||
const tabWidth = typeof options.tabWidth === "number" ? options.tabWidth : 4;
|
||||
const ignoreComments = !!options.ignoreComments;
|
||||
const ignoreStrings = !!options.ignoreStrings;
|
||||
const ignoreTemplateLiterals = !!options.ignoreTemplateLiterals;
|
||||
const ignoreRegExpLiterals = !!options.ignoreRegExpLiterals;
|
||||
const ignoreTrailingComments = !!options.ignoreTrailingComments || !!options.ignoreComments;
|
||||
const ignoreUrls = !!options.ignoreUrls;
|
||||
const maxCommentLength = options.comments;
|
||||
let ignorePattern = null;
|
||||
if (options.ignorePattern)
|
||||
ignorePattern = new RegExp(options.ignorePattern, "u");
|
||||
function isTrailingComment(line, lineNumber, comment) {
|
||||
return comment && (comment.loc.start.line === lineNumber && lineNumber <= comment.loc.end.line) && (comment.loc.end.line > lineNumber || comment.loc.end.column === line.length);
|
||||
}
|
||||
function isFullLineComment(line, lineNumber, comment) {
|
||||
const start = comment.loc.start;
|
||||
const end = comment.loc.end;
|
||||
const isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim();
|
||||
return comment && (start.line < lineNumber || start.line === lineNumber && isFirstTokenOnLine) && (end.line > lineNumber || end.line === lineNumber && end.column === line.length);
|
||||
}
|
||||
function isJSXEmptyExpressionInSingleLineContainer(node) {
|
||||
if (!node || !node.parent || node.type !== "JSXEmptyExpression" || node.parent.type !== "JSXExpressionContainer")
|
||||
return false;
|
||||
const parent = node.parent;
|
||||
return parent.loc.start.line === parent.loc.end.line;
|
||||
}
|
||||
function stripTrailingComment(line, comment) {
|
||||
return line.slice(0, comment.loc.start.column).replace(/\s+$/u, "");
|
||||
}
|
||||
function ensureArrayAndPush(object, key, value) {
|
||||
if (!Array.isArray(object[key]))
|
||||
object[key] = [];
|
||||
object[key].push(value);
|
||||
}
|
||||
function getAllStrings() {
|
||||
return sourceCode.ast.tokens.filter((token) => token.type === "String" || token.type === "JSXText" && sourceCode.getNodeByRangeIndex(token.range[0] - 1).type === "JSXAttribute");
|
||||
}
|
||||
function getAllTemplateLiterals() {
|
||||
return sourceCode.ast.tokens.filter((token) => token.type === "Template");
|
||||
}
|
||||
function getAllRegExpLiterals() {
|
||||
return sourceCode.ast.tokens.filter((token) => token.type === "RegularExpression");
|
||||
}
|
||||
function groupArrayByLineNumber(arr) {
|
||||
const obj = {};
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const node = arr[i];
|
||||
for (let j = node.loc.start.line; j <= node.loc.end.line; ++j)
|
||||
ensureArrayAndPush(obj, j, node);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
function getAllComments() {
|
||||
const comments = [];
|
||||
sourceCode.getAllComments().forEach((commentNode) => {
|
||||
const containingNode = sourceCode.getNodeByRangeIndex(commentNode.range[0]);
|
||||
if (isJSXEmptyExpressionInSingleLineContainer(containingNode)) {
|
||||
if (comments[comments.length - 1] !== containingNode.parent)
|
||||
comments.push(containingNode.parent);
|
||||
} else {
|
||||
comments.push(commentNode);
|
||||
}
|
||||
});
|
||||
return comments;
|
||||
}
|
||||
function checkProgramForMaxLength(node) {
|
||||
const lines = sourceCode.lines;
|
||||
const comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? getAllComments() : [];
|
||||
let commentsIndex = 0;
|
||||
const strings = getAllStrings();
|
||||
const stringsByLine = groupArrayByLineNumber(strings);
|
||||
const templateLiterals = getAllTemplateLiterals();
|
||||
const templateLiteralsByLine = groupArrayByLineNumber(templateLiterals);
|
||||
const regExpLiterals = getAllRegExpLiterals();
|
||||
const regExpLiteralsByLine = groupArrayByLineNumber(regExpLiterals);
|
||||
lines.forEach((line, i) => {
|
||||
const lineNumber = i + 1;
|
||||
let lineIsComment = false;
|
||||
let textToMeasure;
|
||||
if (commentsIndex < comments.length) {
|
||||
let comment = null;
|
||||
do
|
||||
comment = comments[++commentsIndex];
|
||||
while (comment && comment.loc.start.line <= lineNumber);
|
||||
comment = comments[--commentsIndex];
|
||||
if (isFullLineComment(line, lineNumber, comment)) {
|
||||
lineIsComment = true;
|
||||
textToMeasure = line;
|
||||
} else if (ignoreTrailingComments && isTrailingComment(line, lineNumber, comment)) {
|
||||
textToMeasure = stripTrailingComment(line, comment);
|
||||
let lastIndex = commentsIndex;
|
||||
while (isTrailingComment(textToMeasure, lineNumber, comments[--lastIndex]))
|
||||
textToMeasure = stripTrailingComment(textToMeasure, comments[lastIndex]);
|
||||
} else {
|
||||
textToMeasure = line;
|
||||
}
|
||||
} else {
|
||||
textToMeasure = line;
|
||||
}
|
||||
if (ignorePattern && ignorePattern.test(textToMeasure) || ignoreUrls && URL_REGEXP.test(textToMeasure) || ignoreStrings && stringsByLine[lineNumber] || ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] || ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber]) {
|
||||
return;
|
||||
}
|
||||
const lineLength = computeLineLength(textToMeasure, tabWidth);
|
||||
const commentLengthApplies = lineIsComment && maxCommentLength;
|
||||
if (lineIsComment && ignoreComments)
|
||||
return;
|
||||
const loc = {
|
||||
start: {
|
||||
line: lineNumber,
|
||||
column: 0
|
||||
},
|
||||
end: {
|
||||
line: lineNumber,
|
||||
column: textToMeasure.length
|
||||
}
|
||||
};
|
||||
if (commentLengthApplies) {
|
||||
if (lineLength > maxCommentLength) {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: "maxComment",
|
||||
data: {
|
||||
lineLength,
|
||||
maxCommentLength
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (lineLength > maxLength) {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: "max",
|
||||
data: {
|
||||
lineLength,
|
||||
maxLength
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
Program: checkProgramForMaxLength
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { maxLen as default };
|
||||
124
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/max-statements-per-line.js
generated
vendored
Normal file
124
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/max-statements-per-line.js
generated
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
import { c as createRule, y as isNotSemicolonToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const listeningNodes = [
|
||||
"BreakStatement",
|
||||
"ClassDeclaration",
|
||||
"ContinueStatement",
|
||||
"DebuggerStatement",
|
||||
"DoWhileStatement",
|
||||
"ExpressionStatement",
|
||||
"ForInStatement",
|
||||
"ForOfStatement",
|
||||
"ForStatement",
|
||||
"FunctionDeclaration",
|
||||
"IfStatement",
|
||||
"ImportDeclaration",
|
||||
"LabeledStatement",
|
||||
"ReturnStatement",
|
||||
"SwitchStatement",
|
||||
"ThrowStatement",
|
||||
"TryStatement",
|
||||
"VariableDeclaration",
|
||||
"WhileStatement",
|
||||
"WithStatement",
|
||||
"ExportNamedDeclaration",
|
||||
"ExportDefaultDeclaration",
|
||||
"ExportAllDeclaration"
|
||||
];
|
||||
var maxStatementsPerLine = createRule({
|
||||
name: "max-statements-per-line",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce a maximum number of statements allowed per line"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
max: {
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
default: 1
|
||||
},
|
||||
ignoredNodes: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
enum: listeningNodes
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
exceed: "This line has {{numberOfStatementsOnThisLine}} {{statements}}. Maximum allowed is {{maxStatementsPerLine}}."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const options = context.options[0] || {};
|
||||
const maxStatementsPerLine = typeof options.max !== "undefined" ? options.max : 1;
|
||||
const ignoredNodes = options.ignoredNodes || [];
|
||||
let lastStatementLine = 0;
|
||||
let numberOfStatementsOnThisLine = 0;
|
||||
let firstExtraStatement = null;
|
||||
const SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)$/u;
|
||||
function reportFirstExtraStatementAndClear() {
|
||||
if (firstExtraStatement) {
|
||||
context.report({
|
||||
node: firstExtraStatement,
|
||||
messageId: "exceed",
|
||||
data: {
|
||||
numberOfStatementsOnThisLine,
|
||||
maxStatementsPerLine,
|
||||
statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements"
|
||||
}
|
||||
});
|
||||
}
|
||||
firstExtraStatement = null;
|
||||
}
|
||||
function getActualLastToken(node) {
|
||||
return sourceCode.getLastToken(node, isNotSemicolonToken);
|
||||
}
|
||||
function enterStatement(node) {
|
||||
const line = node.loc.start.line;
|
||||
if (node.parent && SINGLE_CHILD_ALLOWED.test(node.parent.type) && (!("alternate" in node.parent) || node.parent.alternate !== node)) {
|
||||
return;
|
||||
}
|
||||
if (line === lastStatementLine) {
|
||||
numberOfStatementsOnThisLine += 1;
|
||||
} else {
|
||||
reportFirstExtraStatementAndClear();
|
||||
numberOfStatementsOnThisLine = 1;
|
||||
lastStatementLine = line;
|
||||
}
|
||||
if (numberOfStatementsOnThisLine === maxStatementsPerLine + 1)
|
||||
firstExtraStatement = firstExtraStatement || node;
|
||||
}
|
||||
function leaveStatement(node) {
|
||||
const line = getActualLastToken(node).loc.end.line;
|
||||
if (line !== lastStatementLine) {
|
||||
reportFirstExtraStatementAndClear();
|
||||
numberOfStatementsOnThisLine = 1;
|
||||
lastStatementLine = line;
|
||||
}
|
||||
}
|
||||
const listeners = {
|
||||
"Program:exit": reportFirstExtraStatementAndClear
|
||||
};
|
||||
for (const node of listeningNodes) {
|
||||
if (ignoredNodes.includes(node))
|
||||
continue;
|
||||
listeners[node] = enterStatement;
|
||||
listeners[`${node}:exit`] = leaveStatement;
|
||||
}
|
||||
return listeners;
|
||||
}
|
||||
});
|
||||
|
||||
export { maxStatementsPerLine as default };
|
||||
292
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/multiline-comment-style.js
generated
vendored
Normal file
292
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/multiline-comment-style.js
generated
vendored
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
import { c as createRule, F as COMMENTS_IGNORE_PATTERN, L as LINEBREAK_MATCHER } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var multilineCommentStyle = createRule({
|
||||
name: "multiline-comment-style",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
docs: {
|
||||
description: "Enforce a particular style for multiline comments"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
enum: ["starred-block", "bare-block"],
|
||||
type: "string"
|
||||
}
|
||||
],
|
||||
additionalItems: false
|
||||
},
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
enum: ["separate-lines"],
|
||||
type: "string"
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
checkJSDoc: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
additionalItems: false
|
||||
}
|
||||
]
|
||||
},
|
||||
messages: {
|
||||
expectedBlock: "Expected a block comment instead of consecutive line comments.",
|
||||
expectedBareBlock: "Expected a block comment without padding stars.",
|
||||
startNewline: "Expected a linebreak after '/*'.",
|
||||
endNewline: "Expected a linebreak before '*/'.",
|
||||
missingStar: "Expected a '*' at the start of this line.",
|
||||
alignment: "Expected this line to be aligned with the start of the comment.",
|
||||
expectedLines: "Expected multiple line comments instead of a block comment."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0] || "starred-block";
|
||||
const params = context.options[1] || {};
|
||||
const checkJSDoc = !!params.checkJSDoc;
|
||||
function isStarredCommentLine(line) {
|
||||
return /^\s*\*/u.test(line);
|
||||
}
|
||||
function isStarredBlockComment([firstComment]) {
|
||||
if (firstComment.type !== "Block")
|
||||
return false;
|
||||
const lines = firstComment.value.split(LINEBREAK_MATCHER);
|
||||
return lines.length > 0 && lines.every((line, i) => (i === 0 || i === lines.length - 1 ? /^\s*$/u : /^\s*\*/u).test(line));
|
||||
}
|
||||
function isJSDocComment([firstComment]) {
|
||||
if (firstComment.type !== "Block")
|
||||
return false;
|
||||
const lines = firstComment.value.split(LINEBREAK_MATCHER);
|
||||
return /^\*\s*$/u.test(lines[0]) && lines.slice(1, -1).every((line) => /^\s* /u.test(line)) && /^\s*$/u.test(lines.at(-1));
|
||||
}
|
||||
function processSeparateLineComments(commentGroup) {
|
||||
const allLinesHaveLeadingSpace = commentGroup.map(({ value }) => value).filter((line) => line.trim().length).every((line) => line.startsWith(" "));
|
||||
return commentGroup.map(({ value }) => allLinesHaveLeadingSpace ? value.replace(/^ /u, "") : value);
|
||||
}
|
||||
function processStarredBlockComment(comment) {
|
||||
const lines = comment.value.split(LINEBREAK_MATCHER).filter((line, i, linesArr) => !(i === 0 || i === linesArr.length - 1)).map((line) => line.replace(/^\s*$/u, ""));
|
||||
const allLinesHaveLeadingSpace = lines.map((line) => line.replace(/\s*\*/u, "")).filter((line) => line.trim().length).every((line) => line.startsWith(" "));
|
||||
return lines.map((line) => line.replace(allLinesHaveLeadingSpace ? /\s*\* ?/u : /\s*\*/u, ""));
|
||||
}
|
||||
function processBareBlockComment(comment) {
|
||||
const lines = comment.value.split(LINEBREAK_MATCHER).map((line) => line.replace(/^\s*$/u, ""));
|
||||
const leadingWhitespace = `${sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0])} `;
|
||||
let offset = "";
|
||||
for (const [i, line] of lines.entries()) {
|
||||
if (!line.trim().length || i === 0)
|
||||
continue;
|
||||
const [, lineOffset] = line.match(/^(\s*\*?\s*)/u);
|
||||
if (lineOffset.length < leadingWhitespace.length) {
|
||||
const newOffset = leadingWhitespace.slice(lineOffset.length - leadingWhitespace.length);
|
||||
if (newOffset.length > offset.length)
|
||||
offset = newOffset;
|
||||
}
|
||||
}
|
||||
return lines.map((line) => {
|
||||
const match = line.match(/^(\s*\*?\s*)(.*)/u);
|
||||
const [, lineOffset, lineContents] = match;
|
||||
if (lineOffset.length > leadingWhitespace.length)
|
||||
return `${lineOffset.slice(leadingWhitespace.length - (offset.length + lineOffset.length))}${lineContents}`;
|
||||
if (lineOffset.length < leadingWhitespace.length)
|
||||
return `${lineOffset.slice(leadingWhitespace.length)}${lineContents}`;
|
||||
return lineContents;
|
||||
});
|
||||
}
|
||||
function getCommentLines(commentGroup) {
|
||||
const [firstComment] = commentGroup;
|
||||
if (firstComment.type === "Line")
|
||||
return processSeparateLineComments(commentGroup);
|
||||
if (isStarredBlockComment(commentGroup))
|
||||
return processStarredBlockComment(firstComment);
|
||||
return processBareBlockComment(firstComment);
|
||||
}
|
||||
function getInitialOffset(comment) {
|
||||
return sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]);
|
||||
}
|
||||
function convertToStarredBlock(firstComment, commentLinesList) {
|
||||
const initialOffset = getInitialOffset(firstComment);
|
||||
return `/*
|
||||
${commentLinesList.map((line) => `${initialOffset} * ${line}`).join("\n")}
|
||||
${initialOffset} */`;
|
||||
}
|
||||
function convertToSeparateLines(firstComment, commentLinesList) {
|
||||
return commentLinesList.map((line) => `// ${line}`).join(`
|
||||
${getInitialOffset(firstComment)}`);
|
||||
}
|
||||
function convertToBlock(firstComment, commentLinesList) {
|
||||
return `/* ${commentLinesList.join(`
|
||||
${getInitialOffset(firstComment)} `)} */`;
|
||||
}
|
||||
const commentGroupCheckers = {
|
||||
"starred-block": function(commentGroup) {
|
||||
const [firstComment] = commentGroup;
|
||||
const commentLines = getCommentLines(commentGroup);
|
||||
if (commentLines.some((value) => value.includes("*/")))
|
||||
return;
|
||||
if (commentGroup.length > 1) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: firstComment.loc.start,
|
||||
end: commentGroup.at(-1).loc.end
|
||||
},
|
||||
messageId: "expectedBlock",
|
||||
fix(fixer) {
|
||||
const range = [firstComment.range[0], commentGroup.at(-1).range[1]];
|
||||
return commentLines.some((value) => value.startsWith("/")) ? null : fixer.replaceTextRange(range, convertToStarredBlock(firstComment, commentLines));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const lines = firstComment.value.split(LINEBREAK_MATCHER);
|
||||
const expectedLeadingWhitespace = getInitialOffset(firstComment);
|
||||
const expectedLinePrefix = `${expectedLeadingWhitespace} *`;
|
||||
if (!/^\*?\s*$/u.test(lines[0])) {
|
||||
const start = firstComment.value.startsWith("*") ? firstComment.range[0] + 1 : firstComment.range[0];
|
||||
context.report({
|
||||
loc: {
|
||||
start: firstComment.loc.start,
|
||||
end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 }
|
||||
},
|
||||
messageId: "startNewline",
|
||||
fix: (fixer) => fixer.insertTextAfterRange([start, start + 2], `
|
||||
${expectedLinePrefix}`)
|
||||
});
|
||||
}
|
||||
if (!/^\s*$/u.test(lines.at(-1))) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: { line: firstComment.loc.end.line, column: firstComment.loc.end.column - 2 },
|
||||
end: firstComment.loc.end
|
||||
},
|
||||
messageId: "endNewline",
|
||||
fix: (fixer) => fixer.replaceTextRange([firstComment.range[1] - 2, firstComment.range[1]], `
|
||||
${expectedLinePrefix}/`)
|
||||
});
|
||||
}
|
||||
for (let lineNumber = firstComment.loc.start.line + 1; lineNumber <= firstComment.loc.end.line; lineNumber++) {
|
||||
const lineText = sourceCode.lines[lineNumber - 1];
|
||||
const errorType = isStarredCommentLine(lineText) ? "alignment" : "missingStar";
|
||||
if (!lineText.startsWith(expectedLinePrefix)) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: { line: lineNumber, column: 0 },
|
||||
end: { line: lineNumber, column: lineText.length }
|
||||
},
|
||||
messageId: errorType,
|
||||
fix(fixer) {
|
||||
const lineStartIndex = sourceCode.getIndexFromLoc({ line: lineNumber, column: 0 });
|
||||
if (errorType === "alignment") {
|
||||
const [, commentTextPrefix2 = ""] = lineText.match(/^(\s*\*)/u) || [];
|
||||
const commentTextStartIndex2 = lineStartIndex + commentTextPrefix2.length;
|
||||
return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex2], expectedLinePrefix);
|
||||
}
|
||||
const [, commentTextPrefix = ""] = lineText.match(/^(\s*)/u) || [];
|
||||
const commentTextStartIndex = lineStartIndex + commentTextPrefix.length;
|
||||
let offset;
|
||||
for (const [idx, line] of lines.entries()) {
|
||||
if (!/\S+/u.test(line))
|
||||
continue;
|
||||
const lineTextToAlignWith = sourceCode.lines[firstComment.loc.start.line - 1 + idx];
|
||||
const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || [];
|
||||
offset = `${commentTextPrefix.slice(prefix.length)}${initialOffset}`;
|
||||
if (/^\s*\//u.test(lineText) && offset.length === 0)
|
||||
offset += " ";
|
||||
break;
|
||||
}
|
||||
return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], `${expectedLinePrefix}${offset}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"separate-lines": function(commentGroup) {
|
||||
const [firstComment] = commentGroup;
|
||||
const isJSDoc = isJSDocComment(commentGroup);
|
||||
if (firstComment.type !== "Block" || !checkJSDoc && isJSDoc)
|
||||
return;
|
||||
let commentLines = getCommentLines(commentGroup);
|
||||
if (isJSDoc)
|
||||
commentLines = commentLines.slice(1, commentLines.length - 1);
|
||||
const tokenAfter = sourceCode.getTokenAfter(firstComment, { includeComments: true });
|
||||
if (tokenAfter && firstComment.loc.end.line === tokenAfter.loc.start.line)
|
||||
return;
|
||||
context.report({
|
||||
loc: {
|
||||
start: firstComment.loc.start,
|
||||
end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 }
|
||||
},
|
||||
messageId: "expectedLines",
|
||||
fix(fixer) {
|
||||
return fixer.replaceText(firstComment, convertToSeparateLines(firstComment, commentLines));
|
||||
}
|
||||
});
|
||||
},
|
||||
"bare-block": function(commentGroup) {
|
||||
if (isJSDocComment(commentGroup))
|
||||
return;
|
||||
const [firstComment] = commentGroup;
|
||||
const commentLines = getCommentLines(commentGroup);
|
||||
if (firstComment.type === "Line" && commentLines.length > 1 && !commentLines.some((value) => value.includes("*/"))) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: firstComment.loc.start,
|
||||
end: commentGroup.at(-1).loc.end
|
||||
},
|
||||
messageId: "expectedBlock",
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange(
|
||||
[firstComment.range[0], commentGroup.at(-1).range[1]],
|
||||
convertToBlock(firstComment, commentLines)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isStarredBlockComment(commentGroup)) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: firstComment.loc.start,
|
||||
end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 }
|
||||
},
|
||||
messageId: "expectedBareBlock",
|
||||
fix(fixer) {
|
||||
return fixer.replaceText(firstComment, convertToBlock(firstComment, commentLines));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
Program() {
|
||||
return sourceCode.getAllComments().filter((comment) => comment.type !== "Shebang").filter((comment) => !COMMENTS_IGNORE_PATTERN.test(comment.value)).filter((comment) => {
|
||||
const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true });
|
||||
return !tokenBefore || tokenBefore.loc.end.line < comment.loc.start.line;
|
||||
}).reduce((commentGroups, comment, index, commentList) => {
|
||||
const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true });
|
||||
if (comment.type === "Line" && index && commentList[index - 1].type === "Line" && tokenBefore && tokenBefore.loc.end.line === comment.loc.start.line - 1 && tokenBefore === commentList[index - 1]) {
|
||||
commentGroups.at(-1).push(comment);
|
||||
} else {
|
||||
commentGroups.push([comment]);
|
||||
}
|
||||
return commentGroups;
|
||||
}, []).filter((commentGroup) => !(commentGroup.length === 1 && commentGroup[0].loc.start.line === commentGroup[0].loc.end.line)).forEach(commentGroupCheckers[option]);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { multilineCommentStyle as default };
|
||||
146
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/multiline-ternary.js
generated
vendored
Normal file
146
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/multiline-ternary.js
generated
vendored
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
import { c as createRule, o as isNotClosingParenToken, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var multilineTernary = createRule({
|
||||
name: "multiline-ternary",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce newlines between operands of ternary expressions"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "always-multiline", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
ignoreJSX: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expectedTestCons: "Expected newline between test and consequent of ternary expression.",
|
||||
expectedConsAlt: "Expected newline between consequent and alternate of ternary expression.",
|
||||
unexpectedTestCons: "Unexpected newline between test and consequent of ternary expression.",
|
||||
unexpectedConsAlt: "Unexpected newline between consequent and alternate of ternary expression."
|
||||
},
|
||||
fixable: "whitespace"
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const multiline = context.options[0] !== "never";
|
||||
const allowSingleLine = context.options[0] === "always-multiline";
|
||||
const IGNORE_JSX = context.options[1] && context.options[1].ignoreJSX;
|
||||
return {
|
||||
ConditionalExpression(node) {
|
||||
const questionToken = sourceCode.getTokenAfter(node.test, isNotClosingParenToken);
|
||||
const colonToken = sourceCode.getTokenAfter(node.consequent, isNotClosingParenToken);
|
||||
const firstTokenOfTest = sourceCode.getFirstToken(node);
|
||||
const lastTokenOfTest = sourceCode.getTokenBefore(questionToken);
|
||||
const firstTokenOfConsequent = sourceCode.getTokenAfter(questionToken);
|
||||
const lastTokenOfConsequent = sourceCode.getTokenBefore(colonToken);
|
||||
const firstTokenOfAlternate = sourceCode.getTokenAfter(colonToken);
|
||||
const areTestAndConsequentOnSameLine = isTokenOnSameLine(lastTokenOfTest, firstTokenOfConsequent);
|
||||
const areConsequentAndAlternateOnSameLine = isTokenOnSameLine(lastTokenOfConsequent, firstTokenOfAlternate);
|
||||
const hasComments = !!sourceCode.getCommentsInside(node).length;
|
||||
if (IGNORE_JSX) {
|
||||
if (node.parent.type === "JSXElement" || node.parent.type === "JSXFragment" || node.parent.type === "JSXExpressionContainer") {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!multiline) {
|
||||
if (!areTestAndConsequentOnSameLine) {
|
||||
context.report({
|
||||
node: node.test,
|
||||
loc: {
|
||||
start: firstTokenOfTest.loc.start,
|
||||
end: lastTokenOfTest.loc.end
|
||||
},
|
||||
messageId: "unexpectedTestCons",
|
||||
fix(fixer) {
|
||||
if (hasComments)
|
||||
return null;
|
||||
const fixers = [];
|
||||
const areTestAndQuestionOnSameLine = isTokenOnSameLine(lastTokenOfTest, questionToken);
|
||||
const areQuestionAndConsOnSameLine = isTokenOnSameLine(questionToken, firstTokenOfConsequent);
|
||||
if (!areTestAndQuestionOnSameLine)
|
||||
fixers.push(fixer.removeRange([lastTokenOfTest.range[1], questionToken.range[0]]));
|
||||
if (!areQuestionAndConsOnSameLine)
|
||||
fixers.push(fixer.removeRange([questionToken.range[1], firstTokenOfConsequent.range[0]]));
|
||||
return fixers;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!areConsequentAndAlternateOnSameLine) {
|
||||
context.report({
|
||||
node: node.consequent,
|
||||
loc: {
|
||||
start: firstTokenOfConsequent.loc.start,
|
||||
end: lastTokenOfConsequent.loc.end
|
||||
},
|
||||
messageId: "unexpectedConsAlt",
|
||||
fix(fixer) {
|
||||
if (hasComments)
|
||||
return null;
|
||||
const fixers = [];
|
||||
const areConsAndColonOnSameLine = isTokenOnSameLine(lastTokenOfConsequent, colonToken);
|
||||
const areColonAndAltOnSameLine = isTokenOnSameLine(colonToken, firstTokenOfAlternate);
|
||||
if (!areConsAndColonOnSameLine)
|
||||
fixers.push(fixer.removeRange([lastTokenOfConsequent.range[1], colonToken.range[0]]));
|
||||
if (!areColonAndAltOnSameLine)
|
||||
fixers.push(fixer.removeRange([colonToken.range[1], firstTokenOfAlternate.range[0]]));
|
||||
return fixers;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (allowSingleLine && node.loc.start.line === node.loc.end.line)
|
||||
return;
|
||||
if (areTestAndConsequentOnSameLine) {
|
||||
context.report({
|
||||
node: node.test,
|
||||
loc: {
|
||||
start: firstTokenOfTest.loc.start,
|
||||
end: lastTokenOfTest.loc.end
|
||||
},
|
||||
messageId: "expectedTestCons",
|
||||
fix: (fixer) => hasComments ? null : fixer.replaceTextRange(
|
||||
[
|
||||
lastTokenOfTest.range[1],
|
||||
questionToken.range[0]
|
||||
],
|
||||
"\n"
|
||||
)
|
||||
});
|
||||
}
|
||||
if (areConsequentAndAlternateOnSameLine) {
|
||||
context.report({
|
||||
node: node.consequent,
|
||||
loc: {
|
||||
start: firstTokenOfConsequent.loc.start,
|
||||
end: lastTokenOfConsequent.loc.end
|
||||
},
|
||||
messageId: "expectedConsAlt",
|
||||
fix: (fixer) => hasComments ? null : fixer.replaceTextRange(
|
||||
[
|
||||
lastTokenOfConsequent.range[1],
|
||||
colonToken.range[0]
|
||||
],
|
||||
"\n"
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { multilineTernary as default };
|
||||
64
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/new-parens.js
generated
vendored
Normal file
64
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/new-parens.js
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { c as createRule, f as isClosingParenToken, e as isOpeningParenToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var newParens = createRule({
|
||||
name: "new-parens",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce or disallow parentheses when invoking a constructor with no arguments"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missing: "Missing '()' invoking a constructor.",
|
||||
unnecessary: "Unnecessary '()' invoking a constructor with no arguments."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = context.options;
|
||||
const always = options[0] !== "never";
|
||||
const sourceCode = context.sourceCode;
|
||||
return {
|
||||
NewExpression(node) {
|
||||
if (node.arguments.length !== 0)
|
||||
return;
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
const hasLastParen = lastToken && isClosingParenToken(lastToken);
|
||||
const tokenBeforeLastToken = sourceCode.getTokenBefore(lastToken);
|
||||
const hasParens = hasLastParen && isOpeningParenToken(tokenBeforeLastToken) && node.callee.range[1] < node.range[1];
|
||||
if (always) {
|
||||
if (!hasParens) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "missing",
|
||||
fix: (fixer) => fixer.insertTextAfter(node, "()")
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (hasParens) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unnecessary",
|
||||
fix: (fixer) => [
|
||||
fixer.remove(tokenBeforeLastToken),
|
||||
fixer.remove(lastToken),
|
||||
fixer.insertTextBefore(node, "("),
|
||||
fixer.insertTextAfter(node, ")")
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { newParens as default };
|
||||
86
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/newline-per-chained-call.js
generated
vendored
Normal file
86
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/newline-per-chained-call.js
generated
vendored
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import { c as createRule, G as skipChainExpression, i as isTokenOnSameLine, o as isNotClosingParenToken, L as LINEBREAK_MATCHER } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var newlinePerChainedCall = createRule({
|
||||
name: "newline-per-chained-call",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require a newline after each call in a method chain"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [{
|
||||
type: "object",
|
||||
properties: {
|
||||
ignoreChainWithDepth: {
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
maximum: 10,
|
||||
default: 2
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}],
|
||||
messages: {
|
||||
expected: "Expected line break before `{{callee}}`."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = context.options[0] || {};
|
||||
const ignoreChainWithDepth = options.ignoreChainWithDepth || 2;
|
||||
const sourceCode = context.sourceCode;
|
||||
function getPrefix(node) {
|
||||
if (node.computed) {
|
||||
if (node.optional)
|
||||
return "?.[";
|
||||
return "[";
|
||||
}
|
||||
if (node.optional)
|
||||
return "?.";
|
||||
return ".";
|
||||
}
|
||||
function getPropertyText(node) {
|
||||
const prefix = getPrefix(node);
|
||||
const lines = sourceCode.getText(node.property).split(LINEBREAK_MATCHER);
|
||||
const suffix = node.computed && lines.length === 1 ? "]" : "";
|
||||
return prefix + lines[0] + suffix;
|
||||
}
|
||||
return {
|
||||
"CallExpression:exit": function(node) {
|
||||
const callee = skipChainExpression(node.callee);
|
||||
if (callee.type !== "MemberExpression")
|
||||
return;
|
||||
let parent = skipChainExpression(callee.object);
|
||||
let depth = 1;
|
||||
while (parent && "callee" in parent && parent.callee) {
|
||||
depth += 1;
|
||||
const parentCallee = skipChainExpression(parent.callee);
|
||||
if (!("object" in parentCallee))
|
||||
break;
|
||||
parent = skipChainExpression(parentCallee.object);
|
||||
}
|
||||
if (depth > ignoreChainWithDepth && isTokenOnSameLine(callee.object, callee.property)) {
|
||||
const firstTokenAfterObject = sourceCode.getTokenAfter(callee.object, isNotClosingParenToken);
|
||||
context.report({
|
||||
node: callee.property,
|
||||
loc: {
|
||||
start: firstTokenAfterObject.loc.start,
|
||||
end: callee.loc.end
|
||||
},
|
||||
messageId: "expected",
|
||||
data: {
|
||||
callee: getPropertyText(callee)
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(firstTokenAfterObject, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { newlinePerChainedCall as default };
|
||||
52
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-confusing-arrow.js
generated
vendored
Normal file
52
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-confusing-arrow.js
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { c as createRule, H as isParenthesised } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
function isConditional(node) {
|
||||
return node.type === "ConditionalExpression";
|
||||
}
|
||||
var noConfusingArrow = createRule({
|
||||
name: "no-confusing-arrow",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow arrow functions where they could be confused with comparisons"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowParens: { type: "boolean", default: true },
|
||||
onlyOneSimpleParam: { type: "boolean", default: false }
|
||||
},
|
||||
additionalProperties: false
|
||||
}],
|
||||
messages: {
|
||||
confusing: "Arrow function used ambiguously with a conditional expression."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const config = context.options[0] || {};
|
||||
const allowParens = config.allowParens || config.allowParens === void 0;
|
||||
const onlyOneSimpleParam = config.onlyOneSimpleParam;
|
||||
const sourceCode = context.sourceCode;
|
||||
function checkArrowFunc(node) {
|
||||
const body = node.body;
|
||||
if (isConditional(body) && !(allowParens && isParenthesised(sourceCode, body)) && !(onlyOneSimpleParam && !(node.params.length === 1 && node.params[0].type === "Identifier"))) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "confusing",
|
||||
fix(fixer) {
|
||||
return allowParens ? fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`) : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrowFunctionExpression: checkArrowFunc
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noConfusingArrow as default };
|
||||
656
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-extra-parens.js
generated
vendored
Normal file
656
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-extra-parens.js
generated
vendored
Normal file
|
|
@ -0,0 +1,656 @@
|
|||
import { c as createRule, I as getPrecedence, J as isDecimalInteger, n as isNotOpeningParenToken, l as isOpeningBracketToken, o as isNotClosingParenToken, e as isOpeningParenToken, v as isOpeningBraceToken, G as skipChainExpression, C as getStaticPropertyName, M as isParenthesized, f as isClosingParenToken, N as isMixedLogicalAndCoalesceExpressions, d as canTokensBeAdjacent, O as isTopLevelExpressionStatement } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noExtraParens = createRule({
|
||||
name: "no-extra-parens",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow unnecessary parentheses"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["functions"]
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 1
|
||||
},
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["all"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
conditionalAssign: { type: "boolean" },
|
||||
ternaryOperandBinaryExpressions: { type: "boolean" },
|
||||
nestedBinaryExpressions: { type: "boolean" },
|
||||
returnAssign: { type: "boolean" },
|
||||
ignoreJSX: { type: "string", enum: ["none", "all", "single-line", "multi-line"] },
|
||||
enforceForArrowConditionals: { type: "boolean" },
|
||||
enforceForSequenceExpressions: { type: "boolean" },
|
||||
enforceForNewInMemberExpressions: { type: "boolean" },
|
||||
enforceForFunctionPrototypeMethods: { type: "boolean" },
|
||||
allowParensAfterCommentPattern: { type: "string" },
|
||||
nestedConditionalExpressions: { type: "boolean" }
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2
|
||||
}
|
||||
]
|
||||
},
|
||||
messages: {
|
||||
unexpected: "Unnecessary parentheses around expression."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const tokensToIgnore = /* @__PURE__ */ new WeakSet();
|
||||
const precedence = getPrecedence;
|
||||
const ALL_NODES = context.options[0] !== "functions";
|
||||
const EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false;
|
||||
const EXCEPT_COND_TERNARY = ALL_NODES && context.options[1] && context.options[1].ternaryOperandBinaryExpressions === false;
|
||||
const NESTED_BINARY = ALL_NODES && context.options[1] && context.options[1].nestedBinaryExpressions === false;
|
||||
const EXCEPT_RETURN_ASSIGN = ALL_NODES && context.options[1] && context.options[1].returnAssign === false;
|
||||
const IGNORE_JSX = ALL_NODES && context.options[1] && context.options[1].ignoreJSX;
|
||||
const IGNORE_ARROW_CONDITIONALS = ALL_NODES && context.options[1] && context.options[1].enforceForArrowConditionals === false;
|
||||
const IGNORE_SEQUENCE_EXPRESSIONS = ALL_NODES && context.options[1] && context.options[1].enforceForSequenceExpressions === false;
|
||||
const IGNORE_NEW_IN_MEMBER_EXPR = ALL_NODES && context.options[1] && context.options[1].enforceForNewInMemberExpressions === false;
|
||||
const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] && context.options[1].enforceForFunctionPrototypeMethods === false;
|
||||
const ALLOW_PARENS_AFTER_COMMENT_PATTERN = ALL_NODES && context.options[1] && context.options[1].allowParensAfterCommentPattern;
|
||||
const ALLOW_NESTED_TERNARY = ALL_NODES && context.options[1] && context.options[1].nestedConditionalExpressions === false;
|
||||
const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({ type: "AssignmentExpression" });
|
||||
const PRECEDENCE_OF_UPDATE_EXPR = precedence({ type: "UpdateExpression" });
|
||||
let reportsBuffer;
|
||||
function isImmediateFunctionPrototypeMethodCall(node) {
|
||||
const callNode = skipChainExpression(node);
|
||||
if (callNode.type !== "CallExpression")
|
||||
return false;
|
||||
const callee = skipChainExpression(callNode.callee);
|
||||
return callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && ["call", "apply"].includes(getStaticPropertyName(callee));
|
||||
}
|
||||
function ruleApplies(node) {
|
||||
if (node.type === "JSXElement" || node.type === "JSXFragment") {
|
||||
const isSingleLine = node.loc.start.line === node.loc.end.line;
|
||||
switch (IGNORE_JSX) {
|
||||
// Exclude this JSX element from linting
|
||||
case "all":
|
||||
return false;
|
||||
// Exclude this JSX element if it is multi-line element
|
||||
case "multi-line":
|
||||
return isSingleLine;
|
||||
// Exclude this JSX element if it is single-line element
|
||||
case "single-line":
|
||||
return !isSingleLine;
|
||||
}
|
||||
}
|
||||
if (node.type === "SequenceExpression" && IGNORE_SEQUENCE_EXPRESSIONS)
|
||||
return false;
|
||||
if (isImmediateFunctionPrototypeMethodCall(node) && IGNORE_FUNCTION_PROTOTYPE_METHODS)
|
||||
return false;
|
||||
return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
|
||||
}
|
||||
function isParenthesised(node) {
|
||||
return isParenthesized(node, sourceCode, 1);
|
||||
}
|
||||
function isParenthesisedTwice(node) {
|
||||
return isParenthesized(node, sourceCode, 2);
|
||||
}
|
||||
function hasExcessParens(node) {
|
||||
return ruleApplies(node) && isParenthesised(node);
|
||||
}
|
||||
function hasDoubleExcessParens(node) {
|
||||
return ruleApplies(node) && isParenthesisedTwice(node);
|
||||
}
|
||||
function hasExcessParensWithPrecedence(node, precedenceLowerLimit) {
|
||||
if (ruleApplies(node) && isParenthesised(node)) {
|
||||
if (precedence(node) >= precedenceLowerLimit || isParenthesisedTwice(node)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isCondAssignException(node) {
|
||||
return EXCEPT_COND_ASSIGN && node.test && node.test.type === "AssignmentExpression";
|
||||
}
|
||||
function isInReturnStatement(node) {
|
||||
for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
|
||||
if (currentNode.type === "ReturnStatement" || currentNode.type === "ArrowFunctionExpression" && currentNode.body.type !== "BlockStatement") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isNewExpressionWithParens(newExpression) {
|
||||
const lastToken = sourceCode.getLastToken(newExpression);
|
||||
const penultimateToken = sourceCode.getTokenBefore(lastToken);
|
||||
return newExpression.arguments.length > 0 || // The expression should end with its own parens, e.g., new new foo() is not a new expression with parens
|
||||
isOpeningParenToken(penultimateToken) && isClosingParenToken(lastToken) && newExpression.callee.range[1] < newExpression.range[1];
|
||||
}
|
||||
function containsAssignment(node) {
|
||||
if (node.type === "AssignmentExpression")
|
||||
return true;
|
||||
if (node.type === "ConditionalExpression" && (node.consequent.type === "AssignmentExpression" || node.alternate.type === "AssignmentExpression")) {
|
||||
return true;
|
||||
}
|
||||
if ("left" in node && (node.left && node.left.type === "AssignmentExpression" || node.right && node.right.type === "AssignmentExpression")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isReturnAssignException(node) {
|
||||
if (!EXCEPT_RETURN_ASSIGN || !isInReturnStatement(node))
|
||||
return false;
|
||||
if (node.type === "ReturnStatement")
|
||||
return node.argument && containsAssignment(node.argument);
|
||||
if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement")
|
||||
return containsAssignment(node.body);
|
||||
return containsAssignment(node);
|
||||
}
|
||||
function hasExcessParensNoLineTerminator(token, node) {
|
||||
if (token.loc.end.line === node.loc.start.line)
|
||||
return hasExcessParens(node);
|
||||
return hasDoubleExcessParens(node);
|
||||
}
|
||||
function requiresLeadingSpace(node) {
|
||||
const leftParenToken = sourceCode.getTokenBefore(node);
|
||||
const tokenBeforeLeftParen = sourceCode.getTokenBefore(leftParenToken, { includeComments: true });
|
||||
const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParenToken, { includeComments: true });
|
||||
return tokenBeforeLeftParen && tokenBeforeLeftParen.range[1] === leftParenToken.range[0] && leftParenToken.range[1] === tokenAfterLeftParen.range[0] && !canTokensBeAdjacent(tokenBeforeLeftParen, tokenAfterLeftParen);
|
||||
}
|
||||
function requiresTrailingSpace(node) {
|
||||
const nextTwoTokens = sourceCode.getTokensAfter(node, { count: 2 });
|
||||
const rightParenToken = nextTwoTokens[0];
|
||||
const tokenAfterRightParen = nextTwoTokens[1];
|
||||
const tokenBeforeRightParen = sourceCode.getLastToken(node);
|
||||
return rightParenToken && tokenAfterRightParen && !sourceCode.isSpaceBetween(rightParenToken, tokenAfterRightParen) && !canTokensBeAdjacent(tokenBeforeRightParen, tokenAfterRightParen);
|
||||
}
|
||||
function isIIFE(node) {
|
||||
const maybeCallNode = skipChainExpression(node);
|
||||
return maybeCallNode.type === "CallExpression" && maybeCallNode.callee.type === "FunctionExpression";
|
||||
}
|
||||
function canBeAssignmentTarget(node) {
|
||||
return !!(node && (node.type === "Identifier" || node.type === "MemberExpression"));
|
||||
}
|
||||
function isFixable(node) {
|
||||
if (node.type !== "Literal" || typeof node.value !== "string")
|
||||
return true;
|
||||
if (isParenthesisedTwice(node))
|
||||
return true;
|
||||
return !isTopLevelExpressionStatement(node.parent);
|
||||
}
|
||||
function report(node) {
|
||||
const leftParenToken = sourceCode.getTokenBefore(node);
|
||||
const rightParenToken = sourceCode.getTokenAfter(node);
|
||||
if (!isParenthesisedTwice(node)) {
|
||||
if (tokensToIgnore.has(sourceCode.getFirstToken(node)))
|
||||
return;
|
||||
if (isIIFE(node) && !("callee" in node && isParenthesised(node.callee)))
|
||||
return;
|
||||
if (ALLOW_PARENS_AFTER_COMMENT_PATTERN) {
|
||||
const commentsBeforeLeftParenToken = sourceCode.getCommentsBefore(leftParenToken);
|
||||
const totalCommentsBeforeLeftParenTokenCount = commentsBeforeLeftParenToken.length;
|
||||
const ignorePattern = new RegExp(ALLOW_PARENS_AFTER_COMMENT_PATTERN, "u");
|
||||
if (totalCommentsBeforeLeftParenTokenCount > 0 && ignorePattern.test(commentsBeforeLeftParenToken[totalCommentsBeforeLeftParenTokenCount - 1].value)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
function finishReport() {
|
||||
context.report({
|
||||
node,
|
||||
loc: leftParenToken.loc,
|
||||
messageId: "unexpected",
|
||||
fix: isFixable(node) ? (fixer) => {
|
||||
const parenthesizedSource = sourceCode.text.slice(leftParenToken.range[1], rightParenToken.range[0]);
|
||||
return fixer.replaceTextRange([
|
||||
leftParenToken.range[0],
|
||||
rightParenToken.range[1]
|
||||
], (requiresLeadingSpace(node) ? " " : "") + parenthesizedSource + (requiresTrailingSpace(node) ? " " : ""));
|
||||
} : null
|
||||
});
|
||||
}
|
||||
if (reportsBuffer) {
|
||||
reportsBuffer.reports.push({ node, finishReport });
|
||||
return;
|
||||
}
|
||||
finishReport();
|
||||
}
|
||||
function checkArgumentWithPrecedence(node) {
|
||||
if ("argument" in node && node.argument && hasExcessParensWithPrecedence(node.argument, precedence(node)))
|
||||
report(node.argument);
|
||||
}
|
||||
function doesMemberExpressionContainCallExpression(node) {
|
||||
let currentNode = node.object;
|
||||
let currentNodeType = node.object.type;
|
||||
while (currentNodeType === "MemberExpression") {
|
||||
if (!("object" in currentNode))
|
||||
break;
|
||||
currentNode = currentNode.object;
|
||||
currentNodeType = currentNode.type;
|
||||
}
|
||||
return currentNodeType === "CallExpression";
|
||||
}
|
||||
function checkCallNew(node) {
|
||||
const callee = node.callee;
|
||||
if (hasExcessParensWithPrecedence(callee, precedence(node))) {
|
||||
if (hasDoubleExcessParens(callee) || !(isIIFE(node) || callee.type === "NewExpression" && !isNewExpressionWithParens(callee) && !(node.type === "NewExpression" && !isNewExpressionWithParens(node)) || node.type === "NewExpression" && callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee) || (!("optional" in node) || !node.optional) && callee.type === "ChainExpression")) {
|
||||
report(node.callee);
|
||||
}
|
||||
}
|
||||
node.arguments.filter((arg) => hasExcessParensWithPrecedence(arg, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report);
|
||||
}
|
||||
function checkBinaryLogical(node) {
|
||||
const prec = precedence(node);
|
||||
const leftPrecedence = precedence(node.left);
|
||||
const rightPrecedence = precedence(node.right);
|
||||
const isExponentiation = node.operator === "**";
|
||||
const shouldSkipLeft = NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression");
|
||||
const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression");
|
||||
if (!shouldSkipLeft && hasExcessParens(node.left)) {
|
||||
if (!(["AwaitExpression", "UnaryExpression"].includes(node.left.type) && isExponentiation) && !isMixedLogicalAndCoalesceExpressions(node.left, node) && (leftPrecedence > prec || leftPrecedence === prec && !isExponentiation) || isParenthesisedTwice(node.left)) {
|
||||
report(node.left);
|
||||
}
|
||||
}
|
||||
if (!shouldSkipRight && hasExcessParens(node.right)) {
|
||||
if (!isMixedLogicalAndCoalesceExpressions(node.right, node) && (rightPrecedence > prec || rightPrecedence === prec && isExponentiation) || isParenthesisedTwice(node.right)) {
|
||||
report(node.right);
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkClass(node) {
|
||||
if (!node.superClass)
|
||||
return;
|
||||
const hasExtraParens = precedence(node.superClass) > PRECEDENCE_OF_UPDATE_EXPR ? hasExcessParens(node.superClass) : hasDoubleExcessParens(node.superClass);
|
||||
if (hasExtraParens)
|
||||
report(node.superClass);
|
||||
}
|
||||
function checkSpreadOperator(node) {
|
||||
if (hasExcessParensWithPrecedence(node.argument, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(node.argument);
|
||||
}
|
||||
function checkExpressionOrExportStatement(node) {
|
||||
const firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node);
|
||||
const secondToken = sourceCode.getTokenAfter(firstToken, isNotOpeningParenToken);
|
||||
const thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null;
|
||||
const tokenAfterClosingParens = secondToken ? sourceCode.getTokenAfter(secondToken, isNotClosingParenToken) : null;
|
||||
if (isOpeningParenToken(firstToken) && (isOpeningBraceToken(secondToken) || secondToken.type === "Keyword" && (secondToken.value === "function" || secondToken.value === "class" || secondToken.value === "let" && tokenAfterClosingParens && (isOpeningBracketToken(tokenAfterClosingParens) || tokenAfterClosingParens.type === "Identifier")) || secondToken && secondToken.type === "Identifier" && secondToken.value === "async" && thirdToken && thirdToken.type === "Keyword" && thirdToken.value === "function")) {
|
||||
tokensToIgnore.add(secondToken);
|
||||
}
|
||||
const hasExtraParens = node.parent.type === "ExportDefaultDeclaration" ? hasExcessParensWithPrecedence(node, PRECEDENCE_OF_ASSIGNMENT_EXPR) : hasExcessParens(node);
|
||||
if (hasExtraParens)
|
||||
report(node);
|
||||
}
|
||||
function pathToAncestor(node, ancestor) {
|
||||
const path = [node];
|
||||
let currentNode = node;
|
||||
while (currentNode !== ancestor) {
|
||||
currentNode = currentNode.parent;
|
||||
if (currentNode === null || currentNode === void 0)
|
||||
throw new Error("Nodes are not in the ancestor-descendant relationship.");
|
||||
path.push(currentNode);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
function pathToDescendant(node, descendant) {
|
||||
return pathToAncestor(descendant, node).reverse();
|
||||
}
|
||||
function isSafelyEnclosingInExpression(node, child) {
|
||||
switch (node.type) {
|
||||
case "ArrayExpression":
|
||||
case "ArrayPattern":
|
||||
case "BlockStatement":
|
||||
case "ObjectExpression":
|
||||
case "ObjectPattern":
|
||||
case "TemplateLiteral":
|
||||
return true;
|
||||
case "ArrowFunctionExpression":
|
||||
case "FunctionExpression":
|
||||
return node.params.includes(child);
|
||||
case "CallExpression":
|
||||
case "NewExpression":
|
||||
return node.arguments.includes(child);
|
||||
case "MemberExpression":
|
||||
return node.computed && node.property === child;
|
||||
case "ConditionalExpression":
|
||||
return node.consequent === child;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function startNewReportsBuffering() {
|
||||
reportsBuffer = {
|
||||
upper: reportsBuffer,
|
||||
inExpressionNodes: [],
|
||||
reports: []
|
||||
};
|
||||
}
|
||||
function endCurrentReportsBuffering() {
|
||||
const { upper, inExpressionNodes, reports } = reportsBuffer ?? {};
|
||||
if (upper) {
|
||||
upper.inExpressionNodes.push(...inExpressionNodes ?? []);
|
||||
upper.reports.push(...reports ?? []);
|
||||
} else {
|
||||
reports?.forEach(({ finishReport }) => finishReport());
|
||||
}
|
||||
reportsBuffer = upper;
|
||||
}
|
||||
function isInCurrentReportsBuffer(node) {
|
||||
return reportsBuffer?.reports.some((r) => r.node === node);
|
||||
}
|
||||
function removeFromCurrentReportsBuffer(node) {
|
||||
if (reportsBuffer)
|
||||
reportsBuffer.reports = reportsBuffer.reports.filter((r) => r.node !== node);
|
||||
}
|
||||
function isMemberExpInNewCallee(node) {
|
||||
if (node.type === "MemberExpression") {
|
||||
return node.parent.type === "NewExpression" && node.parent.callee === node ? true : "object" in node.parent && node.parent.object === node && isMemberExpInNewCallee(node.parent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isAnonymousFunctionAssignmentException({ left, operator, right }) {
|
||||
if (left.type === "Identifier" && ["=", "&&=", "||=", "??="].includes(operator)) {
|
||||
const rhsType = right.type;
|
||||
if (rhsType === "ArrowFunctionExpression")
|
||||
return true;
|
||||
if ((rhsType === "FunctionExpression" || rhsType === "ClassExpression") && !right.id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
ArrayExpression(node) {
|
||||
node.elements.filter((e) => !!e && hasExcessParensWithPrecedence(e, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report);
|
||||
},
|
||||
ArrayPattern(node) {
|
||||
node.elements.filter((e) => !!e && canBeAssignmentTarget(e) && hasExcessParens(e)).forEach(report);
|
||||
},
|
||||
ArrowFunctionExpression(node) {
|
||||
if (isReturnAssignException(node))
|
||||
return;
|
||||
if (node.body.type === "ConditionalExpression" && IGNORE_ARROW_CONDITIONALS) {
|
||||
return;
|
||||
}
|
||||
if (node.body.type !== "BlockStatement") {
|
||||
const firstBodyToken = sourceCode.getFirstToken(node.body, isNotOpeningParenToken);
|
||||
const tokenBeforeFirst = sourceCode.getTokenBefore(firstBodyToken);
|
||||
if (isOpeningParenToken(tokenBeforeFirst) && isOpeningBraceToken(firstBodyToken))
|
||||
tokensToIgnore.add(firstBodyToken);
|
||||
if (hasExcessParensWithPrecedence(node.body, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(node.body);
|
||||
}
|
||||
},
|
||||
AssignmentExpression(node) {
|
||||
if (canBeAssignmentTarget(node.left) && hasExcessParens(node.left) && (!isAnonymousFunctionAssignmentException(node) || isParenthesisedTwice(node.left))) {
|
||||
report(node.left);
|
||||
}
|
||||
if (!isReturnAssignException(node) && hasExcessParensWithPrecedence(node.right, precedence(node)))
|
||||
report(node.right);
|
||||
},
|
||||
BinaryExpression(node) {
|
||||
if (reportsBuffer && node.operator === "in")
|
||||
reportsBuffer.inExpressionNodes.push(node);
|
||||
checkBinaryLogical(node);
|
||||
},
|
||||
"CallExpression": checkCallNew,
|
||||
ConditionalExpression(node) {
|
||||
if (isReturnAssignException(node))
|
||||
return;
|
||||
const availableTypes = /* @__PURE__ */ new Set(["BinaryExpression", "LogicalExpression"]);
|
||||
if (!(EXCEPT_COND_TERNARY && availableTypes.has(node.test.type)) && !(ALLOW_NESTED_TERNARY && ["ConditionalExpression"].includes(node.test.type)) && !isCondAssignException(node) && hasExcessParensWithPrecedence(node.test, precedence({ type: "LogicalExpression", operator: "||" }))) {
|
||||
report(node.test);
|
||||
}
|
||||
if (!(EXCEPT_COND_TERNARY && availableTypes.has(node.consequent.type)) && !(ALLOW_NESTED_TERNARY && ["ConditionalExpression"].includes(node.consequent.type)) && hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
|
||||
report(node.consequent);
|
||||
}
|
||||
if (!(EXCEPT_COND_TERNARY && availableTypes.has(node.alternate.type)) && !(ALLOW_NESTED_TERNARY && ["ConditionalExpression"].includes(node.alternate.type)) && hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
|
||||
report(node.alternate);
|
||||
}
|
||||
},
|
||||
DoWhileStatement(node) {
|
||||
if (hasExcessParens(node.test) && !isCondAssignException(node))
|
||||
report(node.test);
|
||||
},
|
||||
"ExportDefaultDeclaration": (node) => checkExpressionOrExportStatement(node.declaration),
|
||||
"ExpressionStatement": (node) => checkExpressionOrExportStatement(node.expression),
|
||||
ForInStatement(node) {
|
||||
if (node.left.type !== "VariableDeclaration") {
|
||||
const firstLeftToken = sourceCode.getFirstToken(node.left, isNotOpeningParenToken);
|
||||
if (firstLeftToken.value === "let" && isOpeningBracketToken(
|
||||
sourceCode.getTokenAfter(firstLeftToken, isNotClosingParenToken)
|
||||
)) {
|
||||
tokensToIgnore.add(firstLeftToken);
|
||||
}
|
||||
}
|
||||
if (hasExcessParens(node.left))
|
||||
report(node.left);
|
||||
if (hasExcessParens(node.right))
|
||||
report(node.right);
|
||||
},
|
||||
ForOfStatement(node) {
|
||||
if (node.left.type !== "VariableDeclaration") {
|
||||
const firstLeftToken = sourceCode.getFirstToken(node.left, isNotOpeningParenToken);
|
||||
if (firstLeftToken.value === "let") {
|
||||
tokensToIgnore.add(firstLeftToken);
|
||||
}
|
||||
}
|
||||
if (hasExcessParens(node.left))
|
||||
report(node.left);
|
||||
if (hasExcessParensWithPrecedence(node.right, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(node.right);
|
||||
},
|
||||
ForStatement(node) {
|
||||
if (node.test && hasExcessParens(node.test) && !isCondAssignException(node))
|
||||
report(node.test);
|
||||
if (node.update && hasExcessParens(node.update))
|
||||
report(node.update);
|
||||
if (node.init) {
|
||||
if (node.init.type !== "VariableDeclaration") {
|
||||
const firstToken = sourceCode.getFirstToken(node.init, isNotOpeningParenToken);
|
||||
if (firstToken.value === "let" && isOpeningBracketToken(
|
||||
sourceCode.getTokenAfter(firstToken, isNotClosingParenToken)
|
||||
)) {
|
||||
tokensToIgnore.add(firstToken);
|
||||
}
|
||||
}
|
||||
startNewReportsBuffering();
|
||||
if (hasExcessParens(node.init))
|
||||
report(node.init);
|
||||
}
|
||||
},
|
||||
"ForStatement > *.init:exit": function(node) {
|
||||
if (reportsBuffer?.reports.length) {
|
||||
reportsBuffer.inExpressionNodes.forEach((inExpressionNode) => {
|
||||
const path = pathToDescendant(node, inExpressionNode);
|
||||
let nodeToExclude = null;
|
||||
for (let i = 0; i < path.length; i++) {
|
||||
const pathNode = path[i];
|
||||
if (i < path.length - 1) {
|
||||
const nextPathNode = path[i + 1];
|
||||
if (isSafelyEnclosingInExpression(pathNode, nextPathNode)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isParenthesised(pathNode)) {
|
||||
if (isInCurrentReportsBuffer(pathNode)) {
|
||||
if (isParenthesisedTwice(pathNode)) {
|
||||
return;
|
||||
}
|
||||
if (!nodeToExclude)
|
||||
nodeToExclude = pathNode;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nodeToExclude)
|
||||
removeFromCurrentReportsBuffer(nodeToExclude);
|
||||
});
|
||||
}
|
||||
endCurrentReportsBuffering();
|
||||
},
|
||||
IfStatement(node) {
|
||||
if (hasExcessParens(node.test) && !isCondAssignException(node))
|
||||
report(node.test);
|
||||
},
|
||||
ImportExpression(node) {
|
||||
const { source } = node;
|
||||
if (source.type === "SequenceExpression") {
|
||||
if (hasDoubleExcessParens(source))
|
||||
report(source);
|
||||
} else if (hasExcessParens(source)) {
|
||||
report(source);
|
||||
}
|
||||
},
|
||||
"LogicalExpression": checkBinaryLogical,
|
||||
MemberExpression(node) {
|
||||
const shouldAllowWrapOnce = isMemberExpInNewCallee(node) && doesMemberExpressionContainCallExpression(node);
|
||||
const nodeObjHasExcessParens = shouldAllowWrapOnce ? hasDoubleExcessParens(node.object) : hasExcessParens(node.object) && !(isImmediateFunctionPrototypeMethodCall(node.parent) && "callee" in node.parent && node.parent.callee === node && IGNORE_FUNCTION_PROTOTYPE_METHODS);
|
||||
if (nodeObjHasExcessParens && precedence(node.object) >= precedence(node) && (node.computed || !(isDecimalInteger(node.object) || node.object.type === "Literal" && "regex" in node.object && node.object.regex))) {
|
||||
report(node.object);
|
||||
}
|
||||
if (nodeObjHasExcessParens && node.object.type === "CallExpression") {
|
||||
report(node.object);
|
||||
}
|
||||
if (nodeObjHasExcessParens && !IGNORE_NEW_IN_MEMBER_EXPR && node.object.type === "NewExpression" && isNewExpressionWithParens(node.object)) {
|
||||
report(node.object);
|
||||
}
|
||||
if (nodeObjHasExcessParens && node.optional && node.object.type === "ChainExpression") {
|
||||
report(node.object);
|
||||
}
|
||||
if (node.computed && hasExcessParens(node.property))
|
||||
report(node.property);
|
||||
},
|
||||
"MethodDefinition[computed=true]": function(node) {
|
||||
if (hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(node.key);
|
||||
},
|
||||
"NewExpression": checkCallNew,
|
||||
ObjectExpression(node) {
|
||||
node.properties.filter((property) => property.type === "Property" && property.value && hasExcessParensWithPrecedence(property.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach((property) => report(property.value));
|
||||
},
|
||||
ObjectPattern(node) {
|
||||
node.properties.filter((property) => {
|
||||
const value = property.value;
|
||||
return value && canBeAssignmentTarget(value) && hasExcessParens(value);
|
||||
}).forEach((property) => report(property.value));
|
||||
},
|
||||
Property(node) {
|
||||
if (node.computed) {
|
||||
const { key } = node;
|
||||
if (key && hasExcessParensWithPrecedence(key, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(key);
|
||||
}
|
||||
},
|
||||
PropertyDefinition(node) {
|
||||
if (node.computed && hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(node.key);
|
||||
if (node.value && hasExcessParensWithPrecedence(node.value, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(node.value);
|
||||
},
|
||||
RestElement(node) {
|
||||
const argument = node.argument;
|
||||
if (canBeAssignmentTarget(argument) && hasExcessParens(argument))
|
||||
report(argument);
|
||||
},
|
||||
ReturnStatement(node) {
|
||||
const returnToken = sourceCode.getFirstToken(node);
|
||||
if (isReturnAssignException(node))
|
||||
return;
|
||||
if (node.argument && returnToken && hasExcessParensNoLineTerminator(returnToken, node.argument) && !(node.argument.type === "Literal" && "regex" in node.argument && node.argument.regex)) {
|
||||
report(node.argument);
|
||||
}
|
||||
},
|
||||
SequenceExpression(node) {
|
||||
const precedenceOfNode = precedence(node);
|
||||
node.expressions.filter((e) => hasExcessParensWithPrecedence(e, precedenceOfNode)).forEach(report);
|
||||
},
|
||||
SwitchCase(node) {
|
||||
if (node.test && hasExcessParens(node.test))
|
||||
report(node.test);
|
||||
},
|
||||
SwitchStatement(node) {
|
||||
if (hasExcessParens(node.discriminant))
|
||||
report(node.discriminant);
|
||||
},
|
||||
ThrowStatement(node) {
|
||||
const throwToken = sourceCode.getFirstToken(node);
|
||||
if (throwToken && node.argument && hasExcessParensNoLineTerminator(throwToken, node.argument))
|
||||
report(node.argument);
|
||||
},
|
||||
"UnaryExpression": checkArgumentWithPrecedence,
|
||||
UpdateExpression(node) {
|
||||
if (node.prefix) {
|
||||
checkArgumentWithPrecedence(node);
|
||||
} else {
|
||||
const { argument } = node;
|
||||
const operatorToken = sourceCode.getLastToken(node);
|
||||
if (argument.loc.end.line === operatorToken.loc.start.line) {
|
||||
checkArgumentWithPrecedence(node);
|
||||
} else {
|
||||
if (hasDoubleExcessParens(argument))
|
||||
report(argument);
|
||||
}
|
||||
}
|
||||
},
|
||||
"AwaitExpression": checkArgumentWithPrecedence,
|
||||
VariableDeclarator(node) {
|
||||
if (node.init && hasExcessParensWithPrecedence(node.init, PRECEDENCE_OF_ASSIGNMENT_EXPR) && !(node.init.type === "Literal" && "regex" in node.init && node.init.regex)) {
|
||||
report(node.init);
|
||||
}
|
||||
},
|
||||
WhileStatement(node) {
|
||||
if (hasExcessParens(node.test) && !isCondAssignException(node))
|
||||
report(node.test);
|
||||
},
|
||||
WithStatement(node) {
|
||||
if (hasExcessParens(node.object))
|
||||
report(node.object);
|
||||
},
|
||||
YieldExpression(node) {
|
||||
if (node.argument) {
|
||||
const yieldToken = sourceCode.getFirstToken(node);
|
||||
if (precedence(node.argument) >= precedence(node) && yieldToken && hasExcessParensNoLineTerminator(yieldToken, node.argument) || hasDoubleExcessParens(node.argument)) {
|
||||
report(node.argument);
|
||||
}
|
||||
}
|
||||
},
|
||||
"ClassDeclaration": checkClass,
|
||||
"ClassExpression": checkClass,
|
||||
"SpreadElement": checkSpreadOperator,
|
||||
"SpreadProperty": checkSpreadOperator,
|
||||
TemplateLiteral(node) {
|
||||
node.expressions.filter((e) => e && hasExcessParens(e)).forEach(report);
|
||||
},
|
||||
AssignmentPattern(node) {
|
||||
const { left, right } = node;
|
||||
if (canBeAssignmentTarget(left) && hasExcessParens(left))
|
||||
report(left);
|
||||
if (right && hasExcessParensWithPrecedence(right, PRECEDENCE_OF_ASSIGNMENT_EXPR))
|
||||
report(right);
|
||||
},
|
||||
// This listener is exposed for TypeScript rule to consume
|
||||
TSStringKeyword(node) {
|
||||
if (hasExcessParens(node))
|
||||
report(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noExtraParens as default };
|
||||
79
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-extra-semi.js
generated
vendored
Normal file
79
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-extra-semi.js
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import { c as createRule, P as FixTracker, k as isClosingBraceToken, t as isSemicolonToken, O as isTopLevelExpressionStatement } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noExtraSemi = createRule({
|
||||
name: "no-extra-semi",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow unnecessary semicolons"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [],
|
||||
messages: {
|
||||
unexpected: "Unnecessary semicolon."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
function isFixable(nodeOrToken) {
|
||||
const nextToken = sourceCode.getTokenAfter(nodeOrToken);
|
||||
if (!nextToken || nextToken.type !== "String")
|
||||
return true;
|
||||
const stringNode = sourceCode.getNodeByRangeIndex(nextToken.range[0]);
|
||||
return !isTopLevelExpressionStatement(stringNode.parent);
|
||||
}
|
||||
function report(nodeOrToken) {
|
||||
context.report({
|
||||
node: nodeOrToken,
|
||||
messageId: "unexpected",
|
||||
fix: isFixable(nodeOrToken) ? (fixer) => new FixTracker(fixer, context.sourceCode).retainSurroundingTokens(nodeOrToken).remove(nodeOrToken) : null
|
||||
});
|
||||
}
|
||||
function checkForPartOfClassBody(firstToken) {
|
||||
for (let token = firstToken; token.type === "Punctuator" && !isClosingBraceToken(token); token = sourceCode.getTokenAfter(token)) {
|
||||
if (isSemicolonToken(token))
|
||||
report(token);
|
||||
}
|
||||
}
|
||||
return {
|
||||
/**
|
||||
* Reports this empty statement, except if the parent node is a loop.
|
||||
* @param node A EmptyStatement node to be reported.
|
||||
*/
|
||||
EmptyStatement(node) {
|
||||
const parent = node.parent;
|
||||
const allowedParentTypes = [
|
||||
"ForStatement",
|
||||
"ForInStatement",
|
||||
"ForOfStatement",
|
||||
"WhileStatement",
|
||||
"DoWhileStatement",
|
||||
"IfStatement",
|
||||
"LabeledStatement",
|
||||
"WithStatement"
|
||||
];
|
||||
if (!allowedParentTypes.includes(parent.type))
|
||||
report(node);
|
||||
},
|
||||
/**
|
||||
* Checks tokens from the head of this class body to the first MethodDefinition or the end of this class body.
|
||||
* @param node A ClassBody node to check.
|
||||
*/
|
||||
ClassBody(node) {
|
||||
checkForPartOfClassBody(sourceCode.getFirstToken(node, 1));
|
||||
},
|
||||
/**
|
||||
* Checks tokens from this MethodDefinition to the next MethodDefinition or the end of this class body.
|
||||
* @param node A MethodDefinition node of the start point.
|
||||
*/
|
||||
"MethodDefinition, PropertyDefinition, StaticBlock": function(node) {
|
||||
checkForPartOfClassBody(sourceCode.getTokenAfter(node));
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noExtraSemi as default };
|
||||
49
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-floating-decimal.js
generated
vendored
Normal file
49
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-floating-decimal.js
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { c as createRule, d as canTokensBeAdjacent } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noFloatingDecimal = createRule({
|
||||
name: "no-floating-decimal",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow leading or trailing decimal points in numeric literals"
|
||||
},
|
||||
schema: [],
|
||||
fixable: "code",
|
||||
messages: {
|
||||
leading: "A leading decimal point can be confused with a dot.",
|
||||
trailing: "A trailing decimal point can be confused with a dot."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
return {
|
||||
Literal(node) {
|
||||
if (typeof node.value === "number") {
|
||||
if (node.raw.startsWith(".")) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "leading",
|
||||
fix(fixer) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(node);
|
||||
const needsSpaceBefore = tokenBefore && tokenBefore.range[1] === node.range[0] && !canTokensBeAdjacent(tokenBefore, `0${node.raw}`);
|
||||
return fixer.insertTextBefore(node, needsSpaceBefore ? " 0" : "0");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (node.raw.indexOf(".") === node.raw.length - 1) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "trailing",
|
||||
fix: (fixer) => fixer.insertTextAfter(node, "0")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noFloatingDecimal as default };
|
||||
132
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-mixed-operators.js
generated
vendored
Normal file
132
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-mixed-operators.js
generated
vendored
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
import { c as createRule, I as getPrecedence, H as isParenthesised, o as isNotClosingParenToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const ARITHMETIC_OPERATORS = ["+", "-", "*", "/", "%", "**"];
|
||||
const BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"];
|
||||
const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="];
|
||||
const LOGICAL_OPERATORS = ["&&", "||"];
|
||||
const RELATIONAL_OPERATORS = ["in", "instanceof"];
|
||||
const TERNARY_OPERATOR = ["?:"];
|
||||
const COALESCE_OPERATOR = ["??"];
|
||||
const ALL_OPERATORS = [].concat(
|
||||
ARITHMETIC_OPERATORS,
|
||||
BITWISE_OPERATORS,
|
||||
COMPARISON_OPERATORS,
|
||||
LOGICAL_OPERATORS,
|
||||
RELATIONAL_OPERATORS,
|
||||
TERNARY_OPERATOR,
|
||||
COALESCE_OPERATOR
|
||||
);
|
||||
const DEFAULT_GROUPS = [
|
||||
ARITHMETIC_OPERATORS,
|
||||
BITWISE_OPERATORS,
|
||||
COMPARISON_OPERATORS,
|
||||
LOGICAL_OPERATORS,
|
||||
RELATIONAL_OPERATORS
|
||||
];
|
||||
const TARGET_NODE_TYPE = /^(?:Binary|Logical|Conditional)Expression$/u;
|
||||
function normalizeOptions(options = {}) {
|
||||
const hasGroups = options.groups && options.groups.length > 0;
|
||||
const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
|
||||
const allowSamePrecedence = options.allowSamePrecedence !== false;
|
||||
return {
|
||||
groups,
|
||||
allowSamePrecedence
|
||||
};
|
||||
}
|
||||
function includesBothInAGroup(groups, left, right) {
|
||||
return groups.some((group) => group.includes(left) && group.includes(right));
|
||||
}
|
||||
function getChildNode(node) {
|
||||
return node.type === "ConditionalExpression" ? node.test : node.left;
|
||||
}
|
||||
var noMixedOperators = createRule({
|
||||
name: "no-mixed-operators",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow mixed binary operators"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
groups: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
enum: ALL_OPERATORS
|
||||
},
|
||||
minItems: 2,
|
||||
uniqueItems: true
|
||||
},
|
||||
uniqueItems: true
|
||||
},
|
||||
allowSamePrecedence: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedMixedOperator: "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'. Use parentheses to clarify the intended order of operations."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const options = normalizeOptions(context.options[0]);
|
||||
function shouldIgnore(node) {
|
||||
const a = node;
|
||||
const b = node.parent;
|
||||
return !includesBothInAGroup(
|
||||
options.groups ?? [],
|
||||
a.operator,
|
||||
b.type === "ConditionalExpression" ? "?:" : b.operator
|
||||
) || options.allowSamePrecedence && getPrecedence(a) === getPrecedence(b);
|
||||
}
|
||||
function isMixedWithParent(node) {
|
||||
return node.operator !== node.parent.operator && !isParenthesised(sourceCode, node);
|
||||
}
|
||||
function getOperatorToken(node) {
|
||||
return sourceCode.getTokenAfter(getChildNode(node), isNotClosingParenToken);
|
||||
}
|
||||
function reportBothOperators(node) {
|
||||
const parent = node.parent;
|
||||
const left = getChildNode(parent) === node ? node : parent;
|
||||
const right = getChildNode(parent) !== node ? node : parent;
|
||||
const data = {
|
||||
leftOperator: left.operator || "?:",
|
||||
rightOperator: right.operator || "?:"
|
||||
};
|
||||
context.report({
|
||||
node: left,
|
||||
loc: getOperatorToken(left).loc,
|
||||
messageId: "unexpectedMixedOperator",
|
||||
data
|
||||
});
|
||||
context.report({
|
||||
node: right,
|
||||
loc: getOperatorToken(right).loc,
|
||||
messageId: "unexpectedMixedOperator",
|
||||
data
|
||||
});
|
||||
}
|
||||
function check(node) {
|
||||
if (TARGET_NODE_TYPE.test(node.parent.type) && isMixedWithParent(node) && !shouldIgnore(node)) {
|
||||
reportBothOperators(node);
|
||||
}
|
||||
}
|
||||
return {
|
||||
BinaryExpression: check,
|
||||
LogicalExpression: check
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noMixedOperators as default };
|
||||
86
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-mixed-spaces-and-tabs.js
generated
vendored
Normal file
86
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-mixed-spaces-and-tabs.js
generated
vendored
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noMixedSpacesAndTabs = createRule({
|
||||
name: "no-mixed-spaces-and-tabs",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow mixed spaces and tabs for indentation"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["smart-tabs"]
|
||||
},
|
||||
{
|
||||
type: "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
mixedSpacesAndTabs: "Mixed spaces and tabs."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
let smartTabs;
|
||||
switch (context.options[0]) {
|
||||
case true:
|
||||
// Support old syntax, maybe add deprecation warning here
|
||||
case "smart-tabs":
|
||||
smartTabs = true;
|
||||
break;
|
||||
default:
|
||||
smartTabs = false;
|
||||
}
|
||||
return {
|
||||
"Program:exit": function(node) {
|
||||
const lines = sourceCode.lines;
|
||||
const comments = sourceCode.getAllComments();
|
||||
const ignoredCommentLines = /* @__PURE__ */ new Set();
|
||||
comments.forEach((comment) => {
|
||||
for (let i = comment.loc.start.line + 1; i <= comment.loc.end.line; i++)
|
||||
ignoredCommentLines.add(i);
|
||||
});
|
||||
let regex = /^(?=( +|\t+))\1(?:\t| )/u;
|
||||
if (smartTabs) {
|
||||
regex = /^(?=(\t*))\1(?=( +))\2\t/u;
|
||||
}
|
||||
lines.forEach((line, i) => {
|
||||
const match = regex.exec(line);
|
||||
if (match) {
|
||||
const lineNumber = i + 1;
|
||||
const loc = {
|
||||
start: {
|
||||
line: lineNumber,
|
||||
column: match[0].length - 2
|
||||
},
|
||||
end: {
|
||||
line: lineNumber,
|
||||
column: match[0].length
|
||||
}
|
||||
};
|
||||
if (!ignoredCommentLines.has(lineNumber)) {
|
||||
const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start));
|
||||
if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: "mixedSpacesAndTabs"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noMixedSpacesAndTabs as default };
|
||||
93
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-multi-spaces.js
generated
vendored
Normal file
93
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-multi-spaces.js
generated
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import { c as createRule, a as isCommentToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noMultiSpaces = createRule({
|
||||
name: "no-multi-spaces",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow multiple spaces"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptions: {
|
||||
type: "object",
|
||||
patternProperties: {
|
||||
"^([A-Z][a-z]*)+$": {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
ignoreEOLComments: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
includeTabs: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
multipleSpaces: "Multiple spaces found before '{{displayValue}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const options = context.options[0] || {};
|
||||
const ignoreEOLComments = options.ignoreEOLComments;
|
||||
const exceptions = Object.assign({ Property: true, ImportAttribute: true }, options.exceptions);
|
||||
const hasExceptions = Object.keys(exceptions).some((key) => exceptions[key]);
|
||||
const spacesRe = options.includeTabs === false ? / {2}/ : /[ \t]{2}/;
|
||||
function formatReportedCommentValue(token) {
|
||||
const valueLines = token.value.split("\n");
|
||||
const value = valueLines[0];
|
||||
const formattedValue = `${value.slice(0, 12)}...`;
|
||||
return valueLines.length === 1 && value.length <= 12 ? value : formattedValue;
|
||||
}
|
||||
return {
|
||||
Program() {
|
||||
sourceCode.tokensAndComments.forEach((leftToken, leftIndex, tokensAndComments) => {
|
||||
if (leftIndex === tokensAndComments.length - 1)
|
||||
return;
|
||||
const rightToken = tokensAndComments[leftIndex + 1];
|
||||
if (!spacesRe.test(sourceCode.text.slice(leftToken.range[1], rightToken.range[0])) || leftToken.loc.end.line < rightToken.loc.start.line) {
|
||||
return;
|
||||
}
|
||||
if (ignoreEOLComments && isCommentToken(rightToken) && (leftIndex === tokensAndComments.length - 2 || rightToken.loc.end.line < tokensAndComments[leftIndex + 2].loc.start.line)) {
|
||||
return;
|
||||
}
|
||||
if (hasExceptions) {
|
||||
const parentNode = sourceCode.getNodeByRangeIndex(rightToken.range[0] - 1);
|
||||
if (parentNode && exceptions[parentNode.type])
|
||||
return;
|
||||
}
|
||||
let displayValue;
|
||||
if (rightToken.type === "Block")
|
||||
displayValue = `/*${formatReportedCommentValue(rightToken)}*/`;
|
||||
else if (rightToken.type === "Line")
|
||||
displayValue = `//${formatReportedCommentValue(rightToken)}`;
|
||||
else
|
||||
displayValue = rightToken.value;
|
||||
context.report({
|
||||
node: rightToken,
|
||||
loc: { start: leftToken.loc.end, end: rightToken.loc.start },
|
||||
messageId: "multipleSpaces",
|
||||
data: { displayValue },
|
||||
fix: (fixer) => fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ")
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noMultiSpaces as default };
|
||||
104
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-multiple-empty-lines.js
generated
vendored
Normal file
104
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-multiple-empty-lines.js
generated
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noMultipleEmptyLines = createRule({
|
||||
name: "no-multiple-empty-lines",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow multiple empty lines"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
max: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
maxEOF: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
maxBOF: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
}
|
||||
},
|
||||
required: ["max"],
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
blankBeginningOfFile: "Too many blank lines at the beginning of file. Max of {{max}} allowed.",
|
||||
blankEndOfFile: "Too many blank lines at the end of file. Max of {{max}} allowed.",
|
||||
consecutiveBlank: "More than {{max}} blank {{pluralizedLines}} not allowed."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
let max = 2;
|
||||
let maxEOF = max;
|
||||
let maxBOF = max;
|
||||
if (context.options.length && context.options[0]) {
|
||||
max = context.options[0].max;
|
||||
maxEOF = typeof context.options[0].maxEOF !== "undefined" ? context.options[0].maxEOF : max;
|
||||
maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max;
|
||||
}
|
||||
const sourceCode = context.sourceCode;
|
||||
const allLines = sourceCode.lines[sourceCode.lines.length - 1] === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines;
|
||||
const templateLiteralLines = /* @__PURE__ */ new Set();
|
||||
return {
|
||||
TemplateLiteral(node) {
|
||||
node.quasis.forEach((literalPart) => {
|
||||
for (let ignoredLine = literalPart.loc.start.line; ignoredLine < literalPart.loc.end.line; ignoredLine++)
|
||||
templateLiteralLines.add(ignoredLine);
|
||||
});
|
||||
},
|
||||
"Program:exit": function(node) {
|
||||
return allLines.reduce((nonEmptyLineNumbers, line, index) => {
|
||||
if (line.trim() || templateLiteralLines.has(index + 1))
|
||||
nonEmptyLineNumbers.push(index + 1);
|
||||
return nonEmptyLineNumbers;
|
||||
}, []).concat(allLines.length + 1).reduce((lastLineNumber, lineNumber) => {
|
||||
let messageId, maxAllowed;
|
||||
if (lastLineNumber === 0) {
|
||||
messageId = "blankBeginningOfFile";
|
||||
maxAllowed = maxBOF;
|
||||
} else if (lineNumber === allLines.length + 1) {
|
||||
messageId = "blankEndOfFile";
|
||||
maxAllowed = maxEOF;
|
||||
} else {
|
||||
messageId = "consecutiveBlank";
|
||||
maxAllowed = max;
|
||||
}
|
||||
if (lineNumber - lastLineNumber - 1 > maxAllowed) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: { line: lastLineNumber + maxAllowed + 1, column: 0 },
|
||||
end: { line: lineNumber, column: 0 }
|
||||
},
|
||||
messageId,
|
||||
data: {
|
||||
max: maxAllowed,
|
||||
pluralizedLines: maxAllowed === 1 ? "line" : "lines"
|
||||
},
|
||||
fix(fixer) {
|
||||
const rangeStart = sourceCode.getIndexFromLoc({ line: lastLineNumber + 1, column: 0 });
|
||||
const lineNumberAfterRemovedLines = lineNumber - maxAllowed;
|
||||
const rangeEnd = lineNumberAfterRemovedLines <= allLines.length ? sourceCode.getIndexFromLoc({ line: lineNumberAfterRemovedLines, column: 0 }) : sourceCode.text.length;
|
||||
return fixer.removeRange([rangeStart, rangeEnd]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return lineNumber;
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noMultipleEmptyLines as default };
|
||||
60
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-tabs.js
generated
vendored
Normal file
60
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-tabs.js
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const tabRegex = /\t+/gu;
|
||||
const anyNonWhitespaceRegex = /\S/u;
|
||||
var noTabs = createRule({
|
||||
name: "no-tabs",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow all tabs"
|
||||
},
|
||||
schema: [{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowIndentationTabs: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}],
|
||||
messages: {
|
||||
unexpectedTab: "Unexpected tab character."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs;
|
||||
return {
|
||||
Program(node) {
|
||||
sourceCode.getLines().forEach((line, index) => {
|
||||
let match;
|
||||
while ((match = tabRegex.exec(line)) !== null) {
|
||||
if (allowIndentationTabs && !anyNonWhitespaceRegex.test(line.slice(0, match.index)))
|
||||
continue;
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: {
|
||||
line: index + 1,
|
||||
column: match.index
|
||||
},
|
||||
end: {
|
||||
line: index + 1,
|
||||
column: match.index + match[0].length
|
||||
}
|
||||
},
|
||||
messageId: "unexpectedTab"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noTabs as default };
|
||||
108
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-trailing-spaces.js
generated
vendored
Normal file
108
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-trailing-spaces.js
generated
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import { c as createRule, z as createGlobalLinebreakMatcher } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noTrailingSpaces = createRule({
|
||||
name: "no-trailing-spaces",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow trailing whitespace at the end of lines"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
skipBlankLines: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
ignoreComments: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
trailingSpace: "Trailing spaces not allowed."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const BLANK_CLASS = "[ \xA0\u2000-\u200B\u3000]";
|
||||
const SKIP_BLANK = `^${BLANK_CLASS}*$`;
|
||||
const NONBLANK = `${BLANK_CLASS}+$`;
|
||||
const options = context.options[0] || {};
|
||||
const skipBlankLines = options.skipBlankLines || false;
|
||||
const ignoreComments = options.ignoreComments || false;
|
||||
function report(node, location, fixRange) {
|
||||
context.report({
|
||||
node,
|
||||
loc: location,
|
||||
messageId: "trailingSpace",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange(fixRange);
|
||||
}
|
||||
});
|
||||
}
|
||||
function getCommentLineNumbers(comments) {
|
||||
const lines = /* @__PURE__ */ new Set();
|
||||
comments.forEach((comment) => {
|
||||
const endLine = comment.type === "Block" ? comment.loc.end.line - 1 : comment.loc.end.line;
|
||||
for (let i = comment.loc.start.line; i <= endLine; i++)
|
||||
lines.add(i);
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
return {
|
||||
Program: function checkTrailingSpaces(node) {
|
||||
const re = new RegExp(NONBLANK, "u");
|
||||
const skipMatch = new RegExp(SKIP_BLANK, "u");
|
||||
const lines = sourceCode.lines;
|
||||
const linebreaks = sourceCode.getText().match(createGlobalLinebreakMatcher());
|
||||
const comments = sourceCode.getAllComments();
|
||||
const commentLineNumbers = getCommentLineNumbers(comments);
|
||||
let totalLength = 0;
|
||||
for (let i = 0, ii = lines.length; i < ii; i++) {
|
||||
const lineNumber = i + 1;
|
||||
const linebreakLength = linebreaks && linebreaks[i] ? linebreaks[i].length : 1;
|
||||
const lineLength = lines[i].length + linebreakLength;
|
||||
const matches = re.exec(lines[i]);
|
||||
if (matches) {
|
||||
const location = {
|
||||
start: {
|
||||
line: lineNumber,
|
||||
column: matches.index
|
||||
},
|
||||
end: {
|
||||
line: lineNumber,
|
||||
column: lineLength - linebreakLength
|
||||
}
|
||||
};
|
||||
const rangeStart = totalLength + location.start.column;
|
||||
const rangeEnd = totalLength + location.end.column;
|
||||
const containingNode = sourceCode.getNodeByRangeIndex(rangeStart);
|
||||
if (containingNode && containingNode.type === "TemplateElement" && rangeStart > containingNode.parent.range[0] && rangeEnd < containingNode.parent.range[1]) {
|
||||
totalLength += lineLength;
|
||||
continue;
|
||||
}
|
||||
if (skipBlankLines && skipMatch.test(lines[i])) {
|
||||
totalLength += lineLength;
|
||||
continue;
|
||||
}
|
||||
const fixRange = [rangeStart, rangeEnd];
|
||||
if (!ignoreComments || !commentLineNumbers.has(lineNumber))
|
||||
report(node, location, fixRange);
|
||||
}
|
||||
totalLength += lineLength;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noTrailingSpaces as default };
|
||||
63
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-whitespace-before-property.js
generated
vendored
Normal file
63
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/no-whitespace-before-property.js
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import { c as createRule, i as isTokenOnSameLine, l as isOpeningBracketToken, J as isDecimalInteger } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var noWhitespaceBeforeProperty = createRule({
|
||||
name: "no-whitespace-before-property",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Disallow whitespace before properties"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [],
|
||||
messages: {
|
||||
unexpectedWhitespace: "Unexpected whitespace before property {{propName}}."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
function reportError(node, leftToken, rightToken) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedWhitespace",
|
||||
data: {
|
||||
propName: sourceCode.getText(node.property)
|
||||
},
|
||||
fix(fixer) {
|
||||
let replacementText = "";
|
||||
if (!node.computed && !node.optional && isDecimalInteger(node.object)) {
|
||||
return null;
|
||||
}
|
||||
if (sourceCode.commentsExistBetween(leftToken, rightToken))
|
||||
return null;
|
||||
if (node.optional)
|
||||
replacementText = "?.";
|
||||
else if (!node.computed)
|
||||
replacementText = ".";
|
||||
return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], replacementText);
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
MemberExpression(node) {
|
||||
let rightToken;
|
||||
let leftToken;
|
||||
if (!isTokenOnSameLine(node.object, node.property))
|
||||
return;
|
||||
if (node.computed) {
|
||||
rightToken = sourceCode.getTokenBefore(node.property, isOpeningBracketToken);
|
||||
leftToken = sourceCode.getTokenBefore(rightToken, node.optional ? 1 : 0);
|
||||
} else {
|
||||
rightToken = sourceCode.getFirstToken(node.property);
|
||||
leftToken = sourceCode.getTokenBefore(rightToken, 1);
|
||||
}
|
||||
if (sourceCode.isSpaceBetween(leftToken, rightToken))
|
||||
reportError(node, leftToken, rightToken);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { noWhitespaceBeforeProperty as default };
|
||||
86
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/nonblock-statement-body-position.js
generated
vendored
Normal file
86
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/nonblock-statement-body-position.js
generated
vendored
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const POSITION_SCHEMA = {
|
||||
type: "string",
|
||||
enum: ["beside", "below", "any"]
|
||||
};
|
||||
var nonblockStatementBodyPosition = createRule({
|
||||
name: "nonblock-statement-body-position",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce the location of single-line statements"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
POSITION_SCHEMA,
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
overrides: {
|
||||
type: "object",
|
||||
properties: {
|
||||
if: POSITION_SCHEMA,
|
||||
else: POSITION_SCHEMA,
|
||||
while: POSITION_SCHEMA,
|
||||
do: POSITION_SCHEMA,
|
||||
for: POSITION_SCHEMA
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expectNoLinebreak: "Expected no linebreak before this statement.",
|
||||
expectLinebreak: "Expected a linebreak before this statement."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
function getOption(keywordName) {
|
||||
return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] || context.options[0] || "beside";
|
||||
}
|
||||
function validateStatement(node, keywordName) {
|
||||
const option = getOption(keywordName);
|
||||
if (node.type === "BlockStatement" || option === "any")
|
||||
return;
|
||||
const tokenBefore = sourceCode.getTokenBefore(node);
|
||||
if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "expectLinebreak",
|
||||
fix: (fixer) => fixer.insertTextBefore(node, "\n")
|
||||
});
|
||||
} else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "expectNoLinebreak",
|
||||
fix(fixer) {
|
||||
if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim())
|
||||
return null;
|
||||
return fixer.replaceTextRange([tokenBefore.range[1], node.range[0]], " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
IfStatement(node) {
|
||||
validateStatement(node.consequent, "if");
|
||||
if (node.alternate && node.alternate.type !== "IfStatement")
|
||||
validateStatement(node.alternate, "else");
|
||||
},
|
||||
WhileStatement: (node) => validateStatement(node.body, "while"),
|
||||
DoWhileStatement: (node) => validateStatement(node.body, "do"),
|
||||
ForStatement: (node) => validateStatement(node.body, "for"),
|
||||
ForInStatement: (node) => validateStatement(node.body, "for"),
|
||||
ForOfStatement: (node) => validateStatement(node.body, "for")
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { nonblockStatementBodyPosition as default };
|
||||
211
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/object-curly-newline.js
generated
vendored
Normal file
211
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/object-curly-newline.js
generated
vendored
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
import { c as createRule, a as isCommentToken, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const OPTION_VALUE = {
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
multiline: {
|
||||
type: "boolean"
|
||||
},
|
||||
minProperties: {
|
||||
type: "integer",
|
||||
minimum: 0
|
||||
},
|
||||
consistent: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
minProperties: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
function normalizeOptionValue(value) {
|
||||
let multiline = false;
|
||||
let minProperties = Number.POSITIVE_INFINITY;
|
||||
let consistent = false;
|
||||
if (value) {
|
||||
if (value === "always") {
|
||||
minProperties = 0;
|
||||
} else if (value === "never") {
|
||||
minProperties = Number.POSITIVE_INFINITY;
|
||||
} else {
|
||||
multiline = Boolean(value.multiline);
|
||||
minProperties = value.minProperties || Number.POSITIVE_INFINITY;
|
||||
consistent = Boolean(value.consistent);
|
||||
}
|
||||
} else {
|
||||
consistent = true;
|
||||
}
|
||||
return { multiline, minProperties, consistent };
|
||||
}
|
||||
function isObject(value) {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
function isNodeSpecificOption(option) {
|
||||
return isObject(option) || typeof option === "string";
|
||||
}
|
||||
function normalizeOptions(options) {
|
||||
if (isObject(options) && Object.values(options).some(isNodeSpecificOption)) {
|
||||
return {
|
||||
ObjectExpression: normalizeOptionValue(options.ObjectExpression),
|
||||
ObjectPattern: normalizeOptionValue(options.ObjectPattern),
|
||||
ImportDeclaration: normalizeOptionValue(options.ImportDeclaration),
|
||||
ExportNamedDeclaration: normalizeOptionValue(options.ExportDeclaration),
|
||||
TSTypeLiteral: normalizeOptionValue(options.TSTypeLiteral),
|
||||
TSInterfaceBody: normalizeOptionValue(options.TSInterfaceBody)
|
||||
};
|
||||
}
|
||||
const value = normalizeOptionValue(options);
|
||||
return { ObjectExpression: value, ObjectPattern: value, ImportDeclaration: value, ExportNamedDeclaration: value, TSTypeLiteral: value, TSInterfaceBody: value };
|
||||
}
|
||||
function areLineBreaksRequired(node, options, first, last) {
|
||||
let objectProperties;
|
||||
if (node.type === "ObjectExpression" || node.type === "ObjectPattern") {
|
||||
objectProperties = node.properties;
|
||||
} else if (node.type === "TSTypeLiteral") {
|
||||
objectProperties = node.members;
|
||||
} else if (node.type === "TSInterfaceBody") {
|
||||
objectProperties = node.body;
|
||||
} else {
|
||||
objectProperties = node.specifiers.filter((s) => s.type === "ImportSpecifier" || s.type === "ExportSpecifier");
|
||||
}
|
||||
return objectProperties.length >= options.minProperties || options.multiline && objectProperties.length > 0 && first.loc.start.line !== last.loc.end.line;
|
||||
}
|
||||
var objectCurlyNewline = createRule({
|
||||
name: "object-curly-newline",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent line breaks after opening and before closing braces"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
OPTION_VALUE,
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
ObjectExpression: OPTION_VALUE,
|
||||
ObjectPattern: OPTION_VALUE,
|
||||
ImportDeclaration: OPTION_VALUE,
|
||||
ExportDeclaration: OPTION_VALUE,
|
||||
TSTypeLiteral: OPTION_VALUE,
|
||||
TSInterfaceBody: OPTION_VALUE
|
||||
},
|
||||
additionalProperties: false,
|
||||
minProperties: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.",
|
||||
unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.",
|
||||
expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.",
|
||||
expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const normalizedOptions = normalizeOptions(context.options[0]);
|
||||
function check(node) {
|
||||
const options = normalizedOptions[node.type];
|
||||
if (node.type === "ImportDeclaration" && !node.specifiers.some((specifier) => specifier.type === "ImportSpecifier") || node.type === "ExportNamedDeclaration" && !node.specifiers.some((specifier) => specifier.type === "ExportSpecifier")) {
|
||||
return;
|
||||
}
|
||||
const openBrace = sourceCode.getFirstToken(node, (token) => token.value === "{");
|
||||
let closeBrace;
|
||||
if (node.type === "ObjectPattern" && node.typeAnnotation)
|
||||
closeBrace = sourceCode.getTokenBefore(node.typeAnnotation);
|
||||
else
|
||||
closeBrace = sourceCode.getLastToken(node, (token) => token.value === "}");
|
||||
let first = sourceCode.getTokenAfter(openBrace, { includeComments: true });
|
||||
let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
|
||||
const needsLineBreaks = areLineBreaksRequired(node, options, first, last);
|
||||
const hasCommentsFirstToken = isCommentToken(first);
|
||||
const hasCommentsLastToken = isCommentToken(last);
|
||||
first = sourceCode.getTokenAfter(openBrace);
|
||||
last = sourceCode.getTokenBefore(closeBrace);
|
||||
if (needsLineBreaks) {
|
||||
if (isTokenOnSameLine(openBrace, first)) {
|
||||
context.report({
|
||||
messageId: "expectedLinebreakAfterOpeningBrace",
|
||||
node,
|
||||
loc: openBrace.loc,
|
||||
fix(fixer) {
|
||||
if (hasCommentsFirstToken)
|
||||
return null;
|
||||
return fixer.insertTextAfter(openBrace, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isTokenOnSameLine(last, closeBrace)) {
|
||||
context.report({
|
||||
messageId: "expectedLinebreakBeforeClosingBrace",
|
||||
node,
|
||||
loc: closeBrace.loc,
|
||||
fix(fixer) {
|
||||
if (hasCommentsLastToken)
|
||||
return null;
|
||||
return fixer.insertTextBefore(closeBrace, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const consistent = options.consistent;
|
||||
const hasLineBreakBetweenOpenBraceAndFirst = !isTokenOnSameLine(openBrace, first);
|
||||
const hasLineBreakBetweenCloseBraceAndLast = !isTokenOnSameLine(last, closeBrace);
|
||||
if (!consistent && hasLineBreakBetweenOpenBraceAndFirst || consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) {
|
||||
context.report({
|
||||
messageId: "unexpectedLinebreakAfterOpeningBrace",
|
||||
node,
|
||||
loc: openBrace.loc,
|
||||
fix(fixer) {
|
||||
if (hasCommentsFirstToken)
|
||||
return null;
|
||||
return fixer.removeRange([
|
||||
openBrace.range[1],
|
||||
first.range[0]
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!consistent && hasLineBreakBetweenCloseBraceAndLast || consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) {
|
||||
context.report({
|
||||
messageId: "unexpectedLinebreakBeforeClosingBrace",
|
||||
node,
|
||||
loc: closeBrace.loc,
|
||||
fix(fixer) {
|
||||
if (hasCommentsLastToken)
|
||||
return null;
|
||||
return fixer.removeRange([
|
||||
last.range[1],
|
||||
closeBrace.range[0]
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
ObjectExpression: check,
|
||||
ObjectPattern: check,
|
||||
ImportDeclaration: check,
|
||||
ExportNamedDeclaration: check,
|
||||
TSTypeLiteral: check,
|
||||
TSInterfaceBody: check
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { objectCurlyNewline as default };
|
||||
177
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/object-curly-spacing.js
generated
vendored
Normal file
177
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/object-curly-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
import { c as createRule, m as isNotCommaToken, i as isTokenOnSameLine, j as isClosingBracketToken, k as isClosingBraceToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var objectCurlySpacing = createRule(
|
||||
{
|
||||
name: "object-curly-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing inside braces"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
arraysInObjects: {
|
||||
type: "boolean"
|
||||
},
|
||||
objectsInObjects: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
requireSpaceBefore: "A space is required before '{{token}}'.",
|
||||
requireSpaceAfter: "A space is required after '{{token}}'.",
|
||||
unexpectedSpaceBefore: "There should be no space before '{{token}}'.",
|
||||
unexpectedSpaceAfter: "There should be no space after '{{token}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const spaced = context.options[0] === "always";
|
||||
const sourceCode = context.sourceCode;
|
||||
function isOptionSet(option) {
|
||||
return context.options[1] ? context.options[1][option] === !spaced : false;
|
||||
}
|
||||
const options = {
|
||||
spaced,
|
||||
arraysInObjectsException: isOptionSet("arraysInObjects"),
|
||||
objectsInObjectsException: isOptionSet("objectsInObjects")
|
||||
};
|
||||
function reportNoBeginningSpace(node, token) {
|
||||
const nextToken = context.sourceCode.getTokenAfter(token, { includeComments: true });
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: token.loc.end, end: nextToken.loc.start },
|
||||
messageId: "unexpectedSpaceAfter",
|
||||
data: {
|
||||
token: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([token.range[1], nextToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportNoEndingSpace(node, token) {
|
||||
const previousToken = context.sourceCode.getTokenBefore(token, { includeComments: true });
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: previousToken.loc.end, end: token.loc.start },
|
||||
messageId: "unexpectedSpaceBefore",
|
||||
data: {
|
||||
token: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([previousToken.range[1], token.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredBeginningSpace(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "requireSpaceAfter",
|
||||
data: {
|
||||
token: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportRequiredEndingSpace(node, token) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "requireSpaceBefore",
|
||||
data: {
|
||||
token: token.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
function validateBraceSpacing(node, first, second, penultimate, last) {
|
||||
if (isTokenOnSameLine(first, second)) {
|
||||
const firstSpaced = sourceCode.isSpaceBetween(first, second);
|
||||
if (options.spaced && !firstSpaced)
|
||||
reportRequiredBeginningSpace(node, first);
|
||||
if (!options.spaced && firstSpaced && second.type !== "Line")
|
||||
reportNoBeginningSpace(node, first);
|
||||
}
|
||||
if (isTokenOnSameLine(penultimate, last)) {
|
||||
const shouldCheckPenultimate = options.arraysInObjectsException && isClosingBracketToken(penultimate) || options.objectsInObjectsException && isClosingBraceToken(penultimate);
|
||||
const penultimateType = shouldCheckPenultimate && sourceCode.getNodeByRangeIndex(penultimate.range[0]).type;
|
||||
const closingCurlyBraceMustBeSpaced = options.arraysInObjectsException && penultimateType === "ArrayExpression" || options.objectsInObjectsException && (penultimateType === "ObjectExpression" || penultimateType === "ObjectPattern") ? !options.spaced : options.spaced;
|
||||
const lastSpaced = sourceCode.isSpaceBetween(penultimate, last);
|
||||
if (closingCurlyBraceMustBeSpaced && !lastSpaced)
|
||||
reportRequiredEndingSpace(node, last);
|
||||
if (!closingCurlyBraceMustBeSpaced && lastSpaced)
|
||||
reportNoEndingSpace(node, last);
|
||||
}
|
||||
}
|
||||
function getClosingBraceOfObject(node) {
|
||||
const lastProperty = node.properties[node.properties.length - 1];
|
||||
return sourceCode.getTokenAfter(lastProperty, isClosingBraceToken);
|
||||
}
|
||||
function checkForObject(node) {
|
||||
if (node.properties.length === 0)
|
||||
return;
|
||||
const first = sourceCode.getFirstToken(node);
|
||||
const last = getClosingBraceOfObject(node);
|
||||
const second = sourceCode.getTokenAfter(first, { includeComments: true });
|
||||
const penultimate = sourceCode.getTokenBefore(last, { includeComments: true });
|
||||
validateBraceSpacing(node, first, second, penultimate, last);
|
||||
}
|
||||
function checkForImport(node) {
|
||||
if (node.specifiers.length === 0)
|
||||
return;
|
||||
let firstSpecifier = node.specifiers[0];
|
||||
const lastSpecifier = node.specifiers[node.specifiers.length - 1];
|
||||
if (lastSpecifier.type !== "ImportSpecifier")
|
||||
return;
|
||||
if (firstSpecifier.type !== "ImportSpecifier")
|
||||
firstSpecifier = node.specifiers[1];
|
||||
const first = sourceCode.getTokenBefore(firstSpecifier);
|
||||
const last = sourceCode.getTokenAfter(lastSpecifier, isNotCommaToken);
|
||||
const second = sourceCode.getTokenAfter(first, { includeComments: true });
|
||||
const penultimate = sourceCode.getTokenBefore(last, { includeComments: true });
|
||||
validateBraceSpacing(node, first, second, penultimate, last);
|
||||
}
|
||||
function checkForExport(node) {
|
||||
if (node.specifiers.length === 0)
|
||||
return;
|
||||
const firstSpecifier = node.specifiers[0];
|
||||
const lastSpecifier = node.specifiers[node.specifiers.length - 1];
|
||||
const first = sourceCode.getTokenBefore(firstSpecifier);
|
||||
const last = sourceCode.getTokenAfter(lastSpecifier, isNotCommaToken);
|
||||
const second = sourceCode.getTokenAfter(first, { includeComments: true });
|
||||
const penultimate = sourceCode.getTokenBefore(last, { includeComments: true });
|
||||
validateBraceSpacing(node, first, second, penultimate, last);
|
||||
}
|
||||
return {
|
||||
// var {x} = y;
|
||||
ObjectPattern: checkForObject,
|
||||
// var y = {x: 'y'}
|
||||
ObjectExpression: checkForObject,
|
||||
// import {y} from 'x';
|
||||
ImportDeclaration: checkForImport,
|
||||
// export {name} from 'yo';
|
||||
ExportNamedDeclaration: checkForExport
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export { objectCurlySpacing as default };
|
||||
74
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/object-property-newline.js
generated
vendored
Normal file
74
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/object-property-newline.js
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var objectPropertyNewline = createRule({
|
||||
name: "object-property-newline",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce placing object properties on separate lines"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowAllPropertiesOnSameLine: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
allowMultiplePropertiesPerLine: {
|
||||
// Deprecated
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
fixable: "whitespace",
|
||||
messages: {
|
||||
propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.",
|
||||
propertiesOnNewline: "Object properties must go on a new line."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const allowSameLine = context.options[0] && (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine);
|
||||
const messageId = allowSameLine ? "propertiesOnNewlineAll" : "propertiesOnNewline";
|
||||
const sourceCode = context.sourceCode;
|
||||
return {
|
||||
ObjectExpression(node) {
|
||||
if (allowSameLine) {
|
||||
if (node.properties.length > 1) {
|
||||
const firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]);
|
||||
const lastTokenOfLastProperty = sourceCode.getLastToken(node.properties[node.properties.length - 1]);
|
||||
if (firstTokenOfFirstProperty.loc.end.line === lastTokenOfLastProperty.loc.start.line) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 1; i < node.properties.length; i++) {
|
||||
const lastTokenOfPreviousProperty = sourceCode.getLastToken(node.properties[i - 1]);
|
||||
const firstTokenOfCurrentProperty = sourceCode.getFirstToken(node.properties[i]);
|
||||
if (lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line) {
|
||||
context.report({
|
||||
node,
|
||||
loc: firstTokenOfCurrentProperty.loc,
|
||||
messageId,
|
||||
fix(fixer) {
|
||||
const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty);
|
||||
const rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]];
|
||||
if (sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim())
|
||||
return null;
|
||||
return fixer.replaceTextRange(rangeAfterComma, "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { objectPropertyNewline as default };
|
||||
54
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/one-var-declaration-per-line.js
generated
vendored
Normal file
54
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/one-var-declaration-per-line.js
generated
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var oneVarDeclarationPerLine = createRule({
|
||||
name: "one-var-declaration-per-line",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow newlines around variable declarations"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "initializations"]
|
||||
}
|
||||
],
|
||||
fixable: "whitespace",
|
||||
messages: {
|
||||
expectVarOnNewline: "Expected variable declaration to be on a new line."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const always = context.options[0] === "always";
|
||||
function isForTypeSpecifier(keyword) {
|
||||
return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
|
||||
}
|
||||
function checkForNewLine(node) {
|
||||
if (isForTypeSpecifier(node.parent.type))
|
||||
return;
|
||||
const declarations = node.declarations;
|
||||
let prev;
|
||||
declarations.forEach((current) => {
|
||||
if (prev && prev.loc.end.line === current.loc.start.line) {
|
||||
if (always || prev.init || current.init) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "expectVarOnNewline",
|
||||
loc: current.loc,
|
||||
fix: (fixer) => fixer.insertTextBefore(current, "\n")
|
||||
});
|
||||
}
|
||||
}
|
||||
prev = current;
|
||||
});
|
||||
}
|
||||
return {
|
||||
VariableDeclaration: checkForNewLine
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { oneVarDeclarationPerLine as default };
|
||||
157
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/operator-linebreak.js
generated
vendored
Normal file
157
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/operator-linebreak.js
generated
vendored
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
import { c as createRule, i as isTokenOnSameLine, z as createGlobalLinebreakMatcher } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var operatorLinebreak = createRule({
|
||||
name: "operator-linebreak",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent linebreak style for operators"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["after", "before", "none"]
|
||||
},
|
||||
{
|
||||
type: "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
overrides: {
|
||||
type: "object",
|
||||
additionalProperties: {
|
||||
type: "string",
|
||||
enum: ["after", "before", "none", "ignore"]
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
fixable: "code",
|
||||
messages: {
|
||||
operatorAtBeginning: "'{{operator}}' should be placed at the beginning of the line.",
|
||||
operatorAtEnd: "'{{operator}}' should be placed at the end of the line.",
|
||||
badLinebreak: "Bad line breaking before and after '{{operator}}'.",
|
||||
noLinebreak: "There should be no line break before or after '{{operator}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const usedDefaultGlobal = !context.options[0];
|
||||
const globalStyle = context.options[0] || "after";
|
||||
const options = context.options[1] || {};
|
||||
const styleOverrides = options.overrides ? Object.assign({}, options.overrides) : {};
|
||||
if (usedDefaultGlobal && !styleOverrides["?"])
|
||||
styleOverrides["?"] = "before";
|
||||
if (usedDefaultGlobal && !styleOverrides[":"])
|
||||
styleOverrides[":"] = "before";
|
||||
const sourceCode = context.sourceCode;
|
||||
function getFixer(operatorToken, desiredStyle) {
|
||||
return (fixer) => {
|
||||
const tokenBefore = sourceCode.getTokenBefore(operatorToken);
|
||||
const tokenAfter = sourceCode.getTokenAfter(operatorToken);
|
||||
const textBefore = sourceCode.text.slice(tokenBefore.range[1], operatorToken.range[0]);
|
||||
const textAfter = sourceCode.text.slice(operatorToken.range[1], tokenAfter.range[0]);
|
||||
const hasLinebreakBefore = !isTokenOnSameLine(tokenBefore, operatorToken);
|
||||
const hasLinebreakAfter = !isTokenOnSameLine(operatorToken, tokenAfter);
|
||||
let newTextBefore, newTextAfter;
|
||||
if (hasLinebreakBefore !== hasLinebreakAfter && desiredStyle !== "none") {
|
||||
if (sourceCode.getTokenBefore(operatorToken, { includeComments: true }) !== tokenBefore && sourceCode.getTokenAfter(operatorToken, { includeComments: true }) !== tokenAfter) {
|
||||
return null;
|
||||
}
|
||||
newTextBefore = textAfter;
|
||||
newTextAfter = textBefore;
|
||||
} else {
|
||||
const LINEBREAK_REGEX = createGlobalLinebreakMatcher();
|
||||
newTextBefore = desiredStyle === "before" || textBefore.trim() ? textBefore : textBefore.replace(LINEBREAK_REGEX, "");
|
||||
newTextAfter = desiredStyle === "after" || textAfter.trim() ? textAfter : textAfter.replace(LINEBREAK_REGEX, "");
|
||||
if (newTextBefore === textBefore && newTextAfter === textAfter)
|
||||
return null;
|
||||
}
|
||||
if (newTextAfter === "" && tokenAfter.type === "Punctuator" && "+-".includes(operatorToken.value) && tokenAfter.value === operatorToken.value) {
|
||||
newTextAfter += " ";
|
||||
}
|
||||
return fixer.replaceTextRange([tokenBefore.range[1], tokenAfter.range[0]], newTextBefore + operatorToken.value + newTextAfter);
|
||||
};
|
||||
}
|
||||
function validateNode(node, rightSide, operator) {
|
||||
const operatorToken = sourceCode.getTokenBefore(rightSide, (token) => token.value === operator);
|
||||
const leftToken = sourceCode.getTokenBefore(operatorToken);
|
||||
const rightToken = sourceCode.getTokenAfter(operatorToken);
|
||||
const operatorStyleOverride = styleOverrides[operator];
|
||||
const style = operatorStyleOverride || globalStyle;
|
||||
const fix = getFixer(operatorToken, style);
|
||||
if (isTokenOnSameLine(leftToken, operatorToken) && isTokenOnSameLine(operatorToken, rightToken)) ; else if (operatorStyleOverride !== "ignore" && !isTokenOnSameLine(leftToken, operatorToken) && !isTokenOnSameLine(operatorToken, rightToken)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: operatorToken.loc,
|
||||
messageId: "badLinebreak",
|
||||
data: {
|
||||
operator
|
||||
},
|
||||
fix
|
||||
});
|
||||
} else if (style === "before" && isTokenOnSameLine(leftToken, operatorToken)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: operatorToken.loc,
|
||||
messageId: "operatorAtBeginning",
|
||||
data: {
|
||||
operator
|
||||
},
|
||||
fix
|
||||
});
|
||||
} else if (style === "after" && isTokenOnSameLine(operatorToken, rightToken)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: operatorToken.loc,
|
||||
messageId: "operatorAtEnd",
|
||||
data: {
|
||||
operator
|
||||
},
|
||||
fix
|
||||
});
|
||||
} else if (style === "none") {
|
||||
context.report({
|
||||
node,
|
||||
loc: operatorToken.loc,
|
||||
messageId: "noLinebreak",
|
||||
data: {
|
||||
operator
|
||||
},
|
||||
fix
|
||||
});
|
||||
}
|
||||
}
|
||||
function validateBinaryExpression(node) {
|
||||
validateNode(node, node.right, node.operator);
|
||||
}
|
||||
return {
|
||||
BinaryExpression: validateBinaryExpression,
|
||||
LogicalExpression: validateBinaryExpression,
|
||||
AssignmentExpression: validateBinaryExpression,
|
||||
VariableDeclarator(node) {
|
||||
if (node.init)
|
||||
validateNode(node, node.init, "=");
|
||||
},
|
||||
PropertyDefinition(node) {
|
||||
if (node.value)
|
||||
validateNode(node, node.value, "=");
|
||||
},
|
||||
ConditionalExpression(node) {
|
||||
validateNode(node, node.consequent, "?");
|
||||
validateNode(node, node.alternate, ":");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { operatorLinebreak as default };
|
||||
214
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/padded-blocks.js
generated
vendored
Normal file
214
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/padded-blocks.js
generated
vendored
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
import { c as createRule, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const OPTION_ENUMS = ["always", "never", "start", "end"];
|
||||
var paddedBlocks = createRule({
|
||||
name: "padded-blocks",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow padding within blocks"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: OPTION_ENUMS
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
blocks: {
|
||||
type: "string",
|
||||
enum: OPTION_ENUMS
|
||||
},
|
||||
switches: {
|
||||
type: "string",
|
||||
enum: OPTION_ENUMS
|
||||
},
|
||||
classes: {
|
||||
type: "string",
|
||||
enum: OPTION_ENUMS
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
minProperties: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowSingleLineBlocks: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missingPadBlock: "Block must be padded by blank lines.",
|
||||
extraPadBlock: "Block must not be padded by blank lines."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = {};
|
||||
const typeOptions = context.options[0] || "always";
|
||||
const exceptOptions = context.options[1] || {};
|
||||
if (typeof typeOptions === "string") {
|
||||
options.blocks = typeOptions;
|
||||
options.switches = typeOptions;
|
||||
options.classes = typeOptions;
|
||||
} else {
|
||||
Object.assign(options, typeOptions);
|
||||
}
|
||||
exceptOptions.allowSingleLineBlocks ??= false;
|
||||
const sourceCode = context.sourceCode;
|
||||
function getOpenBrace(node) {
|
||||
if (node.type === "SwitchStatement")
|
||||
return sourceCode.getTokenBefore(node.cases[0]);
|
||||
if (node.type === "StaticBlock")
|
||||
return sourceCode.getFirstToken(node, { skip: 1 });
|
||||
return sourceCode.getFirstToken(node);
|
||||
}
|
||||
function isComment(node) {
|
||||
return node.type === "Line" || node.type === "Block";
|
||||
}
|
||||
function isPaddingBetweenTokens(first, second) {
|
||||
return second.loc.start.line - first.loc.end.line >= 2;
|
||||
}
|
||||
function getFirstBlockToken(token) {
|
||||
let prev;
|
||||
let first = token;
|
||||
do {
|
||||
prev = first;
|
||||
first = sourceCode.getTokenAfter(first, { includeComments: true });
|
||||
} while (isComment(first) && first.loc.start.line === prev.loc.end.line);
|
||||
return first;
|
||||
}
|
||||
function getLastBlockToken(token) {
|
||||
let last = token;
|
||||
let next;
|
||||
do {
|
||||
next = last;
|
||||
last = sourceCode.getTokenBefore(last, { includeComments: true });
|
||||
} while (isComment(last) && last.loc.end.line === next.loc.start.line);
|
||||
return last;
|
||||
}
|
||||
function requirePaddingFor(node) {
|
||||
switch (node.type) {
|
||||
case "BlockStatement":
|
||||
case "StaticBlock":
|
||||
return options.blocks;
|
||||
case "SwitchStatement":
|
||||
return options.switches;
|
||||
case "ClassBody":
|
||||
return options.classes;
|
||||
/* c8 ignore next */
|
||||
default:
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
}
|
||||
function checkPadding(node) {
|
||||
const openBrace = getOpenBrace(node);
|
||||
const firstBlockToken = getFirstBlockToken(openBrace);
|
||||
const tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, { includeComments: true });
|
||||
const closeBrace = sourceCode.getLastToken(node);
|
||||
const lastBlockToken = getLastBlockToken(closeBrace);
|
||||
const tokenAfterLast = sourceCode.getTokenAfter(lastBlockToken, { includeComments: true });
|
||||
const blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken);
|
||||
const blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast);
|
||||
if (exceptOptions.allowSingleLineBlocks && isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast))
|
||||
return;
|
||||
const requiredPadding = requirePaddingFor(node);
|
||||
if (blockHasTopPadding) {
|
||||
if (requiredPadding === "never" || requiredPadding === "end") {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: tokenBeforeFirst.loc.start,
|
||||
end: firstBlockToken.loc.start
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n");
|
||||
},
|
||||
messageId: "extraPadBlock"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (requiredPadding === "always" || requiredPadding === "start") {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: tokenBeforeFirst.loc.start,
|
||||
end: firstBlockToken.loc.start
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(tokenBeforeFirst, "\n");
|
||||
},
|
||||
messageId: "missingPadBlock"
|
||||
});
|
||||
}
|
||||
}
|
||||
if (blockHasBottomPadding) {
|
||||
if (requiredPadding === "never" || requiredPadding === "start") {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
end: tokenAfterLast.loc.start,
|
||||
start: lastBlockToken.loc.end
|
||||
},
|
||||
messageId: "extraPadBlock",
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (requiredPadding === "always" || requiredPadding === "end") {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
end: tokenAfterLast.loc.start,
|
||||
start: lastBlockToken.loc.end
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(tokenAfterLast, "\n");
|
||||
},
|
||||
messageId: "missingPadBlock"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
const rule = {};
|
||||
if (Object.prototype.hasOwnProperty.call(options, "switches")) {
|
||||
rule.SwitchStatement = function(node) {
|
||||
if (node.cases.length === 0)
|
||||
return;
|
||||
checkPadding(node);
|
||||
};
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(options, "blocks")) {
|
||||
rule.BlockStatement = function(node) {
|
||||
if (node.body.length === 0)
|
||||
return;
|
||||
checkPadding(node);
|
||||
};
|
||||
rule.StaticBlock = rule.BlockStatement;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(options, "classes")) {
|
||||
rule.ClassBody = function(node) {
|
||||
if (node.body.length === 0)
|
||||
return;
|
||||
checkPadding(node);
|
||||
};
|
||||
}
|
||||
return rule;
|
||||
}
|
||||
});
|
||||
|
||||
export { paddedBlocks as default };
|
||||
316
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/padding-line-between-statements.js
generated
vendored
Normal file
316
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/padding-line-between-statements.js
generated
vendored
Normal file
|
|
@ -0,0 +1,316 @@
|
|||
import { Q as LINEBREAKS, c as createRule, S as STATEMENT_LIST_PARENTS, R as isDirective, i as isTokenOnSameLine, t as isSemicolonToken, y as isNotSemicolonToken, k as isClosingBraceToken, G as skipChainExpression, s as isFunction } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const LT = `[${Array.from(LINEBREAKS).join("")}]`;
|
||||
const PADDING_LINE_SEQUENCE = new RegExp(
|
||||
String.raw`^(\s*?${LT})\s*${LT}(\s*;?)$`,
|
||||
"u"
|
||||
);
|
||||
const CJS_EXPORT = /^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u;
|
||||
const CJS_IMPORT = /^require\(/u;
|
||||
function newKeywordTester(keyword) {
|
||||
return {
|
||||
test: (node, sourceCode) => sourceCode.getFirstToken(node)?.value === keyword
|
||||
};
|
||||
}
|
||||
function newSinglelineKeywordTester(keyword) {
|
||||
return {
|
||||
test: (node, sourceCode) => node.loc.start.line === node.loc.end.line && sourceCode.getFirstToken(node)?.value === keyword
|
||||
};
|
||||
}
|
||||
function newMultilineKeywordTester(keyword) {
|
||||
return {
|
||||
test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && sourceCode.getFirstToken(node)?.value === keyword
|
||||
};
|
||||
}
|
||||
function newNodeTypeTester(type) {
|
||||
return {
|
||||
test: (node) => node.type === type
|
||||
};
|
||||
}
|
||||
function isIIFEStatement(node) {
|
||||
if (node.type === "ExpressionStatement") {
|
||||
let call = skipChainExpression(node.expression);
|
||||
if (call.type === "UnaryExpression")
|
||||
call = skipChainExpression(call.argument);
|
||||
return call.type === "CallExpression" && isFunction(call.callee);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isBlockLikeStatement(sourceCode, node) {
|
||||
if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement")
|
||||
return true;
|
||||
if (isIIFEStatement(node))
|
||||
return true;
|
||||
const lastToken = sourceCode.getLastToken(node, isNotSemicolonToken);
|
||||
const belongingNode = lastToken && isClosingBraceToken(lastToken) ? sourceCode.getNodeByRangeIndex(lastToken.range[0]) : null;
|
||||
return Boolean(belongingNode) && (belongingNode?.type === "BlockStatement" || belongingNode?.type === "SwitchStatement");
|
||||
}
|
||||
function getActualLastToken(sourceCode, node) {
|
||||
const semiToken = sourceCode.getLastToken(node);
|
||||
const prevToken = sourceCode.getTokenBefore(semiToken);
|
||||
const nextToken = sourceCode.getTokenAfter(semiToken);
|
||||
const isSemicolonLessStyle = Boolean(
|
||||
prevToken && nextToken && prevToken.range[0] >= node.range[0] && isSemicolonToken(semiToken) && semiToken.loc.start.line !== prevToken.loc.end.line && semiToken.loc.end.line === nextToken.loc.start.line
|
||||
);
|
||||
return isSemicolonLessStyle ? prevToken : semiToken;
|
||||
}
|
||||
function replacerToRemovePaddingLines(_, trailingSpaces, indentSpaces) {
|
||||
return trailingSpaces + indentSpaces;
|
||||
}
|
||||
function verifyForAny() {
|
||||
}
|
||||
function verifyForNever(context, _, nextNode, paddingLines) {
|
||||
if (paddingLines.length === 0)
|
||||
return;
|
||||
context.report({
|
||||
node: nextNode,
|
||||
messageId: "unexpectedBlankLine",
|
||||
fix(fixer) {
|
||||
if (paddingLines.length >= 2)
|
||||
return null;
|
||||
const prevToken = paddingLines[0][0];
|
||||
const nextToken = paddingLines[0][1];
|
||||
const start = prevToken.range[1];
|
||||
const end = nextToken.range[0];
|
||||
const text = context.sourceCode.text.slice(start, end).replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines);
|
||||
return fixer.replaceTextRange([start, end], text);
|
||||
}
|
||||
});
|
||||
}
|
||||
function verifyForAlways(context, prevNode, nextNode, paddingLines) {
|
||||
if (paddingLines.length > 0)
|
||||
return;
|
||||
context.report({
|
||||
node: nextNode,
|
||||
messageId: "expectedBlankLine",
|
||||
fix(fixer) {
|
||||
const sourceCode = context.sourceCode;
|
||||
let prevToken = getActualLastToken(sourceCode, prevNode);
|
||||
const nextToken = sourceCode.getFirstTokenBetween(
|
||||
prevToken,
|
||||
nextNode,
|
||||
{
|
||||
includeComments: true,
|
||||
/**
|
||||
* Skip the trailing comments of the previous node.
|
||||
* This inserts a blank line after the last trailing comment.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* foo(); // trailing comment.
|
||||
* // comment.
|
||||
* bar();
|
||||
*
|
||||
* Get fixed to:
|
||||
*
|
||||
* foo(); // trailing comment.
|
||||
*
|
||||
* // comment.
|
||||
* bar();
|
||||
* @param token The token to check.
|
||||
* @returns `true` if the token is not a trailing comment.
|
||||
* @private
|
||||
*/
|
||||
filter(token) {
|
||||
if (isTokenOnSameLine(prevToken, token)) {
|
||||
prevToken = token;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
) || nextNode;
|
||||
const insertText = isTokenOnSameLine(prevToken, nextToken) ? "\n\n" : "\n";
|
||||
return fixer.insertTextAfter(prevToken, insertText);
|
||||
}
|
||||
});
|
||||
}
|
||||
const PaddingTypes = {
|
||||
any: { verify: verifyForAny },
|
||||
never: { verify: verifyForNever },
|
||||
always: { verify: verifyForAlways }
|
||||
};
|
||||
const StatementTypes = {
|
||||
"*": { test: () => true },
|
||||
"block-like": {
|
||||
test: (node, sourceCode) => isBlockLikeStatement(sourceCode, node)
|
||||
},
|
||||
"cjs-export": {
|
||||
test: (node, sourceCode) => node.type === "ExpressionStatement" && node.expression.type === "AssignmentExpression" && CJS_EXPORT.test(sourceCode.getText(node.expression.left))
|
||||
},
|
||||
"cjs-import": {
|
||||
test: (node, sourceCode) => node.type === "VariableDeclaration" && node.declarations.length > 0 && Boolean(node.declarations[0].init) && CJS_IMPORT.test(sourceCode.getText(node.declarations[0].init))
|
||||
},
|
||||
"directive": {
|
||||
test: isDirective
|
||||
},
|
||||
"expression": {
|
||||
test: (node) => node.type === "ExpressionStatement" && !isDirective(node)
|
||||
},
|
||||
"iife": {
|
||||
test: isIIFEStatement
|
||||
},
|
||||
"multiline-block-like": {
|
||||
test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && isBlockLikeStatement(sourceCode, node)
|
||||
},
|
||||
"multiline-expression": {
|
||||
test: (node) => node.loc.start.line !== node.loc.end.line && node.type === "ExpressionStatement" && !isDirective(node)
|
||||
},
|
||||
"multiline-const": newMultilineKeywordTester("const"),
|
||||
"multiline-export": newMultilineKeywordTester("export"),
|
||||
"multiline-let": newMultilineKeywordTester("let"),
|
||||
"multiline-var": newMultilineKeywordTester("var"),
|
||||
"singleline-const": newSinglelineKeywordTester("const"),
|
||||
"singleline-export": newSinglelineKeywordTester("export"),
|
||||
"singleline-let": newSinglelineKeywordTester("let"),
|
||||
"singleline-var": newSinglelineKeywordTester("var"),
|
||||
"block": newNodeTypeTester("BlockStatement"),
|
||||
"empty": newNodeTypeTester("EmptyStatement"),
|
||||
"function": newNodeTypeTester("FunctionDeclaration"),
|
||||
"break": newKeywordTester("break"),
|
||||
"case": newKeywordTester("case"),
|
||||
"class": newKeywordTester("class"),
|
||||
"const": newKeywordTester("const"),
|
||||
"continue": newKeywordTester("continue"),
|
||||
"debugger": newKeywordTester("debugger"),
|
||||
"default": newKeywordTester("default"),
|
||||
"do": newKeywordTester("do"),
|
||||
"export": newKeywordTester("export"),
|
||||
"for": newKeywordTester("for"),
|
||||
"if": newKeywordTester("if"),
|
||||
"import": newKeywordTester("import"),
|
||||
"let": newKeywordTester("let"),
|
||||
"return": newKeywordTester("return"),
|
||||
"switch": newKeywordTester("switch"),
|
||||
"throw": newKeywordTester("throw"),
|
||||
"try": newKeywordTester("try"),
|
||||
"var": newKeywordTester("var"),
|
||||
"while": newKeywordTester("while"),
|
||||
"with": newKeywordTester("with")
|
||||
};
|
||||
var paddingLineBetweenStatements = createRule({
|
||||
name: "padding-line-between-statements",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow padding lines between statements"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: {
|
||||
definitions: {
|
||||
paddingType: {
|
||||
type: "string",
|
||||
enum: Object.keys(PaddingTypes)
|
||||
},
|
||||
statementType: {
|
||||
anyOf: [
|
||||
{ type: "string", enum: Object.keys(StatementTypes) },
|
||||
{
|
||||
type: "array",
|
||||
items: { type: "string", enum: Object.keys(StatementTypes) },
|
||||
minItems: 1,
|
||||
uniqueItems: true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
blankLine: { $ref: "#/definitions/paddingType" },
|
||||
prev: { $ref: "#/definitions/statementType" },
|
||||
next: { $ref: "#/definitions/statementType" }
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ["blankLine", "prev", "next"]
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
unexpectedBlankLine: "Unexpected blank line before this statement.",
|
||||
expectedBlankLine: "Expected blank line before this statement."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const configureList = context.options || [];
|
||||
let scopeInfo = null;
|
||||
function enterScope() {
|
||||
scopeInfo = {
|
||||
upper: scopeInfo,
|
||||
prevNode: null
|
||||
};
|
||||
}
|
||||
function exitScope() {
|
||||
scopeInfo = scopeInfo?.upper;
|
||||
}
|
||||
function match(node, type) {
|
||||
let innerStatementNode = node;
|
||||
while (innerStatementNode.type === "LabeledStatement")
|
||||
innerStatementNode = innerStatementNode.body;
|
||||
if (Array.isArray(type))
|
||||
return type.some(match.bind(null, innerStatementNode));
|
||||
return StatementTypes[type].test(innerStatementNode, sourceCode);
|
||||
}
|
||||
function getPaddingType(prevNode, nextNode) {
|
||||
for (let i = configureList.length - 1; i >= 0; --i) {
|
||||
const configure = configureList[i];
|
||||
const matched = match(prevNode, configure.prev) && match(nextNode, configure.next);
|
||||
if (matched)
|
||||
return PaddingTypes[configure.blankLine];
|
||||
}
|
||||
return PaddingTypes.any;
|
||||
}
|
||||
function getPaddingLineSequences(prevNode, nextNode) {
|
||||
const pairs = [];
|
||||
let prevToken = getActualLastToken(sourceCode, prevNode);
|
||||
if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
|
||||
do {
|
||||
const token = sourceCode.getTokenAfter(
|
||||
prevToken,
|
||||
{ includeComments: true }
|
||||
);
|
||||
if (token.loc.start.line - prevToken.loc.end.line >= 2)
|
||||
pairs.push([prevToken, token]);
|
||||
prevToken = token;
|
||||
} while (prevToken.range[0] < nextNode.range[0]);
|
||||
}
|
||||
return pairs;
|
||||
}
|
||||
function verify(node) {
|
||||
const parentType = node.parent.type;
|
||||
const validParent = STATEMENT_LIST_PARENTS.has(parentType) || parentType === "SwitchStatement";
|
||||
if (!validParent)
|
||||
return;
|
||||
const prevNode = scopeInfo?.prevNode;
|
||||
if (prevNode) {
|
||||
const type = getPaddingType(prevNode, node);
|
||||
const paddingLines = getPaddingLineSequences(prevNode, node);
|
||||
type.verify(context, prevNode, node, paddingLines);
|
||||
}
|
||||
scopeInfo.prevNode = node;
|
||||
}
|
||||
function verifyThenEnterScope(node) {
|
||||
verify(node);
|
||||
enterScope();
|
||||
}
|
||||
return {
|
||||
"Program": enterScope,
|
||||
"BlockStatement": enterScope,
|
||||
"SwitchStatement": enterScope,
|
||||
"StaticBlock": enterScope,
|
||||
"Program:exit": exitScope,
|
||||
"BlockStatement:exit": exitScope,
|
||||
"SwitchStatement:exit": exitScope,
|
||||
"StaticBlock:exit": exitScope,
|
||||
":statement": verify,
|
||||
"SwitchCase": verifyThenEnterScope,
|
||||
"SwitchCase:exit": exitScope
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { paddingLineBetweenStatements as default };
|
||||
241
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/quote-props.js
generated
vendored
Normal file
241
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/quote-props.js
generated
vendored
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
import { c as createRule, T as isNumericLiteral, K as KEYWORDS_JS } from '../utils.js';
|
||||
import { tokenize } from 'espree';
|
||||
import 'eslint-visitor-keys';
|
||||
|
||||
var quoteProps = createRule({
|
||||
name: "quote-props",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require quotes around object literal property names"
|
||||
},
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 1
|
||||
},
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
keywords: {
|
||||
type: "boolean"
|
||||
},
|
||||
unnecessary: {
|
||||
type: "boolean"
|
||||
},
|
||||
numbers: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2
|
||||
}
|
||||
]
|
||||
},
|
||||
fixable: "code",
|
||||
messages: {
|
||||
requireQuotesDueToReservedWord: "Properties should be quoted as '{{property}}' is a reserved word.",
|
||||
inconsistentlyQuotedProperty: "Inconsistently quoted property '{{key}}' found.",
|
||||
unnecessarilyQuotedProperty: "Unnecessarily quoted property '{{property}}' found.",
|
||||
unquotedReservedProperty: "Unquoted reserved word '{{property}}' used as key.",
|
||||
unquotedNumericProperty: "Unquoted number literal '{{property}}' used as key.",
|
||||
unquotedPropertyFound: "Unquoted property '{{property}}' found.",
|
||||
redundantQuoting: "Properties shouldn't be quoted as all quotes are redundant."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const MODE = context.options[0];
|
||||
const KEYWORDS = context.options[1] && context.options[1].keywords;
|
||||
const CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false;
|
||||
const NUMBERS = context.options[1] && context.options[1].numbers;
|
||||
const sourceCode = context.sourceCode;
|
||||
function isKeyword(tokenStr) {
|
||||
return KEYWORDS_JS.includes(tokenStr);
|
||||
}
|
||||
function areQuotesRedundant(rawKey, tokens, skipNumberLiterals = false) {
|
||||
return tokens.length === 1 && tokens[0].start === 0 && tokens[0].end === rawKey.length && (["Identifier", "Keyword", "Null", "Boolean"].includes(tokens[0].type) || tokens[0].type === "Numeric" && !skipNumberLiterals && String(+tokens[0].value) === tokens[0].value);
|
||||
}
|
||||
function getUnquotedKey(key) {
|
||||
return key.type === "Identifier" ? key.name : key.value;
|
||||
}
|
||||
function getQuotedKey(key) {
|
||||
if (key.type === "Literal" && typeof key.value === "string") {
|
||||
return sourceCode.getText(key);
|
||||
}
|
||||
return `"${key.type === "Identifier" ? key.name : key.value}"`;
|
||||
}
|
||||
function checkUnnecessaryQuotes(node) {
|
||||
const key = node.key;
|
||||
if (node.type !== "ImportAttribute" && (node.method || node.computed || node.shorthand))
|
||||
return;
|
||||
if (key.type === "Literal" && typeof key.value === "string") {
|
||||
let tokens;
|
||||
try {
|
||||
tokens = tokenize(key.value);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (tokens.length !== 1)
|
||||
return;
|
||||
const isKeywordToken = isKeyword(tokens[0].value);
|
||||
if (isKeywordToken && KEYWORDS)
|
||||
return;
|
||||
if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unnecessarilyQuotedProperty",
|
||||
data: { property: key.value },
|
||||
fix: (fixer) => fixer.replaceText(key, getUnquotedKey(key))
|
||||
});
|
||||
}
|
||||
} else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unquotedReservedProperty",
|
||||
data: { property: key.name },
|
||||
fix: (fixer) => fixer.replaceText(key, getQuotedKey(key))
|
||||
});
|
||||
} else if (NUMBERS && key.type === "Literal" && isNumericLiteral(key)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unquotedNumericProperty",
|
||||
data: { property: key.value },
|
||||
fix: (fixer) => fixer.replaceText(key, getQuotedKey(key))
|
||||
});
|
||||
}
|
||||
}
|
||||
function checkOmittedQuotes(node) {
|
||||
if (node.type !== "ImportAttribute" && (node.method || node.computed || node.shorthand))
|
||||
return;
|
||||
const key = node.key;
|
||||
if (key.type === "Literal" && typeof key.value === "string")
|
||||
return;
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unquotedPropertyFound",
|
||||
data: { property: key.name || key.value },
|
||||
fix: (fixer) => fixer.replaceText(key, getQuotedKey(key))
|
||||
});
|
||||
}
|
||||
function checkConsistencyForObject(node, checkQuotesRedundancy) {
|
||||
checkConsistency(
|
||||
node.properties.filter((property) => property.type !== "SpreadElement" && property.key && !property.method && !property.computed && !property.shorthand),
|
||||
checkQuotesRedundancy
|
||||
);
|
||||
}
|
||||
function checkImportAttributes(attributes) {
|
||||
if (!attributes)
|
||||
return;
|
||||
if (MODE === "consistent")
|
||||
checkConsistency(attributes, false);
|
||||
if (MODE === "consistent-as-needed")
|
||||
checkConsistency(attributes, true);
|
||||
}
|
||||
function checkConsistency(properties, checkQuotesRedundancy) {
|
||||
const quotedProps = [];
|
||||
const unquotedProps = [];
|
||||
let keywordKeyName = null;
|
||||
let necessaryQuotes = false;
|
||||
properties.forEach((property) => {
|
||||
const key = property.key;
|
||||
if (key.type === "Literal" && typeof key.value === "string") {
|
||||
quotedProps.push(property);
|
||||
if (checkQuotesRedundancy) {
|
||||
let tokens;
|
||||
try {
|
||||
tokens = tokenize(key.value);
|
||||
} catch {
|
||||
necessaryQuotes = true;
|
||||
return;
|
||||
}
|
||||
necessaryQuotes = necessaryQuotes || !areQuotesRedundant(key.value, tokens) || KEYWORDS && isKeyword(tokens[0].value);
|
||||
}
|
||||
} else if (KEYWORDS && checkQuotesRedundancy && key.type === "Identifier" && isKeyword(key.name)) {
|
||||
unquotedProps.push(property);
|
||||
necessaryQuotes = true;
|
||||
keywordKeyName = key.name;
|
||||
} else {
|
||||
unquotedProps.push(property);
|
||||
}
|
||||
});
|
||||
if (checkQuotesRedundancy && quotedProps.length && !necessaryQuotes) {
|
||||
quotedProps.forEach((property) => {
|
||||
const key = property.key;
|
||||
context.report({
|
||||
node: property,
|
||||
messageId: "redundantQuoting",
|
||||
fix: (fixer) => fixer.replaceText(key, getUnquotedKey(key))
|
||||
});
|
||||
});
|
||||
} else if (unquotedProps.length && keywordKeyName) {
|
||||
unquotedProps.forEach((property) => {
|
||||
context.report({
|
||||
node: property,
|
||||
messageId: "requireQuotesDueToReservedWord",
|
||||
data: { property: keywordKeyName },
|
||||
fix: (fixer) => fixer.replaceText(property.key, getQuotedKey(property.key))
|
||||
});
|
||||
});
|
||||
} else if (quotedProps.length && unquotedProps.length) {
|
||||
unquotedProps.forEach((property) => {
|
||||
context.report({
|
||||
node: property,
|
||||
messageId: "inconsistentlyQuotedProperty",
|
||||
data: { key: property.key.name || property.key.value },
|
||||
fix: (fixer) => fixer.replaceText(property.key, getQuotedKey(property.key))
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
Property(node) {
|
||||
if (MODE === "always" || !MODE)
|
||||
checkOmittedQuotes(node);
|
||||
if (MODE === "as-needed")
|
||||
checkUnnecessaryQuotes(node);
|
||||
},
|
||||
ObjectExpression(node) {
|
||||
if (MODE === "consistent")
|
||||
checkConsistencyForObject(node, false);
|
||||
if (MODE === "consistent-as-needed")
|
||||
checkConsistencyForObject(node, true);
|
||||
},
|
||||
ImportAttribute(node) {
|
||||
if (MODE === "always" || !MODE)
|
||||
checkOmittedQuotes(node);
|
||||
if (MODE === "as-needed")
|
||||
checkUnnecessaryQuotes(node);
|
||||
},
|
||||
ImportDeclaration(node) {
|
||||
checkImportAttributes(node.attributes);
|
||||
},
|
||||
ExportAllDeclaration(node) {
|
||||
checkImportAttributes(node.attributes);
|
||||
},
|
||||
ExportNamedDeclaration(node) {
|
||||
checkImportAttributes(node.attributes);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { quoteProps as default };
|
||||
235
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/quotes.js
generated
vendored
Normal file
235
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/quotes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
import { Q as LINEBREAKS, c as createRule, O as isTopLevelExpressionStatement, H as isParenthesised, B as isSurroundedBy, U as hasOctalOrNonOctalDecimalEscapeSequence } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
function switchQuote(str) {
|
||||
const newQuote = this.quote;
|
||||
const oldQuote = str[0];
|
||||
if (newQuote === oldQuote)
|
||||
return str;
|
||||
return newQuote + str.slice(1, -1).replace(/\\(\$\{|\r\n?|\n|.)|["'`]|\$\{|(\r\n?|\n)/gu, (match, escaped, newline) => {
|
||||
if (escaped === oldQuote || oldQuote === "`" && escaped === "${")
|
||||
return escaped;
|
||||
if (match === newQuote || newQuote === "`" && match === "${")
|
||||
return `\\${match}`;
|
||||
if (newline && oldQuote === "`")
|
||||
return "\\n";
|
||||
return match;
|
||||
}) + newQuote;
|
||||
}
|
||||
const QUOTE_SETTINGS = {
|
||||
double: {
|
||||
quote: '"',
|
||||
alternateQuote: "'",
|
||||
description: "doublequote",
|
||||
convert: switchQuote
|
||||
},
|
||||
single: {
|
||||
quote: "'",
|
||||
alternateQuote: '"',
|
||||
description: "singlequote",
|
||||
convert: switchQuote
|
||||
},
|
||||
backtick: {
|
||||
quote: "`",
|
||||
alternateQuote: '"',
|
||||
description: "backtick",
|
||||
convert: switchQuote
|
||||
}
|
||||
};
|
||||
const UNESCAPED_LINEBREAK_PATTERN = new RegExp(String.raw`(^|[^\\])(\\\\)*[${Array.from(LINEBREAKS).join("")}]`, "u");
|
||||
const AVOID_ESCAPE = "avoid-escape";
|
||||
var quotes = createRule({
|
||||
name: "quotes",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce the consistent use of either backticks, double, or single quotes"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["single", "double", "backtick"]
|
||||
},
|
||||
{
|
||||
anyOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["avoid-escape"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
avoidEscape: {
|
||||
type: "boolean"
|
||||
},
|
||||
allowTemplateLiterals: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
type: "string",
|
||||
enum: ["never", "avoidEscape", "always"]
|
||||
}
|
||||
]
|
||||
},
|
||||
ignoreStringLiterals: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
wrongQuotes: "Strings must use {{description}}."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const quoteOption = context.options[0];
|
||||
const settings = QUOTE_SETTINGS[quoteOption || "double"];
|
||||
const options = context.options[1];
|
||||
const sourceCode = context.sourceCode;
|
||||
let avoidEscape = false;
|
||||
let ignoreStringLiterals = false;
|
||||
let allowTemplateLiteralsAlways = false;
|
||||
let allowTemplateLiteralsToAvoidEscape = false;
|
||||
if (typeof options === "object") {
|
||||
avoidEscape = options.avoidEscape === true;
|
||||
ignoreStringLiterals = options.ignoreStringLiterals === true;
|
||||
if (typeof options.allowTemplateLiterals === "string") {
|
||||
allowTemplateLiteralsAlways = options.allowTemplateLiterals === "always";
|
||||
allowTemplateLiteralsToAvoidEscape = allowTemplateLiteralsAlways || options.allowTemplateLiterals === "avoidEscape";
|
||||
} else if (typeof options.allowTemplateLiterals === "boolean") {
|
||||
allowTemplateLiteralsAlways = options.allowTemplateLiterals === true;
|
||||
allowTemplateLiteralsToAvoidEscape = options.allowTemplateLiterals === true;
|
||||
}
|
||||
} else if (options === AVOID_ESCAPE) {
|
||||
avoidEscape = true;
|
||||
}
|
||||
function isJSXLiteral(node) {
|
||||
if (!node.parent)
|
||||
return false;
|
||||
return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment";
|
||||
}
|
||||
function isDirective(node) {
|
||||
return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string" && !isParenthesised(sourceCode, node.expression);
|
||||
}
|
||||
function isExpressionInOrJustAfterDirectivePrologue(node) {
|
||||
if (!node.parent)
|
||||
return false;
|
||||
if (!isTopLevelExpressionStatement(node.parent))
|
||||
return false;
|
||||
const block = node.parent.parent;
|
||||
if (!block || !("body" in block) || !Array.isArray(block.body))
|
||||
return false;
|
||||
for (let i = 0; i < block.body.length; ++i) {
|
||||
const statement = block.body[i];
|
||||
if (statement === node.parent)
|
||||
return true;
|
||||
if (!isDirective(statement))
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isAllowedAsNonBacktick(node) {
|
||||
const parent = node.parent;
|
||||
if (!parent)
|
||||
return false;
|
||||
switch (parent.type) {
|
||||
// Directive Prologues.
|
||||
case "ExpressionStatement":
|
||||
return !isParenthesised(sourceCode, node) && isExpressionInOrJustAfterDirectivePrologue(node);
|
||||
// LiteralPropertyName.
|
||||
case "Property":
|
||||
case "PropertyDefinition":
|
||||
case "MethodDefinition":
|
||||
return parent.key === node && !parent.computed;
|
||||
// ModuleSpecifier.
|
||||
case "ImportDeclaration":
|
||||
case "ExportNamedDeclaration":
|
||||
return parent.source === node;
|
||||
// ModuleExportName or ModuleSpecifier.
|
||||
case "ExportAllDeclaration":
|
||||
return parent.exported === node || parent.source === node;
|
||||
// ModuleExportName.
|
||||
case "ImportSpecifier":
|
||||
return parent.imported === node;
|
||||
// ModuleExportName.
|
||||
case "ExportSpecifier":
|
||||
return parent.local === node || parent.exported === node;
|
||||
case "ImportAttribute":
|
||||
return parent.value === node;
|
||||
// Others don't allow.
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function isUsingFeatureOfTemplateLiteral(node) {
|
||||
const hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi;
|
||||
if (hasTag)
|
||||
return true;
|
||||
const hasStringInterpolation = node.expressions.length > 0;
|
||||
if (hasStringInterpolation)
|
||||
return true;
|
||||
const isMultilineString = node.quasis.length >= 1 && UNESCAPED_LINEBREAK_PATTERN.test(node.quasis[0].value.raw);
|
||||
if (isMultilineString)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
Literal(node) {
|
||||
if (ignoreStringLiterals)
|
||||
return;
|
||||
const val = node.value;
|
||||
const rawVal = node.raw;
|
||||
if (settings && typeof val === "string") {
|
||||
let isValid = quoteOption === "backtick" && isAllowedAsNonBacktick(node) || isJSXLiteral(node) || isSurroundedBy(rawVal, settings.quote);
|
||||
if (!isValid && avoidEscape)
|
||||
isValid = isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.includes(settings.quote);
|
||||
if (!isValid) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrongQuotes",
|
||||
data: {
|
||||
description: settings.description
|
||||
},
|
||||
fix(fixer) {
|
||||
if (quoteOption === "backtick" && hasOctalOrNonOctalDecimalEscapeSequence(rawVal)) {
|
||||
return null;
|
||||
}
|
||||
return fixer.replaceText(node, settings.convert(node.raw));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
TemplateLiteral(node) {
|
||||
if (allowTemplateLiteralsAlways || quoteOption === "backtick" || isUsingFeatureOfTemplateLiteral(node)) {
|
||||
return;
|
||||
}
|
||||
if (allowTemplateLiteralsToAvoidEscape && avoidEscape && sourceCode.getText(node).includes(settings.quote))
|
||||
return;
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrongQuotes",
|
||||
data: {
|
||||
description: settings.description
|
||||
},
|
||||
fix(fixer) {
|
||||
if (isTopLevelExpressionStatement(node.parent) && !isParenthesised(sourceCode, node)) {
|
||||
return null;
|
||||
}
|
||||
return fixer.replaceText(node, settings.convert(sourceCode.getText(node)));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { quotes as default };
|
||||
83
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/rest-spread-spacing.js
generated
vendored
Normal file
83
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/rest-spread-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var restSpreadSpacing = createRule({
|
||||
name: "rest-spread-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce spacing between rest and spread operators and their expressions"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedWhitespace: "Unexpected whitespace after {{type}} operator.",
|
||||
expectedWhitespace: "Expected whitespace after {{type}} operator."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const alwaysSpace = context.options[0] === "always";
|
||||
function checkWhiteSpace(node) {
|
||||
const operator = sourceCode.getFirstToken(node);
|
||||
const nextToken = sourceCode.getTokenAfter(operator);
|
||||
const hasWhitespace = sourceCode.isSpaceBetween(operator, nextToken);
|
||||
let type;
|
||||
switch (node.type) {
|
||||
case "SpreadElement":
|
||||
type = "spread";
|
||||
if (node.parent.type === "ObjectExpression")
|
||||
type += " property";
|
||||
break;
|
||||
case "RestElement":
|
||||
type = "rest";
|
||||
if (node.parent.type === "ObjectPattern")
|
||||
type += " property";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (alwaysSpace && !hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: operator.loc,
|
||||
messageId: "expectedWhitespace",
|
||||
data: {
|
||||
type
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " ");
|
||||
}
|
||||
});
|
||||
} else if (!alwaysSpace && hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: operator.loc.end,
|
||||
end: nextToken.loc.start
|
||||
},
|
||||
messageId: "unexpectedWhitespace",
|
||||
data: {
|
||||
type
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([operator.range[1], nextToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
SpreadElement: checkWhiteSpace,
|
||||
RestElement: checkWhiteSpace
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { restSpreadSpacing as default };
|
||||
158
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/semi-spacing.js
generated
vendored
Normal file
158
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/semi-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
import { c as createRule, t as isSemicolonToken, i as isTokenOnSameLine, k as isClosingBraceToken, f as isClosingParenToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var semiSpacing = createRule({
|
||||
name: "semi-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after semicolons"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
after: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedWhitespaceBefore: "Unexpected whitespace before semicolon.",
|
||||
unexpectedWhitespaceAfter: "Unexpected whitespace after semicolon.",
|
||||
missingWhitespaceBefore: "Missing whitespace before semicolon.",
|
||||
missingWhitespaceAfter: "Missing whitespace after semicolon."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const config = context.options[0];
|
||||
const sourceCode = context.sourceCode;
|
||||
let requireSpaceBefore = false;
|
||||
let requireSpaceAfter = true;
|
||||
if (typeof config === "object") {
|
||||
requireSpaceBefore = config.before;
|
||||
requireSpaceAfter = config.after;
|
||||
}
|
||||
function hasLeadingSpace(token) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(token);
|
||||
return tokenBefore && isTokenOnSameLine(tokenBefore, token) && sourceCode.isSpaceBetween(tokenBefore, token);
|
||||
}
|
||||
function hasTrailingSpace(token) {
|
||||
const tokenAfter = sourceCode.getTokenAfter(token);
|
||||
return tokenAfter && isTokenOnSameLine(token, tokenAfter) && sourceCode.isSpaceBetween(token, tokenAfter);
|
||||
}
|
||||
function isLastTokenInCurrentLine(token) {
|
||||
const tokenAfter = sourceCode.getTokenAfter(token);
|
||||
return !(tokenAfter && isTokenOnSameLine(token, tokenAfter));
|
||||
}
|
||||
function isFirstTokenInCurrentLine(token) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(token);
|
||||
return !(tokenBefore && isTokenOnSameLine(token, tokenBefore));
|
||||
}
|
||||
function isBeforeClosingParen(token) {
|
||||
const nextToken = sourceCode.getTokenAfter(token);
|
||||
return nextToken && isClosingBraceToken(nextToken) || isClosingParenToken(nextToken);
|
||||
}
|
||||
function checkSemicolonSpacing(token, node) {
|
||||
if (isSemicolonToken(token)) {
|
||||
if (hasLeadingSpace(token)) {
|
||||
if (!requireSpaceBefore) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(token);
|
||||
const loc = {
|
||||
start: tokenBefore.loc.end,
|
||||
end: token.loc.start
|
||||
};
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: "unexpectedWhitespaceBefore",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (requireSpaceBefore) {
|
||||
const loc = token.loc;
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: "missingWhitespaceBefore",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) {
|
||||
if (hasTrailingSpace(token)) {
|
||||
if (!requireSpaceAfter) {
|
||||
const tokenAfter = sourceCode.getTokenAfter(token);
|
||||
const loc = {
|
||||
start: token.loc.end,
|
||||
end: tokenAfter.loc.start
|
||||
};
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: "unexpectedWhitespaceAfter",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (requireSpaceAfter) {
|
||||
const loc = token.loc;
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: "missingWhitespaceAfter",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkNode(node) {
|
||||
const token = sourceCode.getLastToken(node);
|
||||
checkSemicolonSpacing(token, node);
|
||||
}
|
||||
return {
|
||||
VariableDeclaration: checkNode,
|
||||
ExpressionStatement: checkNode,
|
||||
BreakStatement: checkNode,
|
||||
ContinueStatement: checkNode,
|
||||
DebuggerStatement: checkNode,
|
||||
DoWhileStatement: checkNode,
|
||||
ReturnStatement: checkNode,
|
||||
ThrowStatement: checkNode,
|
||||
ImportDeclaration: checkNode,
|
||||
ExportNamedDeclaration: checkNode,
|
||||
ExportAllDeclaration: checkNode,
|
||||
ExportDefaultDeclaration: checkNode,
|
||||
ForStatement(node) {
|
||||
if (node.init)
|
||||
checkSemicolonSpacing(sourceCode.getTokenAfter(node.init), node);
|
||||
if (node.test)
|
||||
checkSemicolonSpacing(sourceCode.getTokenAfter(node.test), node);
|
||||
},
|
||||
PropertyDefinition: checkNode
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { semiSpacing as default };
|
||||
102
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/semi-style.js
generated
vendored
Normal file
102
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/semi-style.js
generated
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
import { c as createRule, t as isSemicolonToken, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
const SELECTOR = [
|
||||
"BreakStatement",
|
||||
"ContinueStatement",
|
||||
"DebuggerStatement",
|
||||
"DoWhileStatement",
|
||||
"ExportAllDeclaration",
|
||||
"ExportDefaultDeclaration",
|
||||
"ExportNamedDeclaration",
|
||||
"ExpressionStatement",
|
||||
"ImportDeclaration",
|
||||
"ReturnStatement",
|
||||
"ThrowStatement",
|
||||
"VariableDeclaration",
|
||||
"PropertyDefinition"
|
||||
].join(",");
|
||||
function getChildren(node) {
|
||||
const t = node.type;
|
||||
if (t === "BlockStatement" || t === "StaticBlock" || t === "Program" || t === "ClassBody") {
|
||||
return node.body;
|
||||
}
|
||||
if (t === "SwitchCase")
|
||||
return node.consequent;
|
||||
return null;
|
||||
}
|
||||
function isLastChild(node) {
|
||||
if (!node.parent)
|
||||
return true;
|
||||
const t = node.parent.type;
|
||||
if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) {
|
||||
return true;
|
||||
}
|
||||
if (t === "DoWhileStatement") {
|
||||
return true;
|
||||
}
|
||||
const nodeList = getChildren(node.parent);
|
||||
return nodeList !== null && nodeList[nodeList.length - 1] === node;
|
||||
}
|
||||
var semiStyle = createRule({
|
||||
name: "semi-style",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce location of semicolons"
|
||||
},
|
||||
schema: [{ type: "string", enum: ["last", "first"] }],
|
||||
fixable: "whitespace",
|
||||
messages: {
|
||||
expectedSemiColon: "Expected this semicolon to be at {{pos}}."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0] || "last";
|
||||
function check(semiToken, expected) {
|
||||
const prevToken = sourceCode.getTokenBefore(semiToken);
|
||||
const nextToken = sourceCode.getTokenAfter(semiToken);
|
||||
const prevIsSameLine = !prevToken || isTokenOnSameLine(prevToken, semiToken);
|
||||
const nextIsSameLine = !nextToken || isTokenOnSameLine(semiToken, nextToken);
|
||||
if (expected === "last" && !prevIsSameLine || expected === "first" && !nextIsSameLine) {
|
||||
context.report({
|
||||
loc: semiToken.loc,
|
||||
messageId: "expectedSemiColon",
|
||||
data: {
|
||||
pos: expected === "last" ? "the end of the previous line" : "the beginning of the next line"
|
||||
},
|
||||
fix(fixer) {
|
||||
if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken))
|
||||
return null;
|
||||
const start = prevToken ? prevToken.range[1] : semiToken.range[0];
|
||||
const end = nextToken ? nextToken.range[0] : semiToken.range[1];
|
||||
const text = expected === "last" ? ";\n" : "\n;";
|
||||
return fixer.replaceTextRange([start, end], text);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
[SELECTOR](node) {
|
||||
if (option === "first" && isLastChild(node))
|
||||
return;
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (isSemicolonToken(lastToken))
|
||||
check(lastToken, option);
|
||||
},
|
||||
ForStatement(node) {
|
||||
const firstSemi = node.init && sourceCode.getTokenAfter(node.init, isSemicolonToken);
|
||||
const secondSemi = node.test && sourceCode.getTokenAfter(node.test, isSemicolonToken);
|
||||
if (firstSemi)
|
||||
check(firstSemi, "last");
|
||||
if (secondSemi)
|
||||
check(secondSemi, "last");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { semiStyle as default };
|
||||
231
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/semi.js
generated
vendored
Normal file
231
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/semi.js
generated
vendored
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
import { c as createRule, t as isSemicolonToken, h as getNextLocation, P as FixTracker, k as isClosingBraceToken, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var semi = createRule({
|
||||
name: "semi",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow semicolons instead of ASI"
|
||||
},
|
||||
fixable: "code",
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
beforeStatementContinuationChars: {
|
||||
type: "string",
|
||||
enum: ["always", "any", "never"]
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2
|
||||
},
|
||||
{
|
||||
type: "array",
|
||||
items: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
omitLastInOneLineBlock: { type: "boolean" },
|
||||
omitLastInOneLineClassBody: { type: "boolean" }
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2
|
||||
}
|
||||
]
|
||||
},
|
||||
messages: {
|
||||
missingSemi: "Missing semicolon.",
|
||||
extraSemi: "Extra semicolon."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const OPT_OUT_PATTERN = /^[-[(/+`]/u;
|
||||
const unsafeClassFieldNames = /* @__PURE__ */ new Set(["get", "set", "static"]);
|
||||
const unsafeClassFieldFollowers = /* @__PURE__ */ new Set(["*", "in", "instanceof"]);
|
||||
const options = context.options[1];
|
||||
const never = context.options[0] === "never";
|
||||
const exceptOneLine = Boolean(options && "omitLastInOneLineBlock" in options && options.omitLastInOneLineBlock);
|
||||
const exceptOneLineClassBody = Boolean(options && "omitLastInOneLineClassBody" in options && options.omitLastInOneLineClassBody);
|
||||
const beforeStatementContinuationChars = options && "beforeStatementContinuationChars" in options && options.beforeStatementContinuationChars || "any";
|
||||
const sourceCode = context.sourceCode;
|
||||
function report(node, missing = false) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
let messageId = "missingSemi";
|
||||
let fix, loc;
|
||||
if (!missing) {
|
||||
loc = {
|
||||
start: lastToken.loc.end,
|
||||
end: getNextLocation(sourceCode, lastToken.loc.end)
|
||||
};
|
||||
fix = function(fixer) {
|
||||
return fixer.insertTextAfter(lastToken, ";");
|
||||
};
|
||||
} else {
|
||||
messageId = "extraSemi";
|
||||
loc = lastToken.loc;
|
||||
fix = function(fixer) {
|
||||
return new FixTracker(fixer, sourceCode).retainSurroundingTokens(lastToken).remove(lastToken);
|
||||
};
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId,
|
||||
fix
|
||||
});
|
||||
}
|
||||
function isRedundantSemi(semiToken) {
|
||||
const nextToken = sourceCode.getTokenAfter(semiToken);
|
||||
return !nextToken || isClosingBraceToken(nextToken) || isSemicolonToken(nextToken);
|
||||
}
|
||||
function isEndOfArrowBlock(lastToken) {
|
||||
if (!isClosingBraceToken(lastToken))
|
||||
return false;
|
||||
const node = sourceCode.getNodeByRangeIndex(lastToken.range[0]);
|
||||
return node.type === "BlockStatement" && node.parent.type === "ArrowFunctionExpression";
|
||||
}
|
||||
function maybeClassFieldAsiHazard(node) {
|
||||
if (node.type !== "PropertyDefinition")
|
||||
return false;
|
||||
const needsNameCheck = !node.computed && node.key.type === "Identifier";
|
||||
if (needsNameCheck && "name" in node.key && unsafeClassFieldNames.has(node.key.name)) {
|
||||
const isStaticStatic = node.static && node.key.name === "static";
|
||||
if (!isStaticStatic && !node.value)
|
||||
return true;
|
||||
}
|
||||
const followingToken = sourceCode.getTokenAfter(node);
|
||||
return unsafeClassFieldFollowers.has(followingToken.value);
|
||||
}
|
||||
function isOnSameLineWithNextToken(node) {
|
||||
const prevToken = sourceCode.getLastToken(node, 1);
|
||||
const nextToken = sourceCode.getTokenAfter(node);
|
||||
return !!nextToken && isTokenOnSameLine(prevToken, nextToken);
|
||||
}
|
||||
function maybeAsiHazardAfter(node) {
|
||||
const t = node.type;
|
||||
if (t === "DoWhileStatement" || t === "BreakStatement" || t === "ContinueStatement" || t === "DebuggerStatement" || t === "ImportDeclaration" || t === "ExportAllDeclaration") {
|
||||
return false;
|
||||
}
|
||||
if (t === "ReturnStatement")
|
||||
return Boolean(node.argument);
|
||||
if (t === "ExportNamedDeclaration")
|
||||
return Boolean(node.declaration);
|
||||
const lastToken = sourceCode.getLastToken(node, 1);
|
||||
if (isEndOfArrowBlock(lastToken))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
function maybeAsiHazardBefore(token) {
|
||||
return Boolean(token) && OPT_OUT_PATTERN.test(token.value) && token.value !== "++" && token.value !== "--";
|
||||
}
|
||||
function canRemoveSemicolon(node) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (isRedundantSemi(lastToken))
|
||||
return true;
|
||||
if (maybeClassFieldAsiHazard(node))
|
||||
return false;
|
||||
if (isOnSameLineWithNextToken(node))
|
||||
return false;
|
||||
if (node.type !== "PropertyDefinition" && beforeStatementContinuationChars === "never" && !maybeAsiHazardAfter(node)) {
|
||||
return true;
|
||||
}
|
||||
const nextToken = sourceCode.getTokenAfter(node);
|
||||
if (!maybeAsiHazardBefore(nextToken))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function isLastInOneLinerBlock(node) {
|
||||
const parent = node.parent;
|
||||
const nextToken = sourceCode.getTokenAfter(node);
|
||||
if (!nextToken || nextToken.value !== "}")
|
||||
return false;
|
||||
if (parent.type === "BlockStatement")
|
||||
return parent.loc.start.line === parent.loc.end.line;
|
||||
if (parent.type === "StaticBlock") {
|
||||
const openingBrace = sourceCode.getFirstToken(parent, { skip: 1 });
|
||||
return openingBrace.loc.start.line === parent.loc.end.line;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isLastInOneLinerClassBody(node) {
|
||||
const parent = node.parent;
|
||||
const nextToken = sourceCode.getTokenAfter(node);
|
||||
if (!nextToken || nextToken.value !== "}")
|
||||
return false;
|
||||
if (parent.type === "ClassBody")
|
||||
return parent.loc.start.line === parent.loc.end.line;
|
||||
return false;
|
||||
}
|
||||
function checkForSemicolon(node) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
const isSemi = isSemicolonToken(lastToken);
|
||||
if (never) {
|
||||
const nextToken = sourceCode.getTokenAfter(node);
|
||||
if (isSemi && canRemoveSemicolon(node)) {
|
||||
report(node, true);
|
||||
} else if (!isSemi && beforeStatementContinuationChars === "always" && node.type !== "PropertyDefinition" && maybeAsiHazardBefore(nextToken)) {
|
||||
report(node);
|
||||
}
|
||||
} else {
|
||||
const oneLinerBlock = exceptOneLine && isLastInOneLinerBlock(node);
|
||||
const oneLinerClassBody = exceptOneLineClassBody && isLastInOneLinerClassBody(node);
|
||||
const oneLinerBlockOrClassBody = oneLinerBlock || oneLinerClassBody;
|
||||
if (isSemi && oneLinerBlockOrClassBody)
|
||||
report(node, true);
|
||||
else if (!isSemi && !oneLinerBlockOrClassBody)
|
||||
report(node);
|
||||
}
|
||||
}
|
||||
function checkForSemicolonForVariableDeclaration(node) {
|
||||
const parent = node.parent;
|
||||
if ((parent.type !== "ForStatement" || parent.init !== node) && (!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node)) {
|
||||
checkForSemicolon(node);
|
||||
}
|
||||
}
|
||||
return {
|
||||
VariableDeclaration: checkForSemicolonForVariableDeclaration,
|
||||
ExpressionStatement: checkForSemicolon,
|
||||
ReturnStatement: checkForSemicolon,
|
||||
ThrowStatement: checkForSemicolon,
|
||||
DoWhileStatement: checkForSemicolon,
|
||||
DebuggerStatement: checkForSemicolon,
|
||||
BreakStatement: checkForSemicolon,
|
||||
ContinueStatement: checkForSemicolon,
|
||||
ImportDeclaration: checkForSemicolon,
|
||||
ExportAllDeclaration: checkForSemicolon,
|
||||
ExportNamedDeclaration(node) {
|
||||
if (!node.declaration)
|
||||
checkForSemicolon(node);
|
||||
},
|
||||
ExportDefaultDeclaration(node) {
|
||||
if (!/(?:Class|Function)Declaration/u.test(node.declaration.type))
|
||||
checkForSemicolon(node);
|
||||
},
|
||||
PropertyDefinition: checkForSemicolon
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { semi as default };
|
||||
130
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-before-blocks.js
generated
vendored
Normal file
130
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-before-blocks.js
generated
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
import { c as createRule, i as isTokenOnSameLine, g as isArrowToken, E as isKeywordToken, x as isColonToken, V as getSwitchCaseColonToken, s as isFunction } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
function isFunctionBody(node) {
|
||||
const parent = node.parent;
|
||||
return node.type === "BlockStatement" && isFunction(parent) && parent.body === node;
|
||||
}
|
||||
var spaceBeforeBlocks = createRule({
|
||||
name: "space-before-blocks",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before blocks"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
keywords: {
|
||||
type: "string",
|
||||
enum: ["always", "never", "off"]
|
||||
},
|
||||
functions: {
|
||||
type: "string",
|
||||
enum: ["always", "never", "off"]
|
||||
},
|
||||
classes: {
|
||||
type: "string",
|
||||
enum: ["always", "never", "off"]
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedSpace: "Unexpected space before opening brace.",
|
||||
missingSpace: "Missing space before opening brace."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const config = context.options[0];
|
||||
const sourceCode = context.sourceCode;
|
||||
let alwaysFunctions = true;
|
||||
let alwaysKeywords = true;
|
||||
let alwaysClasses = true;
|
||||
let neverFunctions = false;
|
||||
let neverKeywords = false;
|
||||
let neverClasses = false;
|
||||
if (typeof config === "object") {
|
||||
alwaysFunctions = config.functions === "always";
|
||||
alwaysKeywords = config.keywords === "always";
|
||||
alwaysClasses = config.classes === "always";
|
||||
neverFunctions = config.functions === "never";
|
||||
neverKeywords = config.keywords === "never";
|
||||
neverClasses = config.classes === "never";
|
||||
} else if (config === "never") {
|
||||
alwaysFunctions = false;
|
||||
alwaysKeywords = false;
|
||||
alwaysClasses = false;
|
||||
neverFunctions = true;
|
||||
neverKeywords = true;
|
||||
neverClasses = true;
|
||||
}
|
||||
function isConflicted(precedingToken, node) {
|
||||
return isArrowToken(precedingToken) || isKeywordToken(precedingToken) && !isFunctionBody(node) || isColonToken(precedingToken) && "parent" in node && node.parent && node.parent.type === "SwitchCase" && precedingToken === getSwitchCaseColonToken(node.parent, sourceCode);
|
||||
}
|
||||
function checkPrecedingSpace(node) {
|
||||
const precedingToken = sourceCode.getTokenBefore(node);
|
||||
if (precedingToken && !isConflicted(precedingToken, node) && isTokenOnSameLine(precedingToken, node)) {
|
||||
const hasSpace = sourceCode.isSpaceBetween(precedingToken, node);
|
||||
let requireSpace;
|
||||
let requireNoSpace;
|
||||
if (isFunctionBody(node)) {
|
||||
requireSpace = alwaysFunctions;
|
||||
requireNoSpace = neverFunctions;
|
||||
} else if (node.type === "ClassBody") {
|
||||
requireSpace = alwaysClasses;
|
||||
requireNoSpace = neverClasses;
|
||||
} else {
|
||||
requireSpace = alwaysKeywords;
|
||||
requireNoSpace = neverKeywords;
|
||||
}
|
||||
if (requireSpace && !hasSpace) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "missingSpace",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(node, " ");
|
||||
}
|
||||
});
|
||||
} else if (requireNoSpace && hasSpace) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedSpace",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([precedingToken.range[1], node.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkSpaceBeforeCaseBlock(node) {
|
||||
const cases = node.cases;
|
||||
let openingBrace;
|
||||
if (cases.length > 0)
|
||||
openingBrace = sourceCode.getTokenBefore(cases[0]);
|
||||
else
|
||||
openingBrace = sourceCode.getLastToken(node, 1);
|
||||
checkPrecedingSpace(openingBrace);
|
||||
}
|
||||
return {
|
||||
BlockStatement: checkPrecedingSpace,
|
||||
ClassBody: checkPrecedingSpace,
|
||||
SwitchStatement: checkSpaceBeforeCaseBlock
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { spaceBeforeBlocks as default };
|
||||
110
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-before-function-paren.js
generated
vendored
Normal file
110
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-before-function-paren.js
generated
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
import { c as createRule, e as isOpeningParenToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var spaceBeforeFunctionParen = createRule({
|
||||
name: "space-before-function-paren",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before `function` definition opening parenthesis"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
anonymous: {
|
||||
type: "string",
|
||||
enum: ["always", "never", "ignore"]
|
||||
},
|
||||
named: {
|
||||
type: "string",
|
||||
enum: ["always", "never", "ignore"]
|
||||
},
|
||||
asyncArrow: {
|
||||
type: "string",
|
||||
enum: ["always", "never", "ignore"]
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedSpace: "Unexpected space before function parentheses.",
|
||||
missingSpace: "Missing space before function parentheses."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always";
|
||||
const overrideConfig = typeof context.options[0] === "object" ? context.options[0] : {};
|
||||
function isNamedFunction(node) {
|
||||
if (node.id)
|
||||
return true;
|
||||
const parent = node.parent;
|
||||
return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.kind === "get" || parent.kind === "set" || parent.method);
|
||||
}
|
||||
function getConfigForFunction(node) {
|
||||
if (node.type === "ArrowFunctionExpression") {
|
||||
if (node.async && isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 })))
|
||||
return overrideConfig.asyncArrow || baseConfig;
|
||||
} else if (isNamedFunction(node)) {
|
||||
return overrideConfig.named || baseConfig;
|
||||
} else if (!node.generator) {
|
||||
return overrideConfig.anonymous || baseConfig;
|
||||
}
|
||||
return "ignore";
|
||||
}
|
||||
function checkFunction(node) {
|
||||
const functionConfig = getConfigForFunction(node);
|
||||
if (functionConfig === "ignore")
|
||||
return;
|
||||
const rightToken = sourceCode.getFirstToken(node, isOpeningParenToken);
|
||||
const leftToken = sourceCode.getTokenBefore(rightToken);
|
||||
const hasSpacing = sourceCode.isSpaceBetween(leftToken, rightToken);
|
||||
if (hasSpacing && functionConfig === "never") {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: leftToken.loc.end,
|
||||
end: rightToken.loc.start
|
||||
},
|
||||
messageId: "unexpectedSpace",
|
||||
fix(fixer) {
|
||||
const comments = sourceCode.getCommentsBefore(rightToken);
|
||||
if (comments.some((comment) => comment.type === "Line"))
|
||||
return null;
|
||||
return fixer.replaceTextRange(
|
||||
[leftToken.range[1], rightToken.range[0]],
|
||||
comments.reduce((text, comment) => text + sourceCode.getText(comment), "")
|
||||
);
|
||||
}
|
||||
});
|
||||
} else if (!hasSpacing && functionConfig === "always") {
|
||||
context.report({
|
||||
node,
|
||||
loc: rightToken.loc,
|
||||
messageId: "missingSpace",
|
||||
fix: (fixer) => fixer.insertTextAfter(leftToken, " ")
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrowFunctionExpression: checkFunction,
|
||||
FunctionDeclaration: checkFunction,
|
||||
FunctionExpression: checkFunction
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { spaceBeforeFunctionParen as default };
|
||||
184
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-in-parens.js
generated
vendored
Normal file
184
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-in-parens.js
generated
vendored
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
import { c as createRule, e as isOpeningParenToken, f as isClosingParenToken, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var spaceInParens = createRule({
|
||||
name: "space-in-parens",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing inside parentheses"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptions: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
enum: ["{}", "[]", "()", "empty"]
|
||||
},
|
||||
uniqueItems: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missingOpeningSpace: "There must be a space after this paren.",
|
||||
missingClosingSpace: "There must be a space before this paren.",
|
||||
rejectedOpeningSpace: "There should be no space after this paren.",
|
||||
rejectedClosingSpace: "There should be no space before this paren."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const ALWAYS = context.options[0] === "always";
|
||||
const exceptionsArrayOptions = context.options[1] && context.options[1].exceptions || [];
|
||||
const options = {
|
||||
braceException: false,
|
||||
bracketException: false,
|
||||
parenException: false,
|
||||
empty: false
|
||||
};
|
||||
let exceptions = {
|
||||
openers: [],
|
||||
closers: []
|
||||
};
|
||||
if (exceptionsArrayOptions.length) {
|
||||
options.braceException = exceptionsArrayOptions.includes("{}");
|
||||
options.bracketException = exceptionsArrayOptions.includes("[]");
|
||||
options.parenException = exceptionsArrayOptions.includes("()");
|
||||
options.empty = exceptionsArrayOptions.includes("empty");
|
||||
}
|
||||
function getExceptions() {
|
||||
const openers = [];
|
||||
const closers = [];
|
||||
if (options.braceException) {
|
||||
openers.push("{");
|
||||
closers.push("}");
|
||||
}
|
||||
if (options.bracketException) {
|
||||
openers.push("[");
|
||||
closers.push("]");
|
||||
}
|
||||
if (options.parenException) {
|
||||
openers.push("(");
|
||||
closers.push(")");
|
||||
}
|
||||
if (options.empty) {
|
||||
openers.push(")");
|
||||
closers.push("(");
|
||||
}
|
||||
return {
|
||||
openers,
|
||||
closers
|
||||
};
|
||||
}
|
||||
const sourceCode = context.sourceCode;
|
||||
function isOpenerException(token) {
|
||||
return exceptions.openers.includes(token.value);
|
||||
}
|
||||
function isCloserException(token) {
|
||||
return exceptions.closers.includes(token.value);
|
||||
}
|
||||
function openerMissingSpace(openingParenToken, tokenAfterOpeningParen) {
|
||||
if (sourceCode.isSpaceBetween(openingParenToken, tokenAfterOpeningParen))
|
||||
return false;
|
||||
if (!options.empty && isClosingParenToken(tokenAfterOpeningParen))
|
||||
return false;
|
||||
if (ALWAYS)
|
||||
return !isOpenerException(tokenAfterOpeningParen);
|
||||
return isOpenerException(tokenAfterOpeningParen);
|
||||
}
|
||||
function openerRejectsSpace(openingParenToken, tokenAfterOpeningParen) {
|
||||
if (!isTokenOnSameLine(openingParenToken, tokenAfterOpeningParen))
|
||||
return false;
|
||||
if (tokenAfterOpeningParen.type === "Line")
|
||||
return false;
|
||||
if (!sourceCode.isSpaceBetween(openingParenToken, tokenAfterOpeningParen))
|
||||
return false;
|
||||
if (ALWAYS)
|
||||
return isOpenerException(tokenAfterOpeningParen);
|
||||
return !isOpenerException(tokenAfterOpeningParen);
|
||||
}
|
||||
function closerMissingSpace(tokenBeforeClosingParen, closingParenToken) {
|
||||
if (sourceCode.isSpaceBetween(tokenBeforeClosingParen, closingParenToken))
|
||||
return false;
|
||||
if (!options.empty && isOpeningParenToken(tokenBeforeClosingParen))
|
||||
return false;
|
||||
if (ALWAYS)
|
||||
return !isCloserException(tokenBeforeClosingParen);
|
||||
return isCloserException(tokenBeforeClosingParen);
|
||||
}
|
||||
function closerRejectsSpace(tokenBeforeClosingParen, closingParenToken) {
|
||||
if (!isTokenOnSameLine(tokenBeforeClosingParen, closingParenToken))
|
||||
return false;
|
||||
if (!sourceCode.isSpaceBetween(tokenBeforeClosingParen, closingParenToken))
|
||||
return false;
|
||||
if (ALWAYS)
|
||||
return isCloserException(tokenBeforeClosingParen);
|
||||
return !isCloserException(tokenBeforeClosingParen);
|
||||
}
|
||||
return {
|
||||
Program: function checkParenSpaces(node) {
|
||||
exceptions = getExceptions();
|
||||
const tokens = sourceCode.tokensAndComments;
|
||||
tokens.forEach((token, i) => {
|
||||
const prevToken = tokens[i - 1];
|
||||
const nextToken = tokens[i + 1];
|
||||
if (!isOpeningParenToken(token) && !isClosingParenToken(token))
|
||||
return;
|
||||
if (token.value === "(" && openerMissingSpace(token, nextToken)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingOpeningSpace",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (token.value === "(" && openerRejectsSpace(token, nextToken)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: token.loc.end, end: nextToken.loc.start },
|
||||
messageId: "rejectedOpeningSpace",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([token.range[1], nextToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (token.value === ")" && closerMissingSpace(prevToken, token)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: token.loc,
|
||||
messageId: "missingClosingSpace",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(token, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (token.value === ")" && closerRejectsSpace(prevToken, token)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: { start: prevToken.loc.end, end: token.loc.start },
|
||||
messageId: "rejectedClosingSpace",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([prevToken.range[1], token.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { spaceInParens as default };
|
||||
111
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-infix-ops.js
generated
vendored
Normal file
111
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-infix-ops.js
generated
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import { c as createRule, w as isEqToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var spaceInfixOps = createRule({
|
||||
name: "space-infix-ops",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require spacing around infix operators"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
int32Hint: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missingSpace: "Operator '{{operator}}' must be spaced."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const int32Hint = context.options[0] ? context.options[0].int32Hint === true : false;
|
||||
const sourceCode = context.sourceCode;
|
||||
function getFirstNonSpacedToken(left, right, op) {
|
||||
const operator = sourceCode.getFirstTokenBetween(left, right, (token) => token.value === op);
|
||||
const prev = sourceCode.getTokenBefore(operator);
|
||||
const next = sourceCode.getTokenAfter(operator);
|
||||
if (!sourceCode.isSpaceBetween(prev, operator) || !sourceCode.isSpaceBetween(operator, next))
|
||||
return operator;
|
||||
return null;
|
||||
}
|
||||
function report(mainNode, culpritToken) {
|
||||
context.report({
|
||||
node: mainNode,
|
||||
loc: culpritToken.loc,
|
||||
messageId: "missingSpace",
|
||||
data: {
|
||||
operator: culpritToken.value
|
||||
},
|
||||
fix(fixer) {
|
||||
const previousToken = sourceCode.getTokenBefore(culpritToken);
|
||||
const afterToken = sourceCode.getTokenAfter(culpritToken);
|
||||
let fixString = "";
|
||||
if (culpritToken.range[0] - previousToken.range[1] === 0)
|
||||
fixString = " ";
|
||||
fixString += culpritToken.value;
|
||||
if (afterToken.range[0] - culpritToken.range[1] === 0)
|
||||
fixString += " ";
|
||||
return fixer.replaceText(culpritToken, fixString);
|
||||
}
|
||||
});
|
||||
}
|
||||
function checkBinary(node) {
|
||||
const leftNode = "typeAnnotation" in node.left && node.left.typeAnnotation ? node.left.typeAnnotation : node.left;
|
||||
const rightNode = node.right;
|
||||
const operator = "operator" in node && node.operator ? node.operator : "=";
|
||||
const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, operator);
|
||||
if (nonSpacedNode) {
|
||||
if (!(int32Hint && sourceCode.getText(node).endsWith("|0")))
|
||||
report(node, nonSpacedNode);
|
||||
}
|
||||
}
|
||||
function checkConditional(node) {
|
||||
const nonSpacedConsequentNode = getFirstNonSpacedToken(node.test, node.consequent, "?");
|
||||
const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":");
|
||||
if (nonSpacedConsequentNode)
|
||||
report(node, nonSpacedConsequentNode);
|
||||
if (nonSpacedAlternateNode)
|
||||
report(node, nonSpacedAlternateNode);
|
||||
}
|
||||
function checkVar(node) {
|
||||
const leftNode = node.id.typeAnnotation ? node.id.typeAnnotation : node.id;
|
||||
const rightNode = node.init;
|
||||
if (rightNode) {
|
||||
const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
|
||||
if (nonSpacedNode)
|
||||
report(node, nonSpacedNode);
|
||||
}
|
||||
}
|
||||
return {
|
||||
AssignmentExpression: checkBinary,
|
||||
AssignmentPattern: checkBinary,
|
||||
BinaryExpression: checkBinary,
|
||||
LogicalExpression: checkBinary,
|
||||
ConditionalExpression: checkConditional,
|
||||
VariableDeclarator: checkVar,
|
||||
// TODO: Stage 3: Overridden by ts version, can delete directly
|
||||
PropertyDefinition(node) {
|
||||
if (!node.value)
|
||||
return;
|
||||
const operatorToken = sourceCode.getTokenBefore(node.value, isEqToken);
|
||||
const leftToken = sourceCode.getTokenBefore(operatorToken);
|
||||
const rightToken = sourceCode.getTokenAfter(operatorToken);
|
||||
if (!sourceCode.isSpaceBetween(leftToken, operatorToken) || !sourceCode.isSpaceBetween(operatorToken, rightToken)) {
|
||||
report(node, operatorToken);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { spaceInfixOps as default };
|
||||
202
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-unary-ops.js
generated
vendored
Normal file
202
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/space-unary-ops.js
generated
vendored
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
import { c as createRule, d as canTokensBeAdjacent } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var spaceUnaryOps = createRule({
|
||||
name: "space-unary-ops",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before or after unary operators"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
words: {
|
||||
type: "boolean",
|
||||
default: true
|
||||
},
|
||||
nonwords: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
overrides: {
|
||||
type: "object",
|
||||
additionalProperties: {
|
||||
type: "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedBefore: "Unexpected space before unary operator '{{operator}}'.",
|
||||
unexpectedAfter: "Unexpected space after unary operator '{{operator}}'.",
|
||||
unexpectedAfterWord: "Unexpected space after unary word operator '{{word}}'.",
|
||||
wordOperator: "Unary word operator '{{word}}' must be followed by whitespace.",
|
||||
operator: "Unary operator '{{operator}}' must be followed by whitespace.",
|
||||
beforeUnaryExpressions: "Space is required before unary expressions '{{token}}'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const options = context.options[0] || { words: true, nonwords: false };
|
||||
const sourceCode = context.sourceCode;
|
||||
function isFirstBangInBangBangExpression(node) {
|
||||
return node && node.type === "UnaryExpression" && node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
|
||||
}
|
||||
function overrideExistsForOperator(operator) {
|
||||
return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
|
||||
}
|
||||
function overrideEnforcesSpaces(operator) {
|
||||
return options.overrides?.[operator];
|
||||
}
|
||||
function verifyWordHasSpaces(node, firstToken, secondToken, word) {
|
||||
if (secondToken.range[0] === firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wordOperator",
|
||||
data: {
|
||||
word
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(firstToken, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) {
|
||||
if (canTokensBeAdjacent(firstToken, secondToken)) {
|
||||
if (secondToken.range[0] > firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedAfterWord",
|
||||
data: {
|
||||
word
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) {
|
||||
if (overrideExistsForOperator(word)) {
|
||||
if (overrideEnforcesSpaces(word))
|
||||
verifyWordHasSpaces(node, firstToken, secondToken, word);
|
||||
else
|
||||
verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
|
||||
} else if (options.words) {
|
||||
verifyWordHasSpaces(node, firstToken, secondToken, word);
|
||||
} else {
|
||||
verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
|
||||
}
|
||||
}
|
||||
function checkForSpacesAfterYield(node) {
|
||||
const tokens = sourceCode.getFirstTokens(node, 3);
|
||||
const word = "yield";
|
||||
if (!node.argument || node.delegate)
|
||||
return;
|
||||
checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word);
|
||||
}
|
||||
function checkForSpacesAfterAwait(node) {
|
||||
const tokens = sourceCode.getFirstTokens(node, 3);
|
||||
checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await");
|
||||
}
|
||||
function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
|
||||
if ("prefix" in node && node.prefix) {
|
||||
if (isFirstBangInBangBangExpression(node))
|
||||
return;
|
||||
if (firstToken.range[1] === secondToken.range[0]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "operator",
|
||||
data: {
|
||||
operator: firstToken.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(firstToken, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (firstToken.range[1] === secondToken.range[0]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "beforeUnaryExpressions",
|
||||
data: {
|
||||
token: secondToken.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(secondToken, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) {
|
||||
if ("prefix" in node && node.prefix) {
|
||||
if (secondToken.range[0] > firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedAfter",
|
||||
data: {
|
||||
operator: firstToken.value
|
||||
},
|
||||
fix(fixer) {
|
||||
if (canTokensBeAdjacent(firstToken, secondToken))
|
||||
return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (secondToken.range[0] > firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedBefore",
|
||||
data: {
|
||||
operator: secondToken.value
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkForSpaces(node) {
|
||||
const tokens = node.type === "UpdateExpression" && !node.prefix ? sourceCode.getLastTokens(node, 2) : sourceCode.getFirstTokens(node, 2);
|
||||
const firstToken = tokens[0];
|
||||
const secondToken = tokens[1];
|
||||
if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") {
|
||||
checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value);
|
||||
return;
|
||||
}
|
||||
const operator = "prefix" in node && node.prefix ? tokens[0].value : tokens[1].value;
|
||||
if (overrideExistsForOperator(operator)) {
|
||||
if (overrideEnforcesSpaces(operator))
|
||||
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
|
||||
else
|
||||
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
|
||||
} else if (options.nonwords) {
|
||||
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
|
||||
} else {
|
||||
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
|
||||
}
|
||||
}
|
||||
return {
|
||||
UnaryExpression: checkForSpaces,
|
||||
UpdateExpression: checkForSpaces,
|
||||
NewExpression: checkForSpaces,
|
||||
YieldExpression: checkForSpacesAfterYield,
|
||||
AwaitExpression: checkForSpacesAfterAwait
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { spaceUnaryOps as default };
|
||||
229
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/spaced-comment.js
generated
vendored
Normal file
229
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/spaced-comment.js
generated
vendored
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
import { c as createRule, Q as LINEBREAKS } from '../utils.js';
|
||||
import { e as escapeStringRegexp } from '../vendor.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
function escape(s) {
|
||||
return `(?:${escapeStringRegexp(s)})`;
|
||||
}
|
||||
function escapeAndRepeat(s) {
|
||||
return `${escape(s)}+`;
|
||||
}
|
||||
function parseMarkersOption(markers) {
|
||||
if (!markers.includes("*"))
|
||||
return markers.concat("*");
|
||||
return markers;
|
||||
}
|
||||
function createExceptionsPattern(exceptions) {
|
||||
let pattern = "";
|
||||
if (exceptions.length === 0) {
|
||||
pattern += "\\s";
|
||||
} else {
|
||||
pattern += "(?:\\s|";
|
||||
if (exceptions.length === 1) {
|
||||
pattern += escapeAndRepeat(exceptions[0]);
|
||||
} else {
|
||||
pattern += "(?:";
|
||||
pattern += exceptions.map(escapeAndRepeat).join("|");
|
||||
pattern += ")";
|
||||
}
|
||||
pattern += `(?:$|[${Array.from(LINEBREAKS).join("")}]))`;
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
function createAlwaysStylePattern(markers, exceptions) {
|
||||
let pattern = "^";
|
||||
if (markers.length === 1) {
|
||||
pattern += escape(markers[0]);
|
||||
} else {
|
||||
pattern += "(?:";
|
||||
pattern += markers.map(escape).join("|");
|
||||
pattern += ")";
|
||||
}
|
||||
pattern += "?";
|
||||
pattern += createExceptionsPattern(exceptions);
|
||||
return new RegExp(pattern, "u");
|
||||
}
|
||||
function createNeverStylePattern(markers) {
|
||||
const pattern = `^(${markers.map(escape).join("|")})?[ ]+`;
|
||||
return new RegExp(pattern, "u");
|
||||
}
|
||||
var spacedComment = createRule({
|
||||
name: "spaced-comment",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce consistent spacing after the `//` or `/*` in a comment"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptions: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
markers: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
line: {
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptions: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
markers: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
},
|
||||
block: {
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptions: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
markers: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
balanced: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpectedSpaceAfterMarker: "Unexpected space or tab after marker ({{refChar}}) in comment.",
|
||||
expectedExceptionAfter: "Expected exception block, space or tab after '{{refChar}}' in comment.",
|
||||
unexpectedSpaceBefore: "Unexpected space or tab before '*/' in comment.",
|
||||
unexpectedSpaceAfter: "Unexpected space or tab after '{{refChar}}' in comment.",
|
||||
expectedSpaceBefore: "Expected space or tab before '*/' in comment.",
|
||||
expectedSpaceAfter: "Expected space or tab after '{{refChar}}' in comment."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const requireSpace = context.options[0] !== "never";
|
||||
const config = context.options[1] || {};
|
||||
const balanced = config.block && config.block.balanced;
|
||||
const styleRules = ["block", "line"].reduce((rule, type) => {
|
||||
const nodeType = type;
|
||||
const markers = parseMarkersOption(config[nodeType] && config[nodeType]?.markers || config.markers || []);
|
||||
const exceptions = config[nodeType] && config[nodeType]?.exceptions || config.exceptions || [];
|
||||
const endNeverPattern = "[ ]+$";
|
||||
rule[nodeType] = {
|
||||
beginRegex: requireSpace ? createAlwaysStylePattern(markers, exceptions) : createNeverStylePattern(markers),
|
||||
endRegex: balanced && requireSpace ? new RegExp(`${createExceptionsPattern(exceptions)}$`, "u") : new RegExp(endNeverPattern, "u"),
|
||||
hasExceptions: exceptions.length > 0,
|
||||
captureMarker: new RegExp(`^(${markers.map(escape).join("|")})`, "u"),
|
||||
markers: new Set(markers)
|
||||
};
|
||||
return rule;
|
||||
}, {});
|
||||
function reportBegin(node, messageId, match, refChar) {
|
||||
const type = node.type.toLowerCase();
|
||||
const commentIdentifier = type === "block" ? "/*" : "//";
|
||||
context.report({
|
||||
node,
|
||||
fix(fixer) {
|
||||
const start = node.range[0];
|
||||
let end = start + 2;
|
||||
if (requireSpace) {
|
||||
if (match)
|
||||
end += match[0].length;
|
||||
return fixer.insertTextAfterRange([start, end], " ");
|
||||
}
|
||||
if (match)
|
||||
end += match[0].length;
|
||||
return fixer.replaceTextRange([start, end], commentIdentifier + (match && match[1] ? match[1] : ""));
|
||||
},
|
||||
messageId,
|
||||
data: { refChar }
|
||||
});
|
||||
}
|
||||
function reportEnd(node, messageId, match) {
|
||||
context.report({
|
||||
node,
|
||||
fix(fixer) {
|
||||
if (requireSpace)
|
||||
return fixer.insertTextAfterRange([node.range[0], node.range[1] - 2], " ");
|
||||
const end = node.range[1] - 2;
|
||||
let start = end;
|
||||
if (match)
|
||||
start -= match[0].length;
|
||||
return fixer.replaceTextRange([start, end], "");
|
||||
},
|
||||
messageId
|
||||
});
|
||||
}
|
||||
function checkCommentForSpace(node) {
|
||||
const type = node.type.toLowerCase();
|
||||
const rule = styleRules[type];
|
||||
const commentIdentifier = type === "block" ? "/*" : "//";
|
||||
if (node.value.length === 0 || rule.markers.has(node.value))
|
||||
return;
|
||||
if (type === "line" && (node.value.startsWith("/ <reference") || node.value.startsWith("/ <amd")))
|
||||
return;
|
||||
const beginMatch = rule.beginRegex.exec(node.value);
|
||||
const endMatch = rule.endRegex.exec(node.value);
|
||||
if (requireSpace) {
|
||||
if (!beginMatch) {
|
||||
const hasMarker = rule.captureMarker.exec(node.value);
|
||||
const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier;
|
||||
if (rule.hasExceptions)
|
||||
reportBegin(node, "expectedExceptionAfter", hasMarker, marker);
|
||||
else
|
||||
reportBegin(node, "expectedSpaceAfter", hasMarker, marker);
|
||||
}
|
||||
if (balanced && type === "block" && !endMatch)
|
||||
reportEnd(node, "expectedSpaceBefore", null);
|
||||
} else {
|
||||
if (beginMatch) {
|
||||
if (!beginMatch[1])
|
||||
reportBegin(node, "unexpectedSpaceAfter", beginMatch, commentIdentifier);
|
||||
else
|
||||
reportBegin(node, "unexpectedSpaceAfterMarker", beginMatch, beginMatch[1]);
|
||||
}
|
||||
if (balanced && type === "block" && endMatch)
|
||||
reportEnd(node, "unexpectedSpaceBefore", endMatch);
|
||||
}
|
||||
}
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.filter((token) => token.type !== "Shebang").forEach(checkCommentForSpace);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { spacedComment as default };
|
||||
82
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/switch-colon-spacing.js
generated
vendored
Normal file
82
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/switch-colon-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import { c as createRule, V as getSwitchCaseColonToken, k as isClosingBraceToken, i as isTokenOnSameLine, a as isCommentToken } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var switchColonSpacing = createRule({
|
||||
name: "switch-colon-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Enforce spacing around colons of switch statements"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean", default: false },
|
||||
after: { type: "boolean", default: true }
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
fixable: "whitespace",
|
||||
messages: {
|
||||
expectedBefore: "Expected space(s) before this colon.",
|
||||
expectedAfter: "Expected space(s) after this colon.",
|
||||
unexpectedBefore: "Unexpected space(s) before this colon.",
|
||||
unexpectedAfter: "Unexpected space(s) after this colon."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const options = context.options[0] || {};
|
||||
const beforeSpacing = options.before === true;
|
||||
const afterSpacing = options.after !== false;
|
||||
function isValidSpacing(left, right, expected) {
|
||||
return isClosingBraceToken(right) || !isTokenOnSameLine(left, right) || sourceCode.isSpaceBetween(left, right) === expected;
|
||||
}
|
||||
function commentsExistBetween(left, right) {
|
||||
return sourceCode.getFirstTokenBetween(
|
||||
left,
|
||||
right,
|
||||
{
|
||||
includeComments: true,
|
||||
filter: isCommentToken
|
||||
}
|
||||
) !== null;
|
||||
}
|
||||
function fix(fixer, left, right, spacing) {
|
||||
if (commentsExistBetween(left, right))
|
||||
return null;
|
||||
if (spacing)
|
||||
return fixer.insertTextAfter(left, " ");
|
||||
return fixer.removeRange([left.range[1], right.range[0]]);
|
||||
}
|
||||
return {
|
||||
SwitchCase(node) {
|
||||
const colonToken = getSwitchCaseColonToken(node, sourceCode);
|
||||
const beforeToken = sourceCode.getTokenBefore(colonToken);
|
||||
const afterToken = sourceCode.getTokenAfter(colonToken);
|
||||
if (!isValidSpacing(beforeToken, colonToken, beforeSpacing)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: colonToken.loc,
|
||||
messageId: beforeSpacing ? "expectedBefore" : "unexpectedBefore",
|
||||
fix: (fixer) => fix(fixer, beforeToken, colonToken, beforeSpacing)
|
||||
});
|
||||
}
|
||||
if (!isValidSpacing(colonToken, afterToken, afterSpacing)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: colonToken.loc,
|
||||
messageId: afterSpacing ? "expectedAfter" : "unexpectedAfter",
|
||||
fix: (fixer) => fix(fixer, colonToken, afterToken, afterSpacing)
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { switchColonSpacing as default };
|
||||
102
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/template-curly-spacing.js
generated
vendored
Normal file
102
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/template-curly-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
import { c as createRule, i as isTokenOnSameLine } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var templateCurlySpacing = createRule({
|
||||
name: "template-curly-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow spacing around embedded expressions of template strings"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
expectedBefore: "Expected space(s) before '}'.",
|
||||
expectedAfter: "Expected space(s) after '${'.",
|
||||
unexpectedBefore: "Unexpected space(s) before '}'.",
|
||||
unexpectedAfter: "Unexpected space(s) after '${'."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const always = context.options[0] === "always";
|
||||
function checkSpacingBefore(token) {
|
||||
if (!token.value.startsWith("}"))
|
||||
return;
|
||||
const prevToken = sourceCode.getTokenBefore(token, { includeComments: true });
|
||||
const hasSpace = sourceCode.isSpaceBetween(prevToken, token);
|
||||
if (!isTokenOnSameLine(prevToken, token))
|
||||
return;
|
||||
if (always && !hasSpace) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: token.loc.start,
|
||||
end: {
|
||||
line: token.loc.start.line,
|
||||
column: token.loc.start.column + 1
|
||||
}
|
||||
},
|
||||
messageId: "expectedBefore",
|
||||
fix: (fixer) => fixer.insertTextBefore(token, " ")
|
||||
});
|
||||
}
|
||||
if (!always && hasSpace) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: prevToken.loc.end,
|
||||
end: token.loc.start
|
||||
},
|
||||
messageId: "unexpectedBefore",
|
||||
fix: (fixer) => fixer.removeRange([prevToken.range[1], token.range[0]])
|
||||
});
|
||||
}
|
||||
}
|
||||
function checkSpacingAfter(token) {
|
||||
if (!token.value.endsWith("${"))
|
||||
return;
|
||||
const nextToken = sourceCode.getTokenAfter(token, { includeComments: true });
|
||||
const hasSpace = sourceCode.isSpaceBetween(token, nextToken);
|
||||
if (!isTokenOnSameLine(token, nextToken))
|
||||
return;
|
||||
if (always && !hasSpace) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: {
|
||||
line: token.loc.end.line,
|
||||
column: token.loc.end.column - 2
|
||||
},
|
||||
end: token.loc.end
|
||||
},
|
||||
messageId: "expectedAfter",
|
||||
fix: (fixer) => fixer.insertTextAfter(token, " ")
|
||||
});
|
||||
}
|
||||
if (!always && hasSpace) {
|
||||
context.report({
|
||||
loc: {
|
||||
start: token.loc.end,
|
||||
end: nextToken.loc.start
|
||||
},
|
||||
messageId: "unexpectedAfter",
|
||||
fix: (fixer) => fixer.removeRange([token.range[1], nextToken.range[0]])
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
TemplateElement(node) {
|
||||
const token = sourceCode.getFirstToken(node);
|
||||
checkSpacingBefore(token);
|
||||
checkSpacingAfter(token);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { templateCurlySpacing as default };
|
||||
70
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/template-tag-spacing.js
generated
vendored
Normal file
70
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/template-tag-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var templateTagSpacing = createRule({
|
||||
name: "template-tag-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow spacing between template tags and their literals"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["always", "never"]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
unexpected: "Unexpected space between template tag and template literal.",
|
||||
missing: "Missing space between template tag and template literal."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const never = context.options[0] !== "always";
|
||||
const sourceCode = context.sourceCode;
|
||||
function checkSpacing(node) {
|
||||
const tagToken = sourceCode.getTokenBefore(node.quasi);
|
||||
const literalToken = sourceCode.getFirstToken(node.quasi);
|
||||
const hasWhitespace = sourceCode.isSpaceBetween(tagToken, literalToken);
|
||||
if (never && hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: tagToken.loc.end,
|
||||
end: literalToken.loc.start
|
||||
},
|
||||
messageId: "unexpected",
|
||||
fix(fixer) {
|
||||
const comments = sourceCode.getCommentsBefore(node.quasi);
|
||||
if (comments.some((comment) => comment.type === "Line"))
|
||||
return null;
|
||||
return fixer.replaceTextRange(
|
||||
[tagToken.range[1], literalToken.range[0]],
|
||||
comments.reduce((text, comment) => text + sourceCode.getText(comment), "")
|
||||
);
|
||||
}
|
||||
});
|
||||
} else if (!never && !hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: node.loc.start,
|
||||
end: literalToken.loc.start
|
||||
},
|
||||
messageId: "missing",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(tagToken, " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
TaggedTemplateExpression: checkSpacing
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { templateTagSpacing as default };
|
||||
114
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/wrap-iife.js
generated
vendored
Normal file
114
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/wrap-iife.js
generated
vendored
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
import { c as createRule, H as isParenthesised, M as isParenthesized, G as skipChainExpression, C as getStaticPropertyName } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
function isCalleeOfNewExpression(node) {
|
||||
const maybeCallee = node.parent?.type === "ChainExpression" ? node.parent : node;
|
||||
return maybeCallee.parent?.type === "NewExpression" && maybeCallee.parent.callee === maybeCallee;
|
||||
}
|
||||
var wrapIife = createRule({
|
||||
name: "wrap-iife",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require parentheses around immediate `function` invocations"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["outside", "inside", "any"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
functionPrototypeMethods: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
],
|
||||
fixable: "code",
|
||||
messages: {
|
||||
wrapInvocation: "Wrap an immediate function invocation in parentheses.",
|
||||
wrapExpression: "Wrap only the function expression in parens.",
|
||||
moveInvocation: "Move the invocation into the parens that contain the function."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const style = context.options[0] || "outside";
|
||||
const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
|
||||
const sourceCode = context.sourceCode;
|
||||
function isWrappedInAnyParens(node) {
|
||||
return isParenthesised(sourceCode, node);
|
||||
}
|
||||
function isWrappedInGroupingParens(node) {
|
||||
return isParenthesized(node, sourceCode, 1);
|
||||
}
|
||||
function getFunctionNodeFromIIFE(node) {
|
||||
const callee = skipChainExpression(node.callee);
|
||||
if (callee.type === "FunctionExpression")
|
||||
return callee;
|
||||
if (includeFunctionPrototypeMethods && callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && (getStaticPropertyName(callee) === "call" || getStaticPropertyName(callee) === "apply")) {
|
||||
return callee.object;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
CallExpression(node) {
|
||||
const innerNode = getFunctionNodeFromIIFE(node);
|
||||
if (!innerNode)
|
||||
return;
|
||||
const isCallExpressionWrapped = isWrappedInAnyParens(node);
|
||||
const isFunctionExpressionWrapped = isWrappedInAnyParens(innerNode);
|
||||
if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrapInvocation",
|
||||
fix(fixer) {
|
||||
const nodeToSurround = style === "inside" ? innerNode : node;
|
||||
return fixer.replaceText(nodeToSurround, `(${sourceCode.getText(nodeToSurround)})`);
|
||||
}
|
||||
});
|
||||
} else if (style === "inside" && !isFunctionExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrapExpression",
|
||||
fix(fixer) {
|
||||
if (isWrappedInGroupingParens(node) && !isCalleeOfNewExpression(node)) {
|
||||
const parenAfter = sourceCode.getTokenAfter(node);
|
||||
return fixer.replaceTextRange(
|
||||
[
|
||||
innerNode.range[1],
|
||||
parenAfter.range[1]
|
||||
],
|
||||
`)${sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])}`
|
||||
);
|
||||
}
|
||||
return fixer.replaceText(innerNode, `(${sourceCode.getText(innerNode)})`);
|
||||
}
|
||||
});
|
||||
} else if (style === "outside" && !isCallExpressionWrapped) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "moveInvocation",
|
||||
fix(fixer) {
|
||||
const parenAfter = sourceCode.getTokenAfter(innerNode);
|
||||
return fixer.replaceTextRange(
|
||||
[
|
||||
parenAfter.range[0],
|
||||
node.range[1]
|
||||
],
|
||||
`${sourceCode.getText().slice(parenAfter.range[1], node.range[1])})`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { wrapIife as default };
|
||||
42
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/wrap-regex.js
generated
vendored
Normal file
42
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/wrap-regex.js
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var wrapRegex = createRule({
|
||||
name: "wrap-regex",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require parenthesis around regex literals"
|
||||
},
|
||||
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);
|
||||
const 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)})`)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { wrapRegex as default };
|
||||
88
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/yield-star-spacing.js
generated
vendored
Normal file
88
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/rules/yield-star-spacing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
import { c as createRule } from '../utils.js';
|
||||
import 'eslint-visitor-keys';
|
||||
import 'espree';
|
||||
|
||||
var yieldStarSpacing = createRule({
|
||||
name: "yield-star-spacing",
|
||||
package: "js",
|
||||
meta: {
|
||||
type: "layout",
|
||||
docs: {
|
||||
description: "Require or disallow spacing around the `*` in `yield*` expressions"
|
||||
},
|
||||
fixable: "whitespace",
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "string",
|
||||
enum: ["before", "after", "both", "neither"]
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean" },
|
||||
after: { type: "boolean" }
|
||||
},
|
||||
additionalProperties: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
messages: {
|
||||
missingBefore: "Missing space before *.",
|
||||
missingAfter: "Missing space after *.",
|
||||
unexpectedBefore: "Unexpected space before *.",
|
||||
unexpectedAfter: "Unexpected space after *."
|
||||
}
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const mode = function(option = "after") {
|
||||
if (typeof option === "string") {
|
||||
return {
|
||||
before: { before: true, after: false },
|
||||
after: { before: false, after: true },
|
||||
both: { before: true, after: true },
|
||||
neither: { before: false, after: false }
|
||||
}[option];
|
||||
}
|
||||
return option;
|
||||
}(context.options[0]);
|
||||
function checkSpacing(side, leftToken, rightToken) {
|
||||
if (sourceCode.isSpaceBetween(leftToken, rightToken) !== mode[side]) {
|
||||
const after = leftToken.value === "*";
|
||||
const spaceRequired = mode[side];
|
||||
const node = after ? leftToken : rightToken;
|
||||
const messageId = spaceRequired ? side === "before" ? "missingBefore" : "missingAfter" : side === "before" ? "unexpectedBefore" : "unexpectedAfter";
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
fix(fixer) {
|
||||
if (spaceRequired) {
|
||||
if (after)
|
||||
return fixer.insertTextAfter(node, " ");
|
||||
return fixer.insertTextBefore(node, " ");
|
||||
}
|
||||
return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function checkExpression(node) {
|
||||
if (!("delegate" in node && node.delegate))
|
||||
return;
|
||||
const tokens = sourceCode.getFirstTokens(node, 3);
|
||||
const yieldToken = tokens[0];
|
||||
const starToken = tokens[1];
|
||||
const nextToken = tokens[2];
|
||||
checkSpacing("before", yieldToken, starToken);
|
||||
checkSpacing("after", starToken, nextToken);
|
||||
}
|
||||
return {
|
||||
YieldExpression: checkExpression
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { yieldStarSpacing as default };
|
||||
614
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/utils.js
generated
vendored
Normal file
614
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,614 @@
|
|||
import { KEYS } from 'eslint-visitor-keys';
|
||||
import { tokenize, latestEcmaVersion } from 'espree';
|
||||
|
||||
function createAllConfigs(plugin, name, filter) {
|
||||
const rules = Object.fromEntries(
|
||||
Object.entries(plugin.rules).filter(
|
||||
([key, rule]) => (
|
||||
// Only include fixable rules
|
||||
rule.meta.fixable && !rule.meta.deprecated && key === rule.meta.docs.url.split("/").pop() && (true)
|
||||
)
|
||||
).map(([key]) => [`${name}/${key}`, 2])
|
||||
);
|
||||
return {
|
||||
plugins: {
|
||||
[name]: plugin
|
||||
},
|
||||
rules
|
||||
};
|
||||
}
|
||||
|
||||
const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
|
||||
const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u;
|
||||
const LINEBREAKS = /* @__PURE__ */ new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
|
||||
const LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/u;
|
||||
const STATEMENT_LIST_PARENTS = /* @__PURE__ */ new Set(["Program", "BlockStatement", "StaticBlock", "SwitchCase"]);
|
||||
const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u;
|
||||
const OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN = /^(?:[^\\]|\\.)*\\(?:[1-9]|0\d)/su;
|
||||
function createGlobalLinebreakMatcher() {
|
||||
return new RegExp(LINEBREAK_MATCHER.source, "gu");
|
||||
}
|
||||
function getUpperFunction(node) {
|
||||
for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
|
||||
if (anyFunctionPattern.test(currentNode.type))
|
||||
return currentNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isFunction(node) {
|
||||
return Boolean(node && anyFunctionPattern.test(node.type));
|
||||
}
|
||||
function isNullLiteral(node) {
|
||||
return node.type === "Literal" && node.value === null && !("regex" in node) && !("bigint" in node);
|
||||
}
|
||||
function getStaticStringValue(node) {
|
||||
switch (node.type) {
|
||||
case "Literal":
|
||||
if (node.value === null) {
|
||||
if (isNullLiteral(node))
|
||||
return String(node.value);
|
||||
if ("regex" in node && node.regex)
|
||||
return `/${node.regex.pattern}/${node.regex.flags}`;
|
||||
if ("bigint" in node && node.bigint)
|
||||
return node.bigint;
|
||||
} else {
|
||||
return String(node.value);
|
||||
}
|
||||
break;
|
||||
case "TemplateLiteral":
|
||||
if (node.expressions.length === 0 && node.quasis.length === 1)
|
||||
return node.quasis[0].value.cooked;
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getStaticPropertyName(node) {
|
||||
let prop;
|
||||
if (node) {
|
||||
switch (node.type) {
|
||||
case "ChainExpression":
|
||||
return getStaticPropertyName(node.expression);
|
||||
case "Property":
|
||||
case "PropertyDefinition":
|
||||
case "MethodDefinition":
|
||||
case "ImportAttribute":
|
||||
prop = node.key;
|
||||
break;
|
||||
case "MemberExpression":
|
||||
prop = node.property;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (prop) {
|
||||
if (prop.type === "Identifier" && !("computed" in node && node.computed))
|
||||
return prop.name;
|
||||
return getStaticStringValue(prop);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function skipChainExpression(node) {
|
||||
return node && node.type === "ChainExpression" ? node.expression : node;
|
||||
}
|
||||
function negate(f) {
|
||||
return (token) => !f(token);
|
||||
}
|
||||
function isParenthesised(sourceCode, node) {
|
||||
const previousToken = sourceCode.getTokenBefore(node);
|
||||
const nextToken = sourceCode.getTokenAfter(node);
|
||||
return !!previousToken && !!nextToken && previousToken.value === "(" && previousToken.range[1] <= node.range[0] && nextToken.value === ")" && nextToken.range[0] >= node.range[1];
|
||||
}
|
||||
function isEqToken(token) {
|
||||
return token.value === "=" && token.type === "Punctuator";
|
||||
}
|
||||
function isArrowToken(token) {
|
||||
return token.value === "=>" && token.type === "Punctuator";
|
||||
}
|
||||
function isCommaToken(token) {
|
||||
return token.value === "," && token.type === "Punctuator";
|
||||
}
|
||||
function isQuestionDotToken(token) {
|
||||
return token.value === "?." && token.type === "Punctuator";
|
||||
}
|
||||
function isSemicolonToken(token) {
|
||||
return token.value === ";" && token.type === "Punctuator";
|
||||
}
|
||||
function isColonToken(token) {
|
||||
return token.value === ":" && token.type === "Punctuator";
|
||||
}
|
||||
function isOpeningParenToken(token) {
|
||||
return token.value === "(" && token.type === "Punctuator";
|
||||
}
|
||||
function isClosingParenToken(token) {
|
||||
return token.value === ")" && token.type === "Punctuator";
|
||||
}
|
||||
function isOpeningBracketToken(token) {
|
||||
return token.value === "[" && token.type === "Punctuator";
|
||||
}
|
||||
function isClosingBracketToken(token) {
|
||||
return token.value === "]" && token.type === "Punctuator";
|
||||
}
|
||||
function isOpeningBraceToken(token) {
|
||||
return token.value === "{" && token.type === "Punctuator";
|
||||
}
|
||||
function isClosingBraceToken(token) {
|
||||
return token.value === "}" && token.type === "Punctuator";
|
||||
}
|
||||
function isCommentToken(token) {
|
||||
if (!token)
|
||||
return false;
|
||||
return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
|
||||
}
|
||||
function isKeywordToken(token) {
|
||||
return token.type === "Keyword";
|
||||
}
|
||||
function isLogicalExpression(node) {
|
||||
return node.type === "LogicalExpression" && (node.operator === "&&" || node.operator === "||");
|
||||
}
|
||||
function isCoalesceExpression(node) {
|
||||
return node.type === "LogicalExpression" && node.operator === "??";
|
||||
}
|
||||
function isMixedLogicalAndCoalesceExpressions(left, right) {
|
||||
return isLogicalExpression(left) && isCoalesceExpression(right) || isCoalesceExpression(left) && isLogicalExpression(right);
|
||||
}
|
||||
function getSwitchCaseColonToken(node, sourceCode) {
|
||||
if ("test" in node && node.test)
|
||||
return sourceCode.getTokenAfter(node.test, (token) => isColonToken(token));
|
||||
return sourceCode.getFirstToken(node, 1);
|
||||
}
|
||||
function isTopLevelExpressionStatement(node) {
|
||||
if (node.type !== "ExpressionStatement")
|
||||
return false;
|
||||
const parent = node.parent;
|
||||
return parent.type === "Program" || parent.type === "BlockStatement" && isFunction(parent.parent);
|
||||
}
|
||||
function isDirective(node) {
|
||||
return node.type === "ExpressionStatement" && typeof node.directive === "string";
|
||||
}
|
||||
function isTokenOnSameLine(left, right) {
|
||||
return left?.loc?.end.line === right?.loc?.start.line;
|
||||
}
|
||||
const isNotClosingParenToken = /* @__PURE__ */ negate(isClosingParenToken);
|
||||
const isNotCommaToken = /* @__PURE__ */ negate(isCommaToken);
|
||||
const isNotQuestionDotToken = /* @__PURE__ */ negate(isQuestionDotToken);
|
||||
const isNotOpeningParenToken = /* @__PURE__ */ negate(isOpeningParenToken);
|
||||
const isNotSemicolonToken = /* @__PURE__ */ negate(isSemicolonToken);
|
||||
function isStringLiteral(node) {
|
||||
return node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral";
|
||||
}
|
||||
function isSurroundedBy(val, character) {
|
||||
return val[0] === character && val[val.length - 1] === character;
|
||||
}
|
||||
function getPrecedence(node) {
|
||||
switch (node.type) {
|
||||
case "SequenceExpression":
|
||||
return 0;
|
||||
case "AssignmentExpression":
|
||||
case "ArrowFunctionExpression":
|
||||
case "YieldExpression":
|
||||
return 1;
|
||||
case "ConditionalExpression":
|
||||
return 3;
|
||||
case "LogicalExpression":
|
||||
switch (node.operator) {
|
||||
case "||":
|
||||
case "??":
|
||||
return 4;
|
||||
case "&&":
|
||||
return 5;
|
||||
}
|
||||
/* falls through */
|
||||
case "BinaryExpression":
|
||||
switch (node.operator) {
|
||||
case "|":
|
||||
return 6;
|
||||
case "^":
|
||||
return 7;
|
||||
case "&":
|
||||
return 8;
|
||||
case "==":
|
||||
case "!=":
|
||||
case "===":
|
||||
case "!==":
|
||||
return 9;
|
||||
case "<":
|
||||
case "<=":
|
||||
case ">":
|
||||
case ">=":
|
||||
case "in":
|
||||
case "instanceof":
|
||||
return 10;
|
||||
case "<<":
|
||||
case ">>":
|
||||
case ">>>":
|
||||
return 11;
|
||||
case "+":
|
||||
case "-":
|
||||
return 12;
|
||||
case "*":
|
||||
case "/":
|
||||
case "%":
|
||||
return 13;
|
||||
case "**":
|
||||
return 15;
|
||||
}
|
||||
/* falls through */
|
||||
case "UnaryExpression":
|
||||
case "AwaitExpression":
|
||||
return 16;
|
||||
case "UpdateExpression":
|
||||
return 17;
|
||||
case "CallExpression":
|
||||
case "ChainExpression":
|
||||
case "ImportExpression":
|
||||
return 18;
|
||||
case "NewExpression":
|
||||
return 19;
|
||||
default:
|
||||
if (node.type in KEYS)
|
||||
return 20;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
function isDecimalInteger(node) {
|
||||
return node.type === "Literal" && typeof node.value === "number" && DECIMAL_INTEGER_PATTERN.test(node.raw);
|
||||
}
|
||||
function isDecimalIntegerNumericToken(token) {
|
||||
return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value);
|
||||
}
|
||||
function getNextLocation(sourceCode, { column, line }) {
|
||||
if (column < sourceCode.lines[line - 1].length) {
|
||||
return {
|
||||
column: column + 1,
|
||||
line
|
||||
};
|
||||
}
|
||||
if (line < sourceCode.lines.length) {
|
||||
return {
|
||||
column: 0,
|
||||
line: line + 1
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isNumericLiteral(node) {
|
||||
return node.type === "Literal" && (typeof node.value === "number" || Boolean("bigint" in node && node.bigint));
|
||||
}
|
||||
function canTokensBeAdjacent(leftValue, rightValue) {
|
||||
const espreeOptions = {
|
||||
comment: true,
|
||||
ecmaVersion: latestEcmaVersion,
|
||||
range: true
|
||||
};
|
||||
let leftToken;
|
||||
if (typeof leftValue === "string") {
|
||||
let tokens;
|
||||
try {
|
||||
tokens = tokenize(leftValue, espreeOptions);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
const comments = tokens.comments;
|
||||
leftToken = tokens[tokens.length - 1];
|
||||
if (comments.length) {
|
||||
const lastComment = comments[comments.length - 1];
|
||||
if (!leftToken || lastComment.range[0] > leftToken.range[0])
|
||||
leftToken = lastComment;
|
||||
}
|
||||
} else {
|
||||
leftToken = leftValue;
|
||||
}
|
||||
if (leftToken.type === "Shebang" || leftToken.type === "Hashbang")
|
||||
return false;
|
||||
let rightToken;
|
||||
if (typeof rightValue === "string") {
|
||||
let tokens;
|
||||
try {
|
||||
tokens = tokenize(rightValue, espreeOptions);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
const comments = tokens.comments;
|
||||
rightToken = tokens[0];
|
||||
if (comments.length) {
|
||||
const firstComment = comments[0];
|
||||
if (!rightToken || firstComment.range[0] < rightToken.range[0])
|
||||
rightToken = firstComment;
|
||||
}
|
||||
} else {
|
||||
rightToken = rightValue;
|
||||
}
|
||||
if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") {
|
||||
if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") {
|
||||
const PLUS_TOKENS = /* @__PURE__ */ new Set(["+", "++"]);
|
||||
const MINUS_TOKENS = /* @__PURE__ */ new Set(["-", "--"]);
|
||||
return !(PLUS_TOKENS.has(leftToken.value) && PLUS_TOKENS.has(rightToken.value) || MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value));
|
||||
}
|
||||
if (leftToken.type === "Punctuator" && leftToken.value === "/")
|
||||
return !["Block", "Line", "RegularExpression"].includes(rightToken.type);
|
||||
return true;
|
||||
}
|
||||
if (leftToken.type === "String" || rightToken.type === "String" || leftToken.type === "Template" || rightToken.type === "Template")
|
||||
return true;
|
||||
if (leftToken.type !== "Numeric" && rightToken.type === "Numeric" && rightToken.value.startsWith("."))
|
||||
return true;
|
||||
if (leftToken.type === "Block" || rightToken.type === "Block" || rightToken.type === "Line")
|
||||
return true;
|
||||
if (rightToken.type === "PrivateIdentifier")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function hasOctalOrNonOctalDecimalEscapeSequence(rawString) {
|
||||
return OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN.test(rawString);
|
||||
}
|
||||
function getParentSyntaxParen(node, sourceCode) {
|
||||
const parent = node.parent;
|
||||
if (!parent)
|
||||
return null;
|
||||
switch (parent.type) {
|
||||
case "CallExpression":
|
||||
case "NewExpression":
|
||||
if (parent.arguments.length === 1 && parent.arguments[0] === node) {
|
||||
return sourceCode.getTokenAfter(
|
||||
parent.callee,
|
||||
isOpeningParenToken
|
||||
);
|
||||
}
|
||||
return null;
|
||||
case "DoWhileStatement":
|
||||
if (parent.test === node) {
|
||||
return sourceCode.getTokenAfter(
|
||||
parent.body,
|
||||
isOpeningParenToken
|
||||
);
|
||||
}
|
||||
return null;
|
||||
case "IfStatement":
|
||||
case "WhileStatement":
|
||||
if (parent.test === node) {
|
||||
return sourceCode.getFirstToken(parent, 1);
|
||||
}
|
||||
return null;
|
||||
case "ImportExpression":
|
||||
if (parent.source === node) {
|
||||
return sourceCode.getFirstToken(parent, 1);
|
||||
}
|
||||
return null;
|
||||
case "SwitchStatement":
|
||||
if (parent.discriminant === node) {
|
||||
return sourceCode.getFirstToken(parent, 1);
|
||||
}
|
||||
return null;
|
||||
case "WithStatement":
|
||||
if (parent.object === node) {
|
||||
return sourceCode.getFirstToken(parent, 1);
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function isParenthesized(node, sourceCode, times = 1) {
|
||||
let maybeLeftParen, maybeRightParen;
|
||||
if (node == null || node.parent == null || node.parent.type === "CatchClause" && node.parent.param === node) {
|
||||
return false;
|
||||
}
|
||||
maybeLeftParen = maybeRightParen = node;
|
||||
do {
|
||||
maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
|
||||
maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
|
||||
} while (maybeLeftParen != null && maybeRightParen != null && (maybeLeftParen.type === "Punctuator" && maybeLeftParen.value === "(") && (maybeRightParen.type === "Punctuator" && maybeRightParen.value === ")") && maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && --times > 0);
|
||||
return times === 0;
|
||||
}
|
||||
|
||||
function isObjectNotArray(obj) {
|
||||
return typeof obj === "object" && obj != null && !Array.isArray(obj);
|
||||
}
|
||||
function deepMerge(first = {}, second = {}) {
|
||||
const keys = new Set(Object.keys(first).concat(Object.keys(second)));
|
||||
return Array.from(keys).reduce((acc, key) => {
|
||||
const firstHasKey = key in first;
|
||||
const secondHasKey = key in second;
|
||||
const firstValue = first[key];
|
||||
const secondValue = second[key];
|
||||
if (firstHasKey && secondHasKey) {
|
||||
if (isObjectNotArray(firstValue) && isObjectNotArray(secondValue)) {
|
||||
acc[key] = deepMerge(firstValue, secondValue);
|
||||
} else {
|
||||
acc[key] = secondValue;
|
||||
}
|
||||
} else if (firstHasKey) {
|
||||
acc[key] = firstValue;
|
||||
} else {
|
||||
acc[key] = secondValue;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function createRule({
|
||||
name,
|
||||
package: pkg,
|
||||
create,
|
||||
defaultOptions = [],
|
||||
meta
|
||||
}) {
|
||||
return {
|
||||
create: (context) => {
|
||||
const optionsCount = Math.max(context.options.length, defaultOptions.length);
|
||||
const optionsWithDefault = Array.from(
|
||||
{ length: optionsCount },
|
||||
(_, i) => {
|
||||
if (isObjectNotArray(context.options[i]) && isObjectNotArray(defaultOptions[i])) {
|
||||
return deepMerge(defaultOptions[i], context.options[i]);
|
||||
}
|
||||
return context.options[i] ?? defaultOptions[i];
|
||||
}
|
||||
);
|
||||
return create(context, optionsWithDefault);
|
||||
},
|
||||
defaultOptions,
|
||||
meta: {
|
||||
...meta,
|
||||
docs: {
|
||||
...meta.docs,
|
||||
url: `https://eslint.style/rules/${pkg}/${name}`
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let segmenter;
|
||||
function isASCII(value) {
|
||||
return /^[\u0020-\u007F]*$/u.test(value);
|
||||
}
|
||||
function getStringLength(value) {
|
||||
if (isASCII(value))
|
||||
return value.length;
|
||||
segmenter ??= new Intl.Segmenter();
|
||||
return [...segmenter.segment(value)].length;
|
||||
}
|
||||
|
||||
const KEYWORDS_JS = [
|
||||
"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"
|
||||
];
|
||||
|
||||
class FixTracker {
|
||||
/**
|
||||
* Create a new FixTracker.
|
||||
* @param fixer A ruleFixer instance.
|
||||
* @param sourceCode A SourceCode object for the current code.
|
||||
*/
|
||||
constructor(fixer, sourceCode) {
|
||||
this.fixer = fixer;
|
||||
this.sourceCode = sourceCode;
|
||||
this.retainedRange = null;
|
||||
}
|
||||
retainedRange;
|
||||
/**
|
||||
* Mark the given range as "retained", meaning that other fixes may not
|
||||
* may not modify this region in the same pass.
|
||||
* @param range The range to retain.
|
||||
* @returns 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 node The node to use as a starting point.
|
||||
* @returns The same RuleFixer, for chained calls.
|
||||
*/
|
||||
retainEnclosingFunction(node) {
|
||||
const functionNode = 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 nodeOrToken The node or token to use as a starting
|
||||
* point. The token to the left and right are use in the range.
|
||||
* @returns 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 range The range to remove in the fix.
|
||||
* @param text The text to insert in place of the range.
|
||||
* @returns 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 nodeOrToken The node or token to remove.
|
||||
* @returns The fix command.
|
||||
*/
|
||||
remove(nodeOrToken) {
|
||||
return this.replaceTextRange(nodeOrToken.range, "");
|
||||
}
|
||||
}
|
||||
|
||||
export { isStringLiteral as A, isSurroundedBy as B, getStaticPropertyName as C, getStringLength as D, isKeywordToken as E, COMMENTS_IGNORE_PATTERN as F, skipChainExpression as G, isParenthesised as H, getPrecedence as I, isDecimalInteger as J, KEYWORDS_JS as K, LINEBREAK_MATCHER as L, isParenthesized as M, isMixedLogicalAndCoalesceExpressions as N, isTopLevelExpressionStatement as O, FixTracker as P, LINEBREAKS as Q, isDirective as R, STATEMENT_LIST_PARENTS as S, isNumericLiteral as T, hasOctalOrNonOctalDecimalEscapeSequence as U, getSwitchCaseColonToken as V, isCommentToken as a, isCommaToken as b, createRule as c, canTokensBeAdjacent as d, isOpeningParenToken as e, isClosingParenToken as f, isArrowToken as g, getNextLocation as h, isTokenOnSameLine as i, isClosingBracketToken as j, isClosingBraceToken as k, isOpeningBracketToken as l, isNotCommaToken as m, isNotOpeningParenToken as n, isNotClosingParenToken as o, createAllConfigs as p, isDecimalIntegerNumericToken as q, isNotQuestionDotToken as r, isFunction as s, isSemicolonToken as t, isQuestionDotToken as u, isOpeningBraceToken as v, isEqToken as w, isColonToken as x, isNotSemicolonToken as y, createGlobalLinebreakMatcher as z };
|
||||
13
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/vendor.js
generated
vendored
Normal file
13
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/dist/vendor.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function escapeStringRegexp(string) {
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
// Escape characters with special meaning either inside or outside character sets.
|
||||
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
||||
return string
|
||||
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
||||
.replace(/-/g, '\\x2d');
|
||||
}
|
||||
|
||||
export { escapeStringRegexp as e };
|
||||
118
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/package.json
generated
vendored
Normal file
118
parts/3/phonebookBackend/node_modules/@stylistic/eslint-plugin-js/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
"name": "@stylistic/eslint-plugin-js",
|
||||
"type": "module",
|
||||
"version": "4.4.0",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/eslint-stylistic/eslint-stylistic#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint-stylistic/eslint-stylistic.git",
|
||||
"directory": "packages/eslint-plugin-js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint-stylistic/eslint-stylistic/issues"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/dts/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./define-config-support": {
|
||||
"types": "./dist/dts/define-config-support.d.ts"
|
||||
},
|
||||
"./rule-options": {
|
||||
"types": "./dist/dts/rule-options.d.ts"
|
||||
},
|
||||
"./rules/array-bracket-newline": "./dist/rules/array-bracket-newline.js",
|
||||
"./rules/array-bracket-spacing": "./dist/rules/array-bracket-spacing.js",
|
||||
"./rules/array-element-newline": "./dist/rules/array-element-newline.js",
|
||||
"./rules/arrow-parens": "./dist/rules/arrow-parens.js",
|
||||
"./rules/arrow-spacing": "./dist/rules/arrow-spacing.js",
|
||||
"./rules/block-spacing": "./dist/rules/block-spacing.js",
|
||||
"./rules/brace-style": "./dist/rules/brace-style.js",
|
||||
"./rules/comma-dangle": "./dist/rules/comma-dangle.js",
|
||||
"./rules/comma-spacing": "./dist/rules/comma-spacing.js",
|
||||
"./rules/comma-style": "./dist/rules/comma-style.js",
|
||||
"./rules/computed-property-spacing": "./dist/rules/computed-property-spacing.js",
|
||||
"./rules/dot-location": "./dist/rules/dot-location.js",
|
||||
"./rules/eol-last": "./dist/rules/eol-last.js",
|
||||
"./rules/func-call-spacing": "./dist/rules/func-call-spacing.js",
|
||||
"./rules/function-call-argument-newline": "./dist/rules/function-call-argument-newline.js",
|
||||
"./rules/function-call-spacing": "./dist/rules/function-call-spacing.js",
|
||||
"./rules/function-paren-newline": "./dist/rules/function-paren-newline.js",
|
||||
"./rules/generator-star-spacing": "./dist/rules/generator-star-spacing.js",
|
||||
"./rules/implicit-arrow-linebreak": "./dist/rules/implicit-arrow-linebreak.js",
|
||||
"./rules/indent": "./dist/rules/indent.js",
|
||||
"./rules/jsx-quotes": "./dist/rules/jsx-quotes.js",
|
||||
"./rules/key-spacing": "./dist/rules/key-spacing.js",
|
||||
"./rules/keyword-spacing": "./dist/rules/keyword-spacing.js",
|
||||
"./rules/line-comment-position": "./dist/rules/line-comment-position.js",
|
||||
"./rules/linebreak-style": "./dist/rules/linebreak-style.js",
|
||||
"./rules/lines-around-comment": "./dist/rules/lines-around-comment.js",
|
||||
"./rules/lines-between-class-members": "./dist/rules/lines-between-class-members.js",
|
||||
"./rules/max-len": "./dist/rules/max-len.js",
|
||||
"./rules/max-statements-per-line": "./dist/rules/max-statements-per-line.js",
|
||||
"./rules/multiline-comment-style": "./dist/rules/multiline-comment-style.js",
|
||||
"./rules/multiline-ternary": "./dist/rules/multiline-ternary.js",
|
||||
"./rules/new-parens": "./dist/rules/new-parens.js",
|
||||
"./rules/newline-per-chained-call": "./dist/rules/newline-per-chained-call.js",
|
||||
"./rules/no-confusing-arrow": "./dist/rules/no-confusing-arrow.js",
|
||||
"./rules/no-extra-parens": "./dist/rules/no-extra-parens.js",
|
||||
"./rules/no-extra-semi": "./dist/rules/no-extra-semi.js",
|
||||
"./rules/no-floating-decimal": "./dist/rules/no-floating-decimal.js",
|
||||
"./rules/no-mixed-operators": "./dist/rules/no-mixed-operators.js",
|
||||
"./rules/no-mixed-spaces-and-tabs": "./dist/rules/no-mixed-spaces-and-tabs.js",
|
||||
"./rules/no-multi-spaces": "./dist/rules/no-multi-spaces.js",
|
||||
"./rules/no-multiple-empty-lines": "./dist/rules/no-multiple-empty-lines.js",
|
||||
"./rules/no-tabs": "./dist/rules/no-tabs.js",
|
||||
"./rules/no-trailing-spaces": "./dist/rules/no-trailing-spaces.js",
|
||||
"./rules/no-whitespace-before-property": "./dist/rules/no-whitespace-before-property.js",
|
||||
"./rules/nonblock-statement-body-position": "./dist/rules/nonblock-statement-body-position.js",
|
||||
"./rules/object-curly-newline": "./dist/rules/object-curly-newline.js",
|
||||
"./rules/object-curly-spacing": "./dist/rules/object-curly-spacing.js",
|
||||
"./rules/object-property-newline": "./dist/rules/object-property-newline.js",
|
||||
"./rules/one-var-declaration-per-line": "./dist/rules/one-var-declaration-per-line.js",
|
||||
"./rules/operator-linebreak": "./dist/rules/operator-linebreak.js",
|
||||
"./rules/padded-blocks": "./dist/rules/padded-blocks.js",
|
||||
"./rules/padding-line-between-statements": "./dist/rules/padding-line-between-statements.js",
|
||||
"./rules/quote-props": "./dist/rules/quote-props.js",
|
||||
"./rules/quotes": "./dist/rules/quotes.js",
|
||||
"./rules/rest-spread-spacing": "./dist/rules/rest-spread-spacing.js",
|
||||
"./rules/semi": "./dist/rules/semi.js",
|
||||
"./rules/semi-spacing": "./dist/rules/semi-spacing.js",
|
||||
"./rules/semi-style": "./dist/rules/semi-style.js",
|
||||
"./rules/space-before-blocks": "./dist/rules/space-before-blocks.js",
|
||||
"./rules/space-before-function-paren": "./dist/rules/space-before-function-paren.js",
|
||||
"./rules/space-in-parens": "./dist/rules/space-in-parens.js",
|
||||
"./rules/space-infix-ops": "./dist/rules/space-infix-ops.js",
|
||||
"./rules/space-unary-ops": "./dist/rules/space-unary-ops.js",
|
||||
"./rules/spaced-comment": "./dist/rules/spaced-comment.js",
|
||||
"./rules/switch-colon-spacing": "./dist/rules/switch-colon-spacing.js",
|
||||
"./rules/template-curly-spacing": "./dist/rules/template-curly-spacing.js",
|
||||
"./rules/template-tag-spacing": "./dist/rules/template-tag-spacing.js",
|
||||
"./rules/wrap-iife": "./dist/rules/wrap-iife.js",
|
||||
"./rules/wrap-regex": "./dist/rules/wrap-regex.js",
|
||||
"./rules/yield-star-spacing": "./dist/rules/yield-star-spacing.js"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/dts/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=9.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint-visitor-keys": "^4.2.0",
|
||||
"espree": "^10.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && rollup --config=rollup.config.mjs",
|
||||
"dev": "rollup --config=rollup.config.mjs --watch"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue